Move Type types to zeek namespace

This commit is contained in:
Tim Wojtulewicz 2020-06-04 10:40:43 -07:00
parent 4a1b39a2be
commit ed13972924
120 changed files with 2094 additions and 1934 deletions

View file

@ -81,7 +81,7 @@ public:
* @return The new value, or null on error. Errors must also be
* flagged via the thread.
*/
virtual threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const = 0;
virtual threading::Value* ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, zeek::TypeTag subtype = zeek::TYPE_ERROR) const = 0;
/**
* Convert an IP address into a string.

View file

@ -47,8 +47,8 @@ bool Field::Read(SerializationFormat* fmt)
name = copy_string(tmp_name.c_str());
type = (TypeTag) t;
subtype = (TypeTag) st;
type = static_cast<zeek::TypeTag>(t);
subtype = static_cast<zeek::TypeTag>(st);
return true;
}
@ -79,15 +79,15 @@ std::string Field::TypeName() const
// We do not support tables, if the internal Bro type is table it
// always is a set.
if ( type == TYPE_TABLE )
if ( type == zeek::TYPE_TABLE )
n = "set";
else
n = type_name(type);
n = zeek::type_name(type);
if ( (type == TYPE_TABLE) || (type == TYPE_VECTOR) )
if ( (type == zeek::TYPE_TABLE) || (type == zeek::TYPE_VECTOR) )
{
n += "[";
n += type_name(subtype);
n += zeek::type_name(subtype);
n += "]";
}
@ -99,13 +99,13 @@ Value::~Value()
if ( ! present )
return;
if ( type == TYPE_ENUM || type == TYPE_STRING || type == TYPE_FILE || type == TYPE_FUNC )
if ( type == zeek::TYPE_ENUM || type == zeek::TYPE_STRING || type == zeek::TYPE_FILE || type == zeek::TYPE_FUNC )
delete [] val.string_val.data;
else if ( type == TYPE_PATTERN )
else if ( type == zeek::TYPE_PATTERN )
delete [] val.pattern_text_val;
else if ( type == TYPE_TABLE )
else if ( type == zeek::TYPE_TABLE )
{
for ( int i = 0; i < val.set_val.size; i++ )
delete val.set_val.vals[i];
@ -113,7 +113,7 @@ Value::~Value()
delete [] val.set_val.vals;
}
else if ( type == TYPE_VECTOR )
else if ( type == zeek::TYPE_VECTOR )
{
for ( int i = 0; i < val.vector_val.size; i++ )
delete val.vector_val.vals[i];
@ -122,32 +122,32 @@ Value::~Value()
}
}
bool Value::IsCompatibleType(BroType* t, bool atomic_only)
bool Value::IsCompatibleType(zeek::BroType* t, bool atomic_only)
{
if ( ! t )
return false;
switch ( t->Tag() ) {
case TYPE_BOOL:
case TYPE_INT:
case TYPE_COUNT:
case TYPE_COUNTER:
case TYPE_PORT:
case TYPE_SUBNET:
case TYPE_ADDR:
case TYPE_DOUBLE:
case TYPE_TIME:
case TYPE_INTERVAL:
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
case TYPE_FUNC:
case zeek::TYPE_BOOL:
case zeek::TYPE_INT:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
case zeek::TYPE_PORT:
case zeek::TYPE_SUBNET:
case zeek::TYPE_ADDR:
case zeek::TYPE_DOUBLE:
case zeek::TYPE_TIME:
case zeek::TYPE_INTERVAL:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
case zeek::TYPE_FILE:
case zeek::TYPE_FUNC:
return true;
case TYPE_RECORD:
case zeek::TYPE_RECORD:
return ! atomic_only;
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
if ( atomic_only )
return false;
@ -158,7 +158,7 @@ bool Value::IsCompatibleType(BroType* t, bool atomic_only)
return IsCompatibleType(t->AsSetType()->GetIndices()->GetPureType().get(), true);
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
if ( atomic_only )
return false;
@ -180,22 +180,22 @@ bool Value::Read(SerializationFormat* fmt)
if ( ! (fmt->Read(&ty, "type") && fmt->Read(&sty, "subtype") && fmt->Read(&present, "present")) )
return false;
type = (TypeTag)(ty);
subtype = (TypeTag)(sty);
type = static_cast<zeek::TypeTag>(ty);
subtype = static_cast<zeek::TypeTag>(sty);
if ( ! present )
return true;
switch ( type ) {
case TYPE_BOOL:
case TYPE_INT:
case zeek::TYPE_BOOL:
case zeek::TYPE_INT:
return fmt->Read(&val.int_val, "int");
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
return fmt->Read(&val.uint_val, "uint");
case TYPE_PORT: {
case zeek::TYPE_PORT: {
int proto;
if ( ! (fmt->Read(&val.port_val.port, "port") && fmt->Read(&proto, "proto") ) ) {
return false;
@ -221,7 +221,7 @@ bool Value::Read(SerializationFormat* fmt)
return true;
}
case TYPE_ADDR:
case zeek::TYPE_ADDR:
{
char family;
@ -243,7 +243,7 @@ bool Value::Read(SerializationFormat* fmt)
abort();
}
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
{
char length;
char family;
@ -268,18 +268,18 @@ bool Value::Read(SerializationFormat* fmt)
abort();
}
case TYPE_DOUBLE:
case TYPE_TIME:
case TYPE_INTERVAL:
case zeek::TYPE_DOUBLE:
case zeek::TYPE_TIME:
case zeek::TYPE_INTERVAL:
return fmt->Read(&val.double_val, "double");
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
case TYPE_FUNC:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
case zeek::TYPE_FILE:
case zeek::TYPE_FUNC:
return fmt->Read(&val.string_val.data, &val.string_val.length, "string");
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
if ( ! fmt->Read(&val.set_val.size, "set_size") )
return false;
@ -297,7 +297,7 @@ bool Value::Read(SerializationFormat* fmt)
return true;
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
if ( ! fmt->Read(&val.vector_val.size, "vector_size") )
return false;
@ -317,7 +317,7 @@ bool Value::Read(SerializationFormat* fmt)
default:
reporter->InternalError("unsupported type %s in Value::Read",
type_name(type));
zeek::type_name(type));
}
return false;
@ -334,18 +334,18 @@ bool Value::Write(SerializationFormat* fmt) const
return true;
switch ( type ) {
case TYPE_BOOL:
case TYPE_INT:
case zeek::TYPE_BOOL:
case zeek::TYPE_INT:
return fmt->Write(val.int_val, "int");
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
return fmt->Write(val.uint_val, "uint");
case TYPE_PORT:
case zeek::TYPE_PORT:
return fmt->Write(val.port_val.port, "port") && fmt->Write(val.port_val.proto, "proto");
case TYPE_ADDR:
case zeek::TYPE_ADDR:
{
switch ( val.addr_val.family ) {
case IPv4:
@ -361,7 +361,7 @@ bool Value::Write(SerializationFormat* fmt) const
abort();
}
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
{
if ( ! fmt->Write((char)val.subnet_val.length, "subnet-length") )
return false;
@ -380,18 +380,18 @@ bool Value::Write(SerializationFormat* fmt) const
abort();
}
case TYPE_DOUBLE:
case TYPE_TIME:
case TYPE_INTERVAL:
case zeek::TYPE_DOUBLE:
case zeek::TYPE_TIME:
case zeek::TYPE_INTERVAL:
return fmt->Write(val.double_val, "double");
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
case TYPE_FUNC:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
case zeek::TYPE_FILE:
case zeek::TYPE_FUNC:
return fmt->Write(val.string_val.data, val.string_val.length, "string");
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
if ( ! fmt->Write(val.set_val.size, "set_size") )
return false;
@ -405,7 +405,7 @@ bool Value::Write(SerializationFormat* fmt) const
return true;
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
if ( ! fmt->Write(val.vector_val.size, "vector_size") )
return false;
@ -421,7 +421,7 @@ bool Value::Write(SerializationFormat* fmt) const
default:
reporter->InternalError("unsupported type %s in Value::Write",
type_name(type));
zeek::type_name(type));
}
// unreachable
@ -445,35 +445,35 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return nullptr; // unset field
switch ( val->type ) {
case TYPE_BOOL:
case zeek::TYPE_BOOL:
return val_mgr->Bool(val->val.int_val)->Ref();
case TYPE_INT:
case zeek::TYPE_INT:
return val_mgr->Int(val->val.int_val).release();
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
return val_mgr->Count(val->val.int_val).release();
case TYPE_DOUBLE:
case zeek::TYPE_DOUBLE:
return new DoubleVal(val->val.double_val);
case TYPE_TIME:
case zeek::TYPE_TIME:
return new TimeVal(val->val.double_val);
case TYPE_INTERVAL:
case zeek::TYPE_INTERVAL:
return new IntervalVal(val->val.double_val);
case TYPE_STRING:
case zeek::TYPE_STRING:
{
BroString *s = new BroString((const u_char*)val->val.string_val.data, val->val.string_val.length, true);
return new StringVal(s);
}
case TYPE_PORT:
case zeek::TYPE_PORT:
return val_mgr->Port(val->val.port_val.port, val->val.port_val.proto)->Ref();
case TYPE_ADDR:
case zeek::TYPE_ADDR:
{
IPAddr* addr = nullptr;
switch ( val->val.addr_val.family ) {
@ -494,7 +494,7 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return addrval;
}
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
{
IPAddr* addr = nullptr;
switch ( val->val.subnet_val.prefix.family ) {
@ -515,29 +515,29 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return subnetval;
}
case TYPE_PATTERN:
case zeek::TYPE_PATTERN:
{
RE_Matcher* re = new RE_Matcher(val->val.pattern_text_val);
re->Compile();
return new PatternVal(re);
}
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
IntrusivePtr<TypeList> set_index;
if ( val->val.set_val.size == 0 && val->subtype == TYPE_VOID )
IntrusivePtr<zeek::TypeList> set_index;
if ( val->val.set_val.size == 0 && val->subtype == zeek::TYPE_VOID )
// don't know type - unspecified table.
set_index = make_intrusive<TypeList>();
set_index = make_intrusive<zeek::TypeList>();
else
{
// all entries have to have the same type...
TypeTag stag = val->subtype;
if ( stag == TYPE_VOID )
TypeTag stag = val->val.set_val.vals[0]->type;
zeek::TypeTag stag = val->subtype;
if ( stag == zeek::TYPE_VOID )
stag = val->val.set_val.vals[0]->type;
IntrusivePtr<BroType> index_type;
IntrusivePtr<zeek::BroType> index_type;
if ( stag == TYPE_ENUM )
if ( stag == zeek::TYPE_ENUM )
{
// Enums are not a base-type, so need to look it up.
const auto& sv = val->val.set_val.vals[0]->val.string_val;
@ -556,13 +556,13 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
index_type = enum_id->GetType();
}
else
index_type = base_type(stag);
index_type = zeek::base_type(stag);
set_index = make_intrusive<TypeList>(index_type);
set_index = make_intrusive<zeek::TypeList>(index_type);
set_index->Append(std::move(index_type));
}
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
auto s = make_intrusive<zeek::SetType>(std::move(set_index), nullptr);
TableVal* t = new TableVal(std::move(s));
for ( int j = 0; j < val->val.set_val.size; j++ )
{
@ -573,23 +573,23 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return t;
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
IntrusivePtr<BroType> type;
IntrusivePtr<zeek::BroType> type;
if ( val->val.vector_val.size == 0 && val->subtype == TYPE_VOID )
if ( val->val.vector_val.size == 0 && val->subtype == zeek::TYPE_VOID )
// don't know type - unspecified table.
type = base_type(TYPE_ANY);
type = zeek::base_type(zeek::TYPE_ANY);
else
{
// all entries have to have the same type...
if ( val->subtype == TYPE_VOID )
type = base_type(val->val.vector_val.vals[0]->type);
if ( val->subtype == zeek::TYPE_VOID )
type = zeek::base_type(val->val.vector_val.vals[0]->type);
else
type = base_type(val->subtype);
type = zeek::base_type(val->subtype);
}
auto vt = make_intrusive<VectorType>(std::move(type));
auto vt = make_intrusive<zeek::VectorType>(std::move(type));
auto v = make_intrusive<VectorVal>(std::move(vt));
for ( int j = 0; j < val->val.vector_val.size; j++ )
@ -601,7 +601,7 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return v.release();
}
case TYPE_ENUM: {
case zeek::TYPE_ENUM: {
// Convert to string first to not have to deal with missing
// \0's...
std::string enum_string(val->val.string_val.data, val->val.string_val.length);
@ -618,7 +618,7 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
return nullptr;
}
EnumType* t = id->GetType()->AsEnumType();
zeek::EnumType* t = id->GetType()->AsEnumType();
int intval = t->Lookup(id->ModuleName(), id->Name());
if ( intval < 0 )
{

View file

@ -21,18 +21,23 @@ struct Field {
//! Needed by input framework. Port fields have two names (one for the
//! port, one for the type), and this specifies the secondary name.
const char* secondary_name;
TypeTag type; //! Type of the field.
TypeTag subtype; //! Inner type for sets and vectors.
zeek::TypeTag type; //! Type of the field.
zeek::TypeTag subtype; //! Inner type for sets and vectors.
bool optional; //! True if field is optional.
/**
* Constructor.
*/
Field(const char* name, const char* secondary_name, TypeTag type, TypeTag subtype, bool optional)
Field(const char* name, const char* secondary_name, zeek::TypeTag type, zeek::TypeTag subtype, bool optional)
: name(name ? copy_string(name) : nullptr),
secondary_name(secondary_name ? copy_string(secondary_name) : nullptr),
type(type), subtype(subtype), optional(optional) { }
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead")]]
Field(const char* name, const char* secondary_name, ::TypeTag type, ::TypeTag subtype, bool optional) :
Field(name, secondary_name, static_cast<zeek::TypeTag>(type), static_cast<zeek::TypeTag>(subtype), optional)
{}
/**
* Copy constructor.
*/
@ -85,8 +90,8 @@ private:
* those Vals supported).
*/
struct Value {
TypeTag type; //! The type of the value.
TypeTag subtype; //! Inner type for sets and vectors.
zeek::TypeTag type; //! The type of the value.
zeek::TypeTag subtype; //! Inner type for sets and vectors.
bool present; //! False for optional record fields that are not set.
struct set_t { bro_int_t size; Value** vals; };
@ -140,9 +145,15 @@ struct Value {
*
* arg_present: False if the value represents an optional record field
* that is not set.
*/
Value(TypeTag arg_type = TYPE_ERROR, bool arg_present = true)
: type(arg_type), subtype(TYPE_VOID), present(arg_present) {}
*/
Value(zeek::TypeTag arg_type = zeek::TYPE_ERROR, bool arg_present = true)
: type(arg_type), subtype(zeek::TYPE_VOID), present(arg_present)
{}
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag.")]]
Value(::TypeTag arg_type, bool arg_present = true)
: Value(static_cast<zeek::TypeTag>(arg_type), arg_present)
{}
/**
* Constructor.
@ -154,8 +165,14 @@ struct Value {
* arg_present: False if the value represents an optional record field
* that is not set.
*/
Value(TypeTag arg_type, TypeTag arg_subtype, bool arg_present = true)
: type(arg_type), subtype(arg_subtype), present(arg_present) {}
Value(zeek::TypeTag arg_type, zeek::TypeTag arg_subtype, bool arg_present = true)
: type(arg_type), subtype(arg_subtype), present(arg_present)
{}
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag.")]]
Value(::TypeTag arg_type, ::TypeTag arg_subtype, bool arg_present = true)
: Value(static_cast<zeek::TypeTag>(arg_type), static_cast<zeek::TypeTag>(arg_subtype), arg_present)
{}
/**
* Destructor.
@ -185,7 +202,7 @@ struct Value {
* Returns true if the type can be represented by a Value. If
* `atomic_only` is true, will not permit composite types. This
* method is thread-safe. */
static bool IsCompatibleType(BroType* t, bool atomic_only=false);
static bool IsCompatibleType(zeek::BroType* t, bool atomic_only=false);
/**
* Convenience function to delete an array of value pointers.
@ -209,7 +226,7 @@ struct Value {
private:
friend class ::IPAddr;
Value(const Value& other) { } // Disabled.
Value(const Value& other) = delete;
};
}

View file

@ -81,50 +81,50 @@ bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) con
switch ( val->type ) {
case TYPE_BOOL:
case zeek::TYPE_BOOL:
desc->Add(val->val.int_val ? "T" : "F");
break;
case TYPE_INT:
case zeek::TYPE_INT:
desc->Add(val->val.int_val);
break;
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
desc->Add(val->val.uint_val);
break;
case TYPE_PORT:
case zeek::TYPE_PORT:
desc->Add(val->val.port_val.port);
break;
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
desc->Add(Render(val->val.subnet_val));
break;
case TYPE_ADDR:
case zeek::TYPE_ADDR:
desc->Add(Render(val->val.addr_val));
break;
case TYPE_DOUBLE:
case zeek::TYPE_DOUBLE:
// Rendering via Add() truncates trailing 0s after the
// decimal point. The difference with TIME/INTERVAL is mainly
// to keep the log format consistent.
desc->Add(val->val.double_val, true);
break;
case TYPE_INTERVAL:
case TYPE_TIME:
case zeek::TYPE_INTERVAL:
case zeek::TYPE_TIME:
// Rendering via Render() keeps trailing 0s after the decimal
// point. The difference with DOUBLE is mainly to keep the
// log format consistent.
desc->Add(Render(val->val.double_val));
break;
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
case TYPE_FUNC:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
case zeek::TYPE_FILE:
case zeek::TYPE_FUNC:
{
int size = val->val.string_val.length;
const char* data = val->val.string_val.data;
@ -145,7 +145,7 @@ bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) con
break;
}
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
if ( ! val->val.set_val.size )
{
@ -172,7 +172,7 @@ bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) con
break;
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
if ( ! val->val.vector_val.size )
{
@ -208,7 +208,7 @@ bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) con
}
threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype) const
threading::Value* Ascii::ParseValue(const string& s, const string& name, zeek::TypeTag type, zeek::TypeTag subtype) const
{
if ( ! separators.unset_field.empty() && s.compare(separators.unset_field) == 0 ) // field is not set...
return new threading::Value(type, false);
@ -220,8 +220,8 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
size_t pos;
switch ( type ) {
case TYPE_ENUM:
case TYPE_STRING:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
{
string unescaped = get_unescaped_string(s);
val->val.string_val.length = unescaped.size();
@ -229,7 +229,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
break;
}
case TYPE_BOOL:
case zeek::TYPE_BOOL:
{
auto stripped = strstrip(s);
if ( stripped == "T" || stripped == "1" )
@ -245,28 +245,28 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
break;
}
case TYPE_INT:
case zeek::TYPE_INT:
val->val.int_val = strtoll(start, &end, 10);
if ( CheckNumberError(start, end) )
goto parse_error;
break;
case TYPE_DOUBLE:
case TYPE_TIME:
case TYPE_INTERVAL:
case zeek::TYPE_DOUBLE:
case zeek::TYPE_TIME:
case zeek::TYPE_INTERVAL:
val->val.double_val = strtod(start, &end);
if ( CheckNumberError(start, end) )
goto parse_error;
break;
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
val->val.uint_val = strtoull(start, &end, 10);
if ( CheckNumberError(start, end) )
goto parse_error;
break;
case TYPE_PORT:
case zeek::TYPE_PORT:
{
auto stripped = strstrip(s);
val->val.port_val.proto = TRANSPORT_UNKNOWN;
@ -298,7 +298,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
}
break;
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
{
string unescaped = strstrip(get_unescaped_string(s));
size_t pos = unescaped.find('/');
@ -321,14 +321,14 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
break;
}
case TYPE_ADDR:
case zeek::TYPE_ADDR:
{
string unescaped = strstrip(get_unescaped_string(s));
val->val.addr_val = ParseAddr(unescaped);
break;
}
case TYPE_PATTERN:
case zeek::TYPE_PATTERN:
{
string candidate = get_unescaped_string(s);
// A string is a candidate pattern iff it begins and ends with
@ -351,8 +351,8 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
goto parse_error;
}
case TYPE_TABLE:
case TYPE_VECTOR:
case zeek::TYPE_TABLE:
case zeek::TYPE_VECTOR:
// First - common initialization
// Then - initialization for table.
// Then - initialization for vector.
@ -377,13 +377,13 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
threading::Value** lvals = new threading::Value* [length];
if ( type == TYPE_TABLE )
if ( type == zeek::TYPE_TABLE )
{
val->val.set_val.vals = lvals;
val->val.set_val.size = length;
}
else if ( type == TYPE_VECTOR )
else if ( type == zeek::TYPE_VECTOR )
{
val->val.vector_val.vals = lvals;
val->val.vector_val.size = length;

View file

@ -51,7 +51,7 @@ public:
virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields,
threading::Value** vals) const;
virtual threading::Value* ParseValue(const std::string& s, const std::string& name,
TypeTag type, TypeTag subtype = TYPE_ERROR) const;
zeek::TypeTag type, zeek::TypeTag subtype = zeek::TYPE_ERROR) const;
private:
bool CheckNumberError(const char* start, const char* end) const;

View file

@ -78,7 +78,7 @@ bool JSON::Describe(ODesc* desc, Value* val, const std::string& name) const
return true;
}
threading::Value* JSON::ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype) const
threading::Value* JSON::ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, zeek::TypeTag subtype) const
{
GetThread()->Error("JSON formatter does not support parsing yet.");
return nullptr;
@ -97,37 +97,37 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
switch ( val->type )
{
case TYPE_BOOL:
case zeek::TYPE_BOOL:
writer.Bool(val->val.int_val != 0);
break;
case TYPE_INT:
case zeek::TYPE_INT:
writer.Int64(val->val.int_val);
break;
case TYPE_COUNT:
case TYPE_COUNTER:
case zeek::TYPE_COUNT:
case zeek::TYPE_COUNTER:
writer.Uint64(val->val.uint_val);
break;
case TYPE_PORT:
case zeek::TYPE_PORT:
writer.Uint64(val->val.port_val.port);
break;
case TYPE_SUBNET:
case zeek::TYPE_SUBNET:
writer.String(Formatter::Render(val->val.subnet_val));
break;
case TYPE_ADDR:
case zeek::TYPE_ADDR:
writer.String(Formatter::Render(val->val.addr_val));
break;
case TYPE_DOUBLE:
case TYPE_INTERVAL:
case zeek::TYPE_DOUBLE:
case zeek::TYPE_INTERVAL:
writer.Double(val->val.double_val);
break;
case TYPE_TIME:
case zeek::TYPE_TIME:
{
if ( timestamps == TS_ISO8601 )
{
@ -169,16 +169,16 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
break;
}
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
case TYPE_FUNC:
case zeek::TYPE_ENUM:
case zeek::TYPE_STRING:
case zeek::TYPE_FILE:
case zeek::TYPE_FUNC:
{
writer.String(json_escape_utf8(std::string(val->val.string_val.data, val->val.string_val.length)));
break;
}
case TYPE_TABLE:
case zeek::TYPE_TABLE:
{
writer.StartArray();
@ -189,7 +189,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
break;
}
case TYPE_VECTOR:
case zeek::TYPE_VECTOR:
{
writer.StartArray();

View file

@ -28,7 +28,7 @@ public:
bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const override;
bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields,
threading::Value** vals) const override;
threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const override;
threading::Value* ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, zeek::TypeTag subtype = zeek::TYPE_ERROR) const override;
class NullDoubleWriter : public rapidjson::Writer<rapidjson::StringBuffer> {
public: