factor out ascii input/output.

First step - factored out everything the logging classes
use ( so only output ).

Moved the script-level configuration to logging/main,
and made the individual writers just refer to it -
no idea if this is good design. It works. But I am happy
about opinions :)

Next step - add support for input...
This commit is contained in:
Bernhard Amann 2012-12-03 12:59:11 -08:00
parent f62df0de82
commit 501328d61a
13 changed files with 194 additions and 297 deletions

View file

@ -3,12 +3,54 @@
#ifndef AsciiInputOutput_h
#define AsciiInputOutput_h
#include "Desc.h"
#include "threading/MsgThread.h"
class AsciiInputOutput {
public:
AsciiInputOutput(threading::MsgThread*, const string & separator, const string & set_separator,
const string & empty_field, const string & unset_field);
~AsciiInputOutput();
// converts a threading value to the corresponding ascii representation
// returns false & logs an error with reporter in case an error occurs
bool ValToText(ODesc* desc, Value* val, const Field* field);
bool ValToODesc(ODesc* desc, threading::Value* val, const threading::Field* field) const;
/** Helper method to render an IP address as a string.
*
* @param addr The address.
*
* @return An ASCII representation of the address.
*/
static string Render(const threading::Value::addr_t& addr);
/** Helper method to render an subnet value as a string.
*
* @param addr The address.
*
* @return An ASCII representation of the address.
*/
static string Render(const threading::Value::subnet_t& subnet);
/** Helper method to render a double in Bro's standard precision.
*
* @param d The double.
*
* @return An ASCII representation of the double.
*/
static string Render(double d);
private:
string separator;
string set_separator;
string empty_field;
string unset_field;
string meta_prefix;
threading::MsgThread* thread;
};
#endif /* AsciiInputOuput_h */