mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Deprecate RecordVal::Lookup(const char*, bool)
Replace with GetField(const char*) and GetFieldOrDefault(const char*).
This commit is contained in:
parent
2b4d80c849
commit
5bf2ed02d7
14 changed files with 128 additions and 80 deletions
3
NEWS
3
NEWS
|
@ -202,6 +202,9 @@ Deprecated Functionality
|
||||||
- ``RecordVal::LookupWithDefault(int)`` is deprecated, use
|
- ``RecordVal::LookupWithDefault(int)`` is deprecated, use
|
||||||
``RecordVal::GetFieldOrDefault(int)``.
|
``RecordVal::GetFieldOrDefault(int)``.
|
||||||
|
|
||||||
|
- ``RecordVal::Lookup(const char*, bool)`` is deprecated, use either
|
||||||
|
``RecordVal::GetField()`` or ``RecordVal::GetFieldOrDefault()``.
|
||||||
|
|
||||||
Zeek 3.1.0
|
Zeek 3.1.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
14
src/Val.cc
14
src/Val.cc
|
@ -2781,14 +2781,24 @@ void RecordVal::DoneParsing()
|
||||||
parse_time_records.clear();
|
parse_time_records.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Val> RecordVal::Lookup(const char* field, bool with_default) const
|
const IntrusivePtr<Val>& RecordVal::GetField(const char* field) const
|
||||||
{
|
{
|
||||||
int idx = GetType()->AsRecordType()->FieldOffset(field);
|
int idx = GetType()->AsRecordType()->FieldOffset(field);
|
||||||
|
|
||||||
if ( idx < 0 )
|
if ( idx < 0 )
|
||||||
reporter->InternalError("missing record field: %s", field);
|
reporter->InternalError("missing record field: %s", field);
|
||||||
|
|
||||||
return with_default ? GetFieldOrDefault(idx) : GetField(idx);
|
return GetField(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrusivePtr<Val> RecordVal::GetFieldOrDefault(const char* field) const
|
||||||
|
{
|
||||||
|
int idx = GetType()->AsRecordType()->FieldOffset(field);
|
||||||
|
|
||||||
|
if ( idx < 0 )
|
||||||
|
reporter->InternalError("missing record field: %s", field);
|
||||||
|
|
||||||
|
return GetFieldOrDefault(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||||
|
|
44
src/Val.h
44
src/Val.h
|
@ -1000,6 +1000,46 @@ public:
|
||||||
Val* LookupWithDefault(int field) const
|
Val* LookupWithDefault(int field) const
|
||||||
{ return GetFieldOrDefault(field).release(); }
|
{ return GetFieldOrDefault(field).release(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field name.
|
||||||
|
* @param field The name of a field to retrieve.
|
||||||
|
* @return The value of the given field. If no such field name exists,
|
||||||
|
* a fatal error occurs.
|
||||||
|
*/
|
||||||
|
const IntrusivePtr<Val>& GetField(const char* field) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field name as cast to type @c T.
|
||||||
|
* @param field The name of a field to retrieve.
|
||||||
|
* @return The value of the given field cast to type @c T. If no such
|
||||||
|
* field name exists, a fatal error occurs.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
IntrusivePtr<T> GetField(const char* field) const
|
||||||
|
{ return cast_intrusive<T>(GetField(field)); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field name if it's previously been
|
||||||
|
* assigned, or else returns the value created from evaluating the record
|
||||||
|
* fields' &default expression.
|
||||||
|
* @param field The name of a field to retrieve.
|
||||||
|
* @return The value of the given field. or the default value
|
||||||
|
* if the field hasn't been assigned yet. If no such field name exists,
|
||||||
|
* a fatal error occurs.
|
||||||
|
*/
|
||||||
|
IntrusivePtr<Val> GetFieldOrDefault(const char* field) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a given field name or its default value
|
||||||
|
* as cast to type @c T.
|
||||||
|
* @param field The name of a field to retrieve.
|
||||||
|
* @return The value of the given field or its default value cast to
|
||||||
|
* type @c T. If no such field name exists, a fatal error occurs.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
IntrusivePtr<T> GetFieldOrDefault(const char* field) const
|
||||||
|
{ return cast_intrusive<T>(GetField(field)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up the value of a field by field name. If the field doesn't
|
* Looks up the value of a field by field name. If the field doesn't
|
||||||
* exist in the record type, it's an internal error: abort.
|
* exist in the record type, it's an internal error: abort.
|
||||||
|
@ -1008,7 +1048,9 @@ public:
|
||||||
* the field has yet to be initialized.
|
* the field has yet to be initialized.
|
||||||
* @return the value in field \a field.
|
* @return the value in field \a field.
|
||||||
*/
|
*/
|
||||||
IntrusivePtr<Val> Lookup(const char* field, bool with_default = false) const;
|
[[deprecated("Remove in v4.1. Use GetField() or GetFieldOrDefault().")]]
|
||||||
|
Val* Lookup(const char* field, bool with_default = false) const
|
||||||
|
{ return with_default ? GetFieldOrDefault(field).release() : GetField(field).get(); }
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
|
|
||||||
|
|
|
@ -170,8 +170,8 @@ void ConnSize_Analyzer::SetDurationThreshold(double duration)
|
||||||
void ConnSize_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void ConnSize_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
// RecordType *connection_type is decleared in NetVar.h
|
// RecordType *connection_type is decleared in NetVar.h
|
||||||
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
RecordVal* orig_endp = conn_val->GetField("orig")->AsRecordVal();
|
||||||
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
RecordVal* resp_endp = conn_val->GetField("resp")->AsRecordVal();
|
||||||
|
|
||||||
// endpoint is the RecordType from NetVar.h
|
// endpoint is the RecordType from NetVar.h
|
||||||
int pktidx = zeek::id::endpoint->FieldOffset("num_pkts");
|
int pktidx = zeek::id::endpoint->FieldOffset("num_pkts");
|
||||||
|
|
|
@ -459,22 +459,22 @@ void ICMP_Analyzer::Describe(ODesc* d) const
|
||||||
|
|
||||||
void ICMP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void ICMP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
auto orig_endp = conn_val->Lookup("orig");
|
const auto& orig_endp = conn_val->GetField("orig");
|
||||||
auto resp_endp = conn_val->Lookup("resp");
|
const auto& resp_endp = conn_val->GetField("resp");
|
||||||
|
|
||||||
UpdateEndpointVal(&orig_endp, true);
|
UpdateEndpointVal(orig_endp, true);
|
||||||
UpdateEndpointVal(&resp_endp, false);
|
UpdateEndpointVal(resp_endp, false);
|
||||||
|
|
||||||
// Call children's UpdateConnVal
|
// Call children's UpdateConnVal
|
||||||
Analyzer::UpdateConnVal(conn_val);
|
Analyzer::UpdateConnVal(conn_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICMP_Analyzer::UpdateEndpointVal(IntrusivePtr<Val>* endp_arg, bool is_orig)
|
void ICMP_Analyzer::UpdateEndpointVal(const IntrusivePtr<Val>& endp_arg, bool is_orig)
|
||||||
{
|
{
|
||||||
Conn()->EnableStatusUpdateTimer();
|
Conn()->EnableStatusUpdateTimer();
|
||||||
|
|
||||||
int size = is_orig ? request_len : reply_len;
|
int size = is_orig ? request_len : reply_len;
|
||||||
auto endp = (*endp_arg)->AsRecordVal();
|
auto endp = endp_arg->AsRecordVal();
|
||||||
|
|
||||||
if ( size < 0 )
|
if ( size < 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
||||||
RuleMatcherState matcher_state;
|
RuleMatcherState matcher_state;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateEndpointVal(IntrusivePtr<Val>* endp, bool is_orig);
|
void UpdateEndpointVal(const IntrusivePtr<Val>& endp, bool is_orig);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the counterpart type to the given type (e.g., the counterpart
|
// Returns the counterpart type to the given type (e.g., the counterpart
|
||||||
|
|
|
@ -1287,8 +1287,8 @@ void TCP_Analyzer::FlipRoles()
|
||||||
|
|
||||||
void TCP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void TCP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
RecordVal *orig_endp_val = conn_val->Lookup("orig")->AsRecordVal();
|
RecordVal* orig_endp_val = conn_val->GetField("orig")->AsRecordVal();
|
||||||
RecordVal *resp_endp_val = conn_val->Lookup("resp")->AsRecordVal();
|
RecordVal* resp_endp_val = conn_val->GetField("resp")->AsRecordVal();
|
||||||
|
|
||||||
orig_endp_val->Assign(0, val_mgr->Count(orig->Size()));
|
orig_endp_val->Assign(0, val_mgr->Count(orig->Size()));
|
||||||
orig_endp_val->Assign(1, val_mgr->Count(int(orig->state)));
|
orig_endp_val->Assign(1, val_mgr->Count(int(orig->state)));
|
||||||
|
|
|
@ -216,8 +216,8 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
|
|
||||||
void UDP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void UDP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
RecordVal* orig_endp = conn_val->GetField("orig")->AsRecordVal();
|
||||||
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
RecordVal* resp_endp = conn_val->GetField("resp")->AsRecordVal();
|
||||||
|
|
||||||
UpdateEndpointVal(orig_endp, true);
|
UpdateEndpointVal(orig_endp, true);
|
||||||
UpdateEndpointVal(resp_endp, false);
|
UpdateEndpointVal(resp_endp, false);
|
||||||
|
|
|
@ -21,8 +21,8 @@ DataEvent::DataEvent(RecordVal* args, File* file,
|
||||||
|
|
||||||
file_analysis::Analyzer* DataEvent::Instantiate(RecordVal* args, File* file)
|
file_analysis::Analyzer* DataEvent::Instantiate(RecordVal* args, File* file)
|
||||||
{
|
{
|
||||||
auto chunk_val = args->Lookup("chunk_event");
|
const auto& chunk_val = args->GetField("chunk_event");
|
||||||
auto stream_val = args->Lookup("stream_event");
|
const auto& stream_val = args->GetField("stream_event");
|
||||||
|
|
||||||
if ( ! chunk_val && ! stream_val ) return nullptr;
|
if ( ! chunk_val && ! stream_val ) return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ Extract::~Extract()
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IntrusivePtr<Val> get_extract_field_val(RecordVal* args, const char* name)
|
static const IntrusivePtr<Val>& get_extract_field_val(RecordVal* args, const char* name)
|
||||||
{
|
{
|
||||||
auto rval = args->Lookup(name);
|
const auto& rval = args->GetField(name);
|
||||||
|
|
||||||
if ( ! rval )
|
if ( ! rval )
|
||||||
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
||||||
|
@ -44,8 +44,8 @@ static IntrusivePtr<Val> get_extract_field_val(RecordVal* args, const char* name
|
||||||
|
|
||||||
file_analysis::Analyzer* Extract::Instantiate(RecordVal* args, File* file)
|
file_analysis::Analyzer* Extract::Instantiate(RecordVal* args, File* file)
|
||||||
{
|
{
|
||||||
auto fname = get_extract_field_val(args, "extract_filename");
|
const auto& fname = get_extract_field_val(args, "extract_filename");
|
||||||
auto limit = get_extract_field_val(args, "extract_limit");
|
const auto& limit = get_extract_field_val(args, "extract_limit");
|
||||||
|
|
||||||
if ( ! fname || ! limit )
|
if ( ! fname || ! limit )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -32,16 +32,6 @@ using namespace file_analysis;
|
||||||
|
|
||||||
#define OCSP_STRING_BUF_SIZE 2048
|
#define OCSP_STRING_BUF_SIZE 2048
|
||||||
|
|
||||||
static IntrusivePtr<Val> get_ocsp_type(RecordVal* args, const char* name)
|
|
||||||
{
|
|
||||||
auto rval = args->Lookup(name);
|
|
||||||
|
|
||||||
if ( ! rval )
|
|
||||||
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
|
||||||
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool OCSP_RESPID_bio(OCSP_BASICRESP* basic_resp, BIO* bio)
|
static bool OCSP_RESPID_bio(OCSP_BASICRESP* basic_resp, BIO* bio)
|
||||||
{
|
{
|
||||||
#if ( OPENSSL_VERSION_NUMBER < 0x10100000L ) || defined(LIBRESSL_VERSION_NUMBER)
|
#if ( OPENSSL_VERSION_NUMBER < 0x10100000L ) || defined(LIBRESSL_VERSION_NUMBER)
|
||||||
|
|
|
@ -233,7 +233,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string name = description->Lookup("name", true)->AsString()->CheckString();
|
string name = description->GetFieldOrDefault("name")->AsString()->CheckString();
|
||||||
|
|
||||||
if ( Stream *i = FindStream(name) )
|
if ( Stream *i = FindStream(name) )
|
||||||
{
|
{
|
||||||
|
@ -242,17 +242,19 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto reader = description->Lookup("reader", true);
|
auto reader = description->GetFieldOrDefault("reader");
|
||||||
|
|
||||||
// get the source ...
|
// get the source ...
|
||||||
const BroString* bsource = description->Lookup("source", true)->AsString();
|
auto source_val = description->GetFieldOrDefault("source");
|
||||||
|
const BroString* bsource = source_val->AsString();
|
||||||
string source((const char*) bsource->Bytes(), bsource->Len());
|
string source((const char*) bsource->Bytes(), bsource->Len());
|
||||||
|
|
||||||
ReaderBackend::ReaderInfo rinfo;
|
ReaderBackend::ReaderInfo rinfo;
|
||||||
rinfo.source = copy_string(source.c_str());
|
rinfo.source = copy_string(source.c_str());
|
||||||
rinfo.name = copy_string(name.c_str());
|
rinfo.name = copy_string(name.c_str());
|
||||||
|
|
||||||
auto mode = description->Lookup("mode", true)->AsEnumVal();
|
auto mode_val = description->GetFieldOrDefault("mode");
|
||||||
|
auto mode = mode_val->AsEnumVal();
|
||||||
switch ( mode->InternalInt() )
|
switch ( mode->InternalInt() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -272,7 +274,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = description->Lookup("config", true);
|
auto config = description->GetFieldOrDefault("config");
|
||||||
info->config = config.release()->AsTableVal();
|
info->config = config.release()->AsTableVal();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -317,14 +319,15 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string stream_name = fval->Lookup("name", true)->AsString()->CheckString();
|
string stream_name = fval->GetFieldOrDefault("name")->AsString()->CheckString();
|
||||||
|
|
||||||
auto fields_val = fval->Lookup("fields", true);
|
auto fields_val = fval->GetFieldOrDefault("fields");
|
||||||
RecordType* fields = fields_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
RecordType* fields = fields_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
|
|
||||||
auto want_record = fval->Lookup("want_record", true);
|
auto want_record = fval->GetFieldOrDefault("want_record");
|
||||||
|
|
||||||
Func* event = fval->Lookup("ev", true)->AsFunc();
|
auto ev_val = fval->GetFieldOrDefault("ev");
|
||||||
|
Func* event = ev_val->AsFunc();
|
||||||
|
|
||||||
const auto& etype = event->GetType();
|
const auto& etype = event->GetType();
|
||||||
|
|
||||||
|
@ -412,7 +415,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
else
|
else
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
||||||
auto error_event_val = fval->Lookup("error_ev", true);
|
auto error_event_val = fval->GetFieldOrDefault("error_ev");
|
||||||
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
|
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
|
||||||
|
|
||||||
if ( ! CheckErrorEventTypes(stream_name, error_event, false) )
|
if ( ! CheckErrorEventTypes(stream_name, error_event, false) )
|
||||||
|
@ -470,19 +473,19 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string stream_name = fval->Lookup("name", true)->AsString()->CheckString();
|
string stream_name = fval->GetFieldOrDefault("name")->AsString()->CheckString();
|
||||||
|
|
||||||
auto pred = fval->Lookup("pred", true);
|
auto pred = fval->GetFieldOrDefault("pred");
|
||||||
auto idx_val = fval->Lookup("idx", true);
|
auto idx_val = fval->GetFieldOrDefault("idx");
|
||||||
RecordType* idx = idx_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
RecordType* idx = idx_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
|
|
||||||
IntrusivePtr<RecordType> val;
|
IntrusivePtr<RecordType> val;
|
||||||
auto val_val = fval->Lookup("val", true);
|
auto val_val = fval->GetFieldOrDefault("val");
|
||||||
|
|
||||||
if ( val_val )
|
if ( val_val )
|
||||||
val = {NewRef{}, val_val->AsType()->AsTypeType()->Type()->AsRecordType()};
|
val = {NewRef{}, val_val->AsType()->AsTypeType()->Type()->AsRecordType()};
|
||||||
|
|
||||||
auto dst = fval->Lookup("destination", true);
|
auto dst = fval->GetFieldOrDefault("destination");
|
||||||
|
|
||||||
// check if index fields match table description
|
// check if index fields match table description
|
||||||
int num = idx->NumFields();
|
int num = idx->NumFields();
|
||||||
|
@ -518,7 +521,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto want_record = fval->Lookup("want_record", true);
|
auto want_record = fval->GetFieldOrDefault("want_record");
|
||||||
|
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
|
@ -551,7 +554,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto event_val = fval->Lookup("ev", true);
|
auto event_val = fval->GetFieldOrDefault("ev");
|
||||||
Func* event = event_val ? event_val->AsFunc() : nullptr;
|
Func* event = event_val ? event_val->AsFunc() : nullptr;
|
||||||
|
|
||||||
if ( event )
|
if ( event )
|
||||||
|
@ -624,7 +627,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
assert(want_record->InternalInt() == 1 || want_record->InternalInt() == 0);
|
assert(want_record->InternalInt() == 1 || want_record->InternalInt() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto error_event_val = fval->Lookup("error_ev", true);
|
auto error_event_val = fval->GetFieldOrDefault("error_ev");
|
||||||
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
|
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
|
||||||
|
|
||||||
if ( ! CheckErrorEventTypes(stream_name, error_event, true) )
|
if ( ! CheckErrorEventTypes(stream_name, error_event, true) )
|
||||||
|
|
|
@ -237,7 +237,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordType* columns = sval->Lookup("columns")
|
RecordType* columns = sval->GetField("columns")
|
||||||
->AsType()->AsTypeType()->Type()->AsRecordType();
|
->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
|
|
||||||
bool log_attr_present = false;
|
bool log_attr_present = false;
|
||||||
|
@ -264,7 +264,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto event_val = sval->Lookup("ev");
|
const auto& event_val = sval->GetField("ev");
|
||||||
Func* event = event_val ? event_val->AsFunc() : nullptr;
|
Func* event = event_val ? event_val->AsFunc() : nullptr;
|
||||||
|
|
||||||
if ( event )
|
if ( event )
|
||||||
|
@ -545,22 +545,22 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Find the right writer type.
|
// Find the right writer type.
|
||||||
EnumVal* writer = fval->Lookup("writer", true)->AsEnumVal();
|
auto writer = fval->GetFieldOrDefault<EnumVal>("writer");
|
||||||
|
|
||||||
// Create a new Filter instance.
|
// Create a new Filter instance.
|
||||||
|
|
||||||
auto name = fval->Lookup("name", true);
|
auto name = fval->GetFieldOrDefault("name");
|
||||||
auto pred = fval->Lookup("pred", true);
|
auto pred = fval->GetFieldOrDefault("pred");
|
||||||
auto path_func = fval->Lookup("path_func", true);
|
auto path_func = fval->GetFieldOrDefault("path_func");
|
||||||
auto log_local = fval->Lookup("log_local", true);
|
auto log_local = fval->GetFieldOrDefault("log_local");
|
||||||
auto log_remote = fval->Lookup("log_remote", true);
|
auto log_remote = fval->GetFieldOrDefault("log_remote");
|
||||||
auto interv = fval->Lookup("interv", true);
|
auto interv = fval->GetFieldOrDefault("interv");
|
||||||
auto postprocessor = fval->Lookup("postprocessor", true);
|
auto postprocessor = fval->GetFieldOrDefault("postprocessor");
|
||||||
auto config = fval->Lookup("config", true);
|
auto config = fval->GetFieldOrDefault("config");
|
||||||
auto field_name_map = fval->Lookup("field_name_map", true);
|
auto field_name_map = fval->GetFieldOrDefault("field_name_map");
|
||||||
auto scope_sep = fval->Lookup("scope_sep", true);
|
auto scope_sep = fval->GetFieldOrDefault("scope_sep");
|
||||||
auto ext_prefix = fval->Lookup("ext_prefix", true);
|
auto ext_prefix = fval->GetFieldOrDefault("ext_prefix");
|
||||||
auto ext_func = fval->Lookup("ext_func", true);
|
auto ext_func = fval->GetFieldOrDefault("ext_func");
|
||||||
|
|
||||||
Filter* filter = new Filter;
|
Filter* filter = new Filter;
|
||||||
filter->fval = fval->Ref();
|
filter->fval = fval->Ref();
|
||||||
|
@ -581,8 +581,8 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
|
|
||||||
// Build the list of fields that the filter wants included, including
|
// Build the list of fields that the filter wants included, including
|
||||||
// potentially rolling out fields.
|
// potentially rolling out fields.
|
||||||
auto include = fval->Lookup("include");
|
const auto& include = fval->GetField("include");
|
||||||
auto exclude = fval->Lookup("exclude");
|
const auto& exclude = fval->GetField("exclude");
|
||||||
|
|
||||||
filter->num_ext_fields = 0;
|
filter->num_ext_fields = 0;
|
||||||
if ( filter->ext_func )
|
if ( filter->ext_func )
|
||||||
|
@ -616,7 +616,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the path for the filter.
|
// Get the path for the filter.
|
||||||
auto path_val = fval->Lookup("path");
|
auto path_val = fval->GetField("path");
|
||||||
|
|
||||||
if ( path_val )
|
if ( path_val )
|
||||||
{
|
{
|
||||||
|
|
|
@ -982,33 +982,33 @@ static BifEnum::Supervisor::ClusterRole role_str_to_enum(std::string_view r)
|
||||||
Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
||||||
{
|
{
|
||||||
Supervisor::NodeConfig rval;
|
Supervisor::NodeConfig rval;
|
||||||
rval.name = node->Lookup("name")->AsString()->CheckString();
|
rval.name = node->GetField("name")->AsString()->CheckString();
|
||||||
auto iface_val = node->Lookup("interface");
|
const auto& iface_val = node->GetField("interface");
|
||||||
|
|
||||||
if ( iface_val )
|
if ( iface_val )
|
||||||
rval.interface = iface_val->AsString()->CheckString();
|
rval.interface = iface_val->AsString()->CheckString();
|
||||||
|
|
||||||
auto directory_val = node->Lookup("directory");
|
const auto& directory_val = node->GetField("directory");
|
||||||
|
|
||||||
if ( directory_val )
|
if ( directory_val )
|
||||||
rval.directory = directory_val->AsString()->CheckString();
|
rval.directory = directory_val->AsString()->CheckString();
|
||||||
|
|
||||||
auto stdout_val = node->Lookup("stdout_file");
|
const auto& stdout_val = node->GetField("stdout_file");
|
||||||
|
|
||||||
if ( stdout_val )
|
if ( stdout_val )
|
||||||
rval.stdout_file = stdout_val->AsString()->CheckString();
|
rval.stdout_file = stdout_val->AsString()->CheckString();
|
||||||
|
|
||||||
auto stderr_val = node->Lookup("stderr_file");
|
const auto& stderr_val = node->GetField("stderr_file");
|
||||||
|
|
||||||
if ( stderr_val )
|
if ( stderr_val )
|
||||||
rval.stderr_file = stderr_val->AsString()->CheckString();
|
rval.stderr_file = stderr_val->AsString()->CheckString();
|
||||||
|
|
||||||
auto affinity_val = node->Lookup("cpu_affinity");
|
const auto& affinity_val = node->GetField("cpu_affinity");
|
||||||
|
|
||||||
if ( affinity_val )
|
if ( affinity_val )
|
||||||
rval.cpu_affinity = affinity_val->AsInt();
|
rval.cpu_affinity = affinity_val->AsInt();
|
||||||
|
|
||||||
auto scripts_val = node->Lookup("scripts")->AsVectorVal();
|
auto scripts_val = node->GetField("scripts")->AsVectorVal();
|
||||||
|
|
||||||
for ( auto i = 0u; i < scripts_val->Size(); ++i )
|
for ( auto i = 0u; i < scripts_val->Size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -1016,7 +1016,7 @@ Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
||||||
rval.scripts.emplace_back(std::move(script));
|
rval.scripts.emplace_back(std::move(script));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cluster_table_val = node->Lookup("cluster")->AsTableVal();
|
auto cluster_table_val = node->GetField("cluster")->AsTableVal();
|
||||||
auto cluster_table = cluster_table_val->AsTable();
|
auto cluster_table = cluster_table_val->AsTable();
|
||||||
auto c = cluster_table->InitForIteration();
|
auto c = cluster_table->InitForIteration();
|
||||||
HashKey* k;
|
HashKey* k;
|
||||||
|
@ -1030,11 +1030,11 @@ Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
||||||
auto rv = v->GetVal()->AsRecordVal();
|
auto rv = v->GetVal()->AsRecordVal();
|
||||||
|
|
||||||
Supervisor::ClusterEndpoint ep;
|
Supervisor::ClusterEndpoint ep;
|
||||||
ep.role = static_cast<BifEnum::Supervisor::ClusterRole>(rv->Lookup("role")->AsEnum());
|
ep.role = static_cast<BifEnum::Supervisor::ClusterRole>(rv->GetField("role")->AsEnum());
|
||||||
ep.host = rv->Lookup("host")->AsAddr().AsString();
|
ep.host = rv->GetField("host")->AsAddr().AsString();
|
||||||
ep.port = rv->Lookup("p")->AsPortVal()->Port();
|
ep.port = rv->GetField("p")->AsPortVal()->Port();
|
||||||
|
|
||||||
auto iface = rv->Lookup("interface");
|
const auto& iface = rv->GetField("interface");
|
||||||
|
|
||||||
if ( iface )
|
if ( iface )
|
||||||
ep.interface = iface->AsStringVal()->ToStdString();
|
ep.interface = iface->AsStringVal()->ToStdString();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue