Base: Clean up explicit uses of namespaces in places where they're not necessary.

This commit covers all of the common and base classes.
This commit is contained in:
Tim Wojtulewicz 2020-08-21 09:29:37 -07:00
parent 9f802b2a4d
commit fe0c22c789
240 changed files with 6823 additions and 6787 deletions

View file

@ -8,7 +8,7 @@
namespace zeek::logging {
Component::Component(const std::string& name, factory_callback arg_factory)
: zeek::plugin::Component(zeek::plugin::component::WRITER, name)
: plugin::Component(plugin::component::WRITER, name)
{
factory = arg_factory;
}
@ -23,7 +23,7 @@ Component::~Component()
{
}
void Component::DoDescribe(zeek::ODesc* d) const
void Component::DoDescribe(ODesc* d) const
{
d->Add("Log::WRITER_");
d->Add(CanonicalName());

View file

@ -14,8 +14,8 @@ namespace zeek::logging {
/**
* Component description for plugins providing log writers.
*/
class Component : public zeek::plugin::Component,
public zeek::plugin::TaggedComponent<logging::Tag> {
class Component : public plugin::Component,
public plugin::TaggedComponent<logging::Tag> {
public:
typedef WriterBackend* (*factory_callback)(WriterFrontend* frontend);
@ -54,7 +54,7 @@ protected:
/**
* Overriden from plugin::Component.
*/
void DoDescribe(zeek::ODesc* d) const override;
void DoDescribe(ODesc* d) const override;
private:
factory_callback factory;

File diff suppressed because it is too large Load diff

View file

@ -28,7 +28,7 @@ class RotationTimer;
/**
* Singleton class for managing log streams.
*/
class Manager : public zeek::plugin::ComponentManager<Tag, Component> {
class Manager : public plugin::ComponentManager<Tag, Component> {
public:
/**
@ -54,10 +54,10 @@ public:
* @param rotation_info The fields of a Log::RotationFmtInfo record
* to create and pass to Log::rotation_format_func.
*/
std::string FormatRotationPath(zeek::EnumValPtr writer,
std::string FormatRotationPath(EnumValPtr writer,
std::string_view path, double open,
double close, bool terminating,
zeek::FuncPtr postprocesor);
FuncPtr postprocesor);
/**
* Creates a new log stream.
@ -69,7 +69,7 @@ public:
* This method corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool CreateStream(zeek::EnumVal* id, zeek::RecordVal* stream);
bool CreateStream(EnumVal* id, RecordVal* stream);
/**
* Remove a log stream, stopping all threads.
@ -79,7 +79,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool RemoveStream(zeek::EnumVal* id);
bool RemoveStream(EnumVal* id);
/**
* Enables a log log stream.
@ -89,7 +89,7 @@ public:
* This method corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool EnableStream(zeek::EnumVal* id);
bool EnableStream(EnumVal* id);
/**
* Disables a log stream.
@ -99,7 +99,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool DisableStream(zeek::EnumVal* id);
bool DisableStream(EnumVal* id);
/**
* Adds a filter to a log stream.
@ -111,7 +111,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool AddFilter(zeek::EnumVal* id, zeek::RecordVal* filter);
bool AddFilter(EnumVal* id, RecordVal* filter);
/**
* Removes a filter from a log stream.
@ -123,7 +123,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool RemoveFilter(zeek::EnumVal* id, zeek::StringVal* name);
bool RemoveFilter(EnumVal* id, StringVal* name);
/**
* Removes a filter from a log stream.
@ -135,7 +135,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool RemoveFilter(zeek::EnumVal* id, const std::string& name);
bool RemoveFilter(EnumVal* id, const std::string& name);
/**
* Write a record to a log stream.
@ -148,7 +148,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool Write(zeek::EnumVal* id, zeek::RecordVal* columns);
bool Write(EnumVal* id, RecordVal* columns);
/**
* Create a new log writer frontend. This is exposed so that the
@ -169,7 +169,7 @@ public:
*
* @return Returns true if the writer was successfully created.
*/
bool CreateWriterForRemoteLog(zeek::EnumVal* id, zeek::EnumVal* writer, WriterBackend::WriterInfo* info,
bool CreateWriterForRemoteLog(EnumVal* id, EnumVal* writer, WriterBackend::WriterInfo* info,
int num_fields, const threading::Field* const* fields);
/**
@ -188,7 +188,7 @@ public:
* @param vals An array of log values to write, of size num_fields.
* The method takes ownership of the array.
*/
bool WriteFromRemote(zeek::EnumVal* stream, zeek::EnumVal* writer, const std::string& path,
bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const std::string& path,
int num_fields, threading::Value** vals);
/**
@ -207,7 +207,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool SetBuf(zeek::EnumVal* id, bool enabled);
bool SetBuf(EnumVal* id, bool enabled);
/**
* Flushes a log stream. This flushed all associated writers.
@ -217,7 +217,7 @@ public:
* This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here.
*/
bool Flush(zeek::EnumVal* id);
bool Flush(EnumVal* id);
/**
* Signals the manager to shutdown at Bro's termination.
@ -229,25 +229,25 @@ public:
* @param stream_id the stream to enable remote logs for.
* @return true if remote logs are enabled.
*/
bool EnableRemoteLogs(zeek::EnumVal* stream_id);
bool EnableRemoteLogs(EnumVal* stream_id);
/**
* Disable remote logs for a given stream.
* @param stream_id the stream to disable remote logs for.
* @return true if remote logs are disabled.
*/
bool DisableRemoteLogs(zeek::EnumVal* stream_id);
bool DisableRemoteLogs(EnumVal* stream_id);
/**
* @return true if remote logs are enabled for a given stream.
*/
bool RemoteLogsAreEnabled(zeek::EnumVal* stream_id);
bool RemoteLogsAreEnabled(EnumVal* stream_id);
/**
* @return the type which corresponds to the columns in a log entry for
* a given log stream.
*/
zeek::RecordType* StreamColumns(zeek::EnumVal* stream_id);
RecordType* StreamColumns(EnumVal* stream_id);
protected:
friend class WriterFrontend;
@ -257,12 +257,12 @@ protected:
// Instantiates a new WriterBackend of the given type (note that
// doing so creates a new thread!).
WriterBackend* CreateBackend(WriterFrontend* frontend, zeek::EnumVal* tag);
WriterBackend* CreateBackend(WriterFrontend* frontend, EnumVal* tag);
//// Function also used by the RemoteSerializer.
// Takes ownership of fields and info.
WriterFrontend* CreateWriter(zeek::EnumVal* id, zeek::EnumVal* writer, WriterBackend::WriterInfo* info,
WriterFrontend* CreateWriter(EnumVal* id, EnumVal* writer, WriterBackend::WriterInfo* info,
int num_fields, const threading::Field* const* fields,
bool local, bool remote, bool from_remote,
const std::string& instantiating_filter="");
@ -279,15 +279,15 @@ private:
struct Stream;
struct WriterInfo;
bool TraverseRecord(Stream* stream, Filter* filter, zeek::RecordType* rt,
zeek::TableVal* include, zeek::TableVal* exclude,
bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
TableVal* include, TableVal* exclude,
const std::string& path, const std::list<int>& indices);
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
zeek::RecordVal* columns);
RecordVal* columns);
threading::Value* ValToLogVal(zeek::Val* val, zeek::Type* ty = nullptr);
Stream* FindStream(zeek::EnumVal* id);
threading::Value* ValToLogVal(Val* val, Type* ty = nullptr);
Stream* FindStream(EnumVal* id);
void RemoveDisabledWriters(Stream* stream);
void InstallRotationTimer(WriterInfo* winfo);
void Rotate(WriterInfo* info);
@ -297,7 +297,7 @@ private:
std::vector<Stream *> streams; // Indexed by stream enum.
int rotations_pending; // Number of rotations not yet finished.
zeek::FuncPtr rotation_format_func;
FuncPtr rotation_format_func;
};
} // namespace logging;

View file

@ -24,22 +24,22 @@ Tag& Tag::operator=(const Tag&& other) noexcept
return *this;
}
const zeek::EnumValPtr& Tag::AsVal() const
const EnumValPtr& Tag::AsVal() const
{
return zeek::Tag::AsVal(log_mgr->GetTagType());
}
zeek::EnumVal* Tag::AsEnumVal() const
EnumVal* Tag::AsEnumVal() const
{
return AsVal().get();
}
Tag::Tag(zeek::EnumValPtr val)
Tag::Tag(EnumValPtr val)
: zeek::Tag(std::move(val))
{ }
Tag::Tag(zeek::EnumVal* val)
: zeek::Tag({zeek::NewRef{}, val})
Tag::Tag(EnumVal* val)
: zeek::Tag({NewRef{}, val})
{ }
} // namespace zeek::logging

View file

@ -94,16 +94,16 @@ public:
*
* @param etype the script-layer enum type associated with the tag.
*/
const zeek::EnumValPtr& AsVal() const;
const EnumValPtr& AsVal() const;
[[deprecated("Remove in v4.1. Use AsVal() instead.")]]
zeek::EnumVal* AsEnumVal() const;
EnumVal* AsEnumVal() const;
static const Tag Error;
protected:
friend class zeek::plugin::ComponentManager<Tag, Component>;
friend class zeek::plugin::TaggedComponent<Tag>;
friend class plugin::ComponentManager<Tag, Component>;
friend class plugin::TaggedComponent<Tag>;
/**
* Constructor.
@ -122,10 +122,10 @@ protected:
*
* @param val An enum value of script type \c Log::Writer.
*/
explicit Tag(zeek::EnumValPtr val);
explicit Tag(EnumValPtr val);
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
explicit Tag(zeek::EnumVal* val);
explicit Tag(EnumVal* val);
};
} // namespace zeek::logging

View file

@ -22,7 +22,7 @@ public:
RotationFinishedMessage(WriterFrontend* writer, const char* new_name, const char* old_name,
double open, double close, bool success, bool terminating)
: threading::OutputMessage<WriterFrontend>("RotationFinished", writer),
new_name(zeek::util::copy_string(new_name)), old_name(zeek::util::copy_string(old_name)), open(open),
new_name(util::copy_string(new_name)), old_name(util::copy_string(old_name)), open(open),
close(close), success(success), terminating(terminating) { }
~RotationFinishedMessage() override
@ -97,8 +97,8 @@ bool WriterBackend::WriterInfo::FromBroker(broker::data d)
if ( ! (bpath && brotation_base && brotation_interval && bnetwork_time && bconfig && bppf) )
return false;
path = zeek::util::copy_string(bpath->c_str());
post_proc_func = zeek::util::copy_string(bppf->c_str());
path = util::copy_string(bpath->c_str());
post_proc_func = util::copy_string(bppf->c_str());
rotation_base = *brotation_base;
rotation_interval = *brotation_interval;
network_time = *bnetwork_time;
@ -111,7 +111,7 @@ bool WriterBackend::WriterInfo::FromBroker(broker::data d)
if ( ! (k && v) )
return false;
auto p = std::make_pair(zeek::util::copy_string(k->c_str()), zeek::util::copy_string(v->c_str()));
auto p = std::make_pair(util::copy_string(k->c_str()), util::copy_string(v->c_str()));
config.insert(p);
}
@ -205,7 +205,7 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals)
#ifdef DEBUG
const char* msg = Fmt("Number of fields don't match in WriterBackend::Write() (%d vs. %d)",
arg_num_fields, num_fields);
Debug(zeek::DBG_LOGGING, msg);
Debug(DBG_LOGGING, msg);
#endif
DeleteVals(num_writes, vals);
@ -223,7 +223,7 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals)
#ifdef DEBUG
const char* msg = Fmt("Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)",
i, vals[j][i]->type, fields[i]->type);
Debug(zeek::DBG_LOGGING, msg);
Debug(DBG_LOGGING, msg);
#endif
DisableFrontend();
DeleteVals(num_writes, vals);

View file

@ -50,7 +50,7 @@ public:
struct WriterInfo
{
// Structure takes ownership of these strings.
typedef std::map<const char*, const char*, zeek::util::CompareString> config_map;
typedef std::map<const char*, const char*, util::CompareString> config_map;
/**
* A string left to the interpretation of the writer
@ -98,15 +98,15 @@ public:
WriterInfo(const WriterInfo& other)
{
path = other.path ? zeek::util::copy_string(other.path) : nullptr;
post_proc_func = other.post_proc_func ? zeek::util::copy_string(other.post_proc_func) : nullptr;
path = other.path ? util::copy_string(other.path) : nullptr;
post_proc_func = other.post_proc_func ? util::copy_string(other.post_proc_func) : nullptr;
rotation_interval = other.rotation_interval;
rotation_base = other.rotation_base;
network_time = other.network_time;
for ( config_map::const_iterator i = other.config.begin(); i != other.config.end(); i++ )
config.insert(std::make_pair(zeek::util::copy_string(i->first),
zeek::util::copy_string(i->second)));
config.insert(std::make_pair(util::copy_string(i->first),
util::copy_string(i->second)));
}
~WriterInfo()

View file

@ -14,11 +14,11 @@ namespace zeek::logging {
// Messages sent from frontend to backend (i.e., "InputMessages").
class InitMessage final : public zeek::threading::InputMessage<WriterBackend>
class InitMessage final : public threading::InputMessage<WriterBackend>
{
public:
InitMessage(WriterBackend* backend, const int num_fields, const Field* const* fields)
: zeek::threading::InputMessage<WriterBackend>("Init", backend),
: threading::InputMessage<WriterBackend>("Init", backend),
num_fields(num_fields), fields(fields)
{}
@ -29,14 +29,14 @@ private:
const Field * const* fields;
};
class RotateMessage final : public zeek::threading::InputMessage<WriterBackend>
class RotateMessage final : public threading::InputMessage<WriterBackend>
{
public:
RotateMessage(WriterBackend* backend, WriterFrontend* frontend, const char* rotated_path, const double open,
const double close, const bool terminating)
: zeek::threading::InputMessage<WriterBackend>("Rotate", backend),
: threading::InputMessage<WriterBackend>("Rotate", backend),
frontend(frontend),
rotated_path(zeek::util::copy_string(rotated_path)), open(open),
rotated_path(util::copy_string(rotated_path)), open(open),
close(close), terminating(terminating) { }
virtual ~RotateMessage() { delete [] rotated_path; }
@ -51,11 +51,11 @@ private:
const bool terminating;
};
class WriteMessage final : public zeek::threading::InputMessage<WriterBackend>
class WriteMessage final : public threading::InputMessage<WriterBackend>
{
public:
WriteMessage(WriterBackend* backend, int num_fields, int num_writes, Value*** vals)
: zeek::threading::InputMessage<WriterBackend>("Write", backend),
: threading::InputMessage<WriterBackend>("Write", backend),
num_fields(num_fields), num_writes(num_writes), vals(vals) {}
bool Process() override { return Object()->Write(num_fields, num_writes, vals); }
@ -66,11 +66,11 @@ private:
Value ***vals;
};
class SetBufMessage final : public zeek::threading::InputMessage<WriterBackend>
class SetBufMessage final : public threading::InputMessage<WriterBackend>
{
public:
SetBufMessage(WriterBackend* backend, const bool enabled)
: zeek::threading::InputMessage<WriterBackend>("SetBuf", backend),
: threading::InputMessage<WriterBackend>("SetBuf", backend),
enabled(enabled) { }
bool Process() override { return Object()->SetBuf(enabled); }
@ -79,11 +79,11 @@ private:
const bool enabled;
};
class FlushMessage final : public zeek::threading::InputMessage<WriterBackend>
class FlushMessage final : public threading::InputMessage<WriterBackend>
{
public:
FlushMessage(WriterBackend* backend, double network_time)
: zeek::threading::InputMessage<WriterBackend>("Flush", backend),
: threading::InputMessage<WriterBackend>("Flush", backend),
network_time(network_time) {}
bool Process() override { return Object()->Flush(network_time); }
@ -93,8 +93,8 @@ private:
// Frontend methods.
WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, zeek::EnumVal* arg_stream,
zeek::EnumVal* arg_writer, bool arg_local, bool arg_remote)
WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVal* arg_stream,
EnumVal* arg_writer, bool arg_local, bool arg_remote)
{
stream = arg_stream;
writer = arg_writer;
@ -113,7 +113,7 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, zeek::
fields = nullptr;
const char* w = arg_writer->GetType()->AsEnumType()->Lookup(arg_writer->InternalInt());
name = zeek::util::copy_string(zeek::util::fmt("%s/%s", arg_info.path, w));
name = util::copy_string(util::fmt("%s/%s", arg_info.path, w));
if ( local )
{
@ -158,7 +158,7 @@ void WriterFrontend::Init(int arg_num_fields, const Field* const * arg_fields)
return;
if ( initialized )
zeek::reporter->InternalError("writer initialize twice");
reporter->InternalError("writer initialize twice");
num_fields = arg_num_fields;
fields = arg_fields;
@ -196,8 +196,8 @@ void WriterFrontend::Write(int arg_num_fields, Value** vals)
if ( arg_num_fields != num_fields )
{
zeek::reporter->Warning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.",
name, num_fields, arg_num_fields);
reporter->Warning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.",
name, num_fields, arg_num_fields);
DeleteVals(arg_num_fields, vals);
return;
}
@ -226,7 +226,7 @@ void WriterFrontend::Write(int arg_num_fields, Value** vals)
write_buffer[write_buffer_pos++] = vals;
if ( write_buffer_pos >= WRITER_BUFFER_SIZE || ! buf || zeek::run_state::terminating )
if ( write_buffer_pos >= WRITER_BUFFER_SIZE || ! buf || run_state::terminating )
// Buffer full (or no bufferin desired or termiating).
FlushWriteBuffer();

View file

@ -38,8 +38,8 @@ public:
*
* Frontends must only be instantiated by the main thread.
*/
WriterFrontend(const WriterBackend::WriterInfo& info, zeek::EnumVal* stream,
zeek::EnumVal* writer, bool local, bool remote);
WriterFrontend(const WriterBackend::WriterInfo& info, EnumVal* stream,
EnumVal* writer, bool local, bool remote);
/**
* Destructor.
@ -188,8 +188,8 @@ protected:
void DeleteVals(int num_fields, threading::Value** vals);
zeek::EnumVal* stream;
zeek::EnumVal* writer;
EnumVal* stream;
EnumVal* writer;
WriterBackend* backend; // The backend we have instantiated.
bool disabled; // True if disabled.