mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
move AsciiInputOutput over to threading
This commit is contained in:
parent
12753f31ae
commit
35ac787cd8
7 changed files with 8 additions and 8 deletions
87
src/threading/AsciiInputOutput.h
Normal file
87
src/threading/AsciiInputOutput.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#ifndef AsciiInputOutput_h
|
||||
#define AsciiInputOutput_h
|
||||
|
||||
#include "../Desc.h"
|
||||
#include "MsgThread.h"
|
||||
|
||||
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 & set_separator,
|
||||
const string & unset_field, const string & empty_field);
|
||||
|
||||
// Constructor that defines all separators, etc, besides empty_field, which is not needed for many
|
||||
// non-ascii-based io sources.
|
||||
// Use if you need either ValToODesc or EntryToVal.
|
||||
AsciiInputOutput(threading::MsgThread*, const string & set_separator,
|
||||
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 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.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
string empty_field;
|
||||
string unset_field;
|
||||
string meta_prefix;
|
||||
|
||||
threading::MsgThread* thread;
|
||||
};
|
||||
|
||||
#endif /* AsciiInputOuput_h */
|
Loading…
Add table
Add a link
Reference in a new issue