and factor stuff out the input framework too.

This commit is contained in:
Bernhard Amann 2012-12-03 13:41:19 -08:00
parent 501328d61a
commit 9b2265877d
10 changed files with 339 additions and 292 deletions

View file

@ -8,6 +8,12 @@
class AsciiInputOutput {
public:
// Constructor that leaves separators, etc empty.
// Use if you just need functionality like StringToAddr, etc.
AsciiInputOutput(threading::MsgThread*);
// Constructor that defines all separators, etc.
// Use if you need either ValToODesc or EntryToVal.
AsciiInputOutput(threading::MsgThread*, const string & separator, const string & set_separator,
const string & empty_field, const string & unset_field);
~AsciiInputOutput();
@ -17,6 +23,9 @@ class AsciiInputOutput {
// returns false & logs an error with reporter in case an error occurs
bool ValToODesc(ODesc* desc, threading::Value* val, const threading::Field* field) const;
// convert the ascii representation of a field into a Value
threading::Value* EntryToVal(string s, string name, TypeTag type, TypeTag subtype = TYPE_ERROR) const;
/** Helper method to render an IP address as a string.
*
* @param addr The address.
@ -41,8 +50,24 @@ class AsciiInputOutput {
*/
static string Render(double d);
/**
* Convert a string into a TransportProto. This is just a utility
* function for Readers.
*
* @param proto the transport protocol
*/
TransportProto StringToProto(const string &proto) const;
/**
* Convert a string into a Value::addr_t. This is just a utility
* function for Readers.
*
* @param addr containing an ipv4 or ipv6 address
*/
threading::Value::addr_t StringToAddr(const string &addr) const;
private:
bool CheckNumberError(const string& s, const char * end) const;
string separator;
string set_separator;