mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/776-using-statements'
* origin/topic/timw/776-using-statements: Remove 'using namespace std' from SerialTypes.h Remove other using statements from headers GH-776: Remove using statements added by PR 770 Includes small fixes in files that changed since the merge request was made. Also includes a few small indentation fixes.
This commit is contained in:
commit
876c803d75
147 changed files with 553 additions and 579 deletions
|
@ -1,12 +1,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <thread>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace std;
|
||||
#include <iosfwd>
|
||||
#include <thread>
|
||||
|
||||
namespace threading {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ Formatter::~Formatter()
|
|||
{
|
||||
}
|
||||
|
||||
string Formatter::Render(const threading::Value::addr_t& addr)
|
||||
std::string Formatter::Render(const threading::Value::addr_t& addr)
|
||||
{
|
||||
if ( addr.family == IPv4 )
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ string Formatter::Render(const threading::Value::addr_t& addr)
|
|||
}
|
||||
}
|
||||
|
||||
TransportProto Formatter::ParseProto(const string &proto) const
|
||||
TransportProto Formatter::ParseProto(const std::string &proto) const
|
||||
{
|
||||
if ( proto == "unknown" )
|
||||
return TRANSPORT_UNKNOWN;
|
||||
|
@ -62,7 +62,7 @@ TransportProto Formatter::ParseProto(const string &proto) const
|
|||
|
||||
|
||||
// More or less verbose copy from IPAddr.cc -- which uses reporter.
|
||||
threading::Value::addr_t Formatter::ParseAddr(const string &s) const
|
||||
threading::Value::addr_t Formatter::ParseAddr(const std::string &s) const
|
||||
{
|
||||
threading::Value::addr_t val;
|
||||
|
||||
|
@ -90,7 +90,7 @@ threading::Value::addr_t Formatter::ParseAddr(const string &s) const
|
|||
return val;
|
||||
}
|
||||
|
||||
string Formatter::Render(const threading::Value::subnet_t& subnet)
|
||||
std::string Formatter::Render(const threading::Value::subnet_t& subnet)
|
||||
{
|
||||
char l[16];
|
||||
|
||||
|
@ -99,19 +99,19 @@ string Formatter::Render(const threading::Value::subnet_t& subnet)
|
|||
else
|
||||
modp_uitoa10(subnet.length, l);
|
||||
|
||||
string s = Render(subnet.prefix) + "/" + l;
|
||||
std::string s = Render(subnet.prefix) + "/" + l;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
string Formatter::Render(double d)
|
||||
std::string Formatter::Render(double d)
|
||||
{
|
||||
char buf[256];
|
||||
modp_dtoa(d, buf, 6);
|
||||
return buf;
|
||||
}
|
||||
|
||||
string Formatter::Render(TransportProto proto)
|
||||
std::string Formatter::Render(TransportProto proto)
|
||||
{
|
||||
if ( proto == TRANSPORT_UDP )
|
||||
return "udp";
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
#include "SerialTypes.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
#include "Type.h"
|
||||
#include "SerialTypes.h"
|
||||
|
||||
namespace threading {
|
||||
|
||||
|
@ -17,7 +15,7 @@ namespace formatter {
|
|||
|
||||
/**
|
||||
* A thread-safe class for converting values into some textual format. This
|
||||
* is a base class that implements the interface for common
|
||||
* is a base class that implements the interface for common
|
||||
* rendering/parsing code needed by a number of input/output threads.
|
||||
*/
|
||||
class Formatter {
|
||||
|
@ -69,7 +67,7 @@ public:
|
|||
* @return Returns true on success, false on error. Errors are also
|
||||
* flagged via the thread.
|
||||
*/
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const = 0;
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const = 0;
|
||||
|
||||
/**
|
||||
* Convert an implementation-specific textual representation of a
|
||||
|
@ -83,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 string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const = 0;
|
||||
virtual threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const = 0;
|
||||
|
||||
/**
|
||||
* Convert an IP address into a string.
|
||||
|
@ -94,7 +92,7 @@ public:
|
|||
*
|
||||
* @return An ASCII representation of the address.
|
||||
*/
|
||||
static string Render(const threading::Value::addr_t& addr);
|
||||
static std::string Render(const threading::Value::addr_t& addr);
|
||||
|
||||
/**
|
||||
* Convert an subnet value into a string.
|
||||
|
@ -105,7 +103,7 @@ public:
|
|||
*
|
||||
* @return An ASCII representation of the subnet.
|
||||
*/
|
||||
static string Render(const threading::Value::subnet_t& subnet);
|
||||
static std::string Render(const threading::Value::subnet_t& subnet);
|
||||
|
||||
/**
|
||||
* Convert a double into a string. This renders the double with Bro's
|
||||
|
@ -117,7 +115,7 @@ public:
|
|||
*
|
||||
* @return An ASCII representation of the double.
|
||||
*/
|
||||
static string Render(double d);
|
||||
static std::string Render(double d);
|
||||
|
||||
/**
|
||||
* Convert a transport protocol into a string.
|
||||
|
@ -128,7 +126,7 @@ public:
|
|||
*
|
||||
* @return An ASCII representation of the protocol.
|
||||
*/
|
||||
static string Render(TransportProto proto);
|
||||
static std::string Render(TransportProto proto);
|
||||
|
||||
/**
|
||||
* Convert a string into a TransportProto. The string must be one of
|
||||
|
@ -141,7 +139,7 @@ public:
|
|||
* @return The transport protocol, which will be \c TRANSPORT_UNKNOWN
|
||||
* on error. Errors are also flagged via the thread.
|
||||
*/
|
||||
TransportProto ParseProto(const string &proto) const;
|
||||
TransportProto ParseProto(const std::string &proto) const;
|
||||
|
||||
/**
|
||||
* Convert a string into a Value::addr_t.
|
||||
|
@ -153,7 +151,7 @@ public:
|
|||
* @return The address, which will be all-zero on error. Errors are
|
||||
* also flagged via the thread.
|
||||
*/
|
||||
threading::Value::addr_t ParseAddr(const string &addr) const;
|
||||
threading::Value::addr_t ParseAddr(const std::string &addr) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
*/
|
||||
bool Terminating() const { return terminating; }
|
||||
|
||||
typedef std::list<std::pair<string, MsgThread::Stats> > msg_stats_list;
|
||||
typedef std::list<std::pair<std::string, MsgThread::Stats> > msg_stats_list;
|
||||
|
||||
/**
|
||||
* Returns statistics from all current MsgThread instances.
|
||||
|
|
|
@ -382,7 +382,7 @@ BasicInputMessage* MsgThread::RetrieveIn()
|
|||
return nullptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name());
|
||||
std::string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name());
|
||||
Debug(DBG_THREADING, s.c_str());
|
||||
#endif
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ bool Field::Read(SerializationFormat* fmt)
|
|||
{
|
||||
int t;
|
||||
int st;
|
||||
string tmp_name;
|
||||
std::string tmp_name;
|
||||
bool have_2nd;
|
||||
|
||||
if ( ! fmt->Read(&have_2nd, "have_2nd") )
|
||||
|
@ -19,7 +19,7 @@ bool Field::Read(SerializationFormat* fmt)
|
|||
|
||||
if ( have_2nd )
|
||||
{
|
||||
string tmp_secondary_name;
|
||||
std::string tmp_secondary_name;
|
||||
if ( ! fmt->Read(&tmp_secondary_name, "secondary_name") )
|
||||
return false;
|
||||
|
||||
|
@ -64,9 +64,9 @@ bool Field::Write(SerializationFormat* fmt) const
|
|||
fmt->Write(optional, "optional"));
|
||||
}
|
||||
|
||||
string Field::TypeName() const
|
||||
std::string Field::TypeName() const
|
||||
{
|
||||
string n;
|
||||
std::string n;
|
||||
|
||||
// We do not support tables, if the internal Bro type is table it
|
||||
// always is a set.
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include "Type.h"
|
||||
#include "net_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SerializationFormat;
|
||||
|
||||
namespace threading {
|
||||
|
@ -73,7 +71,7 @@ struct Field {
|
|||
* Returns a textual description of the field's type. This method is
|
||||
* thread-safe.
|
||||
*/
|
||||
string TypeName() const;
|
||||
std::string TypeName() const;
|
||||
|
||||
private:
|
||||
// Force usage of constructor above.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <sstream>
|
||||
#include <errno.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace threading::formatter;
|
||||
|
||||
// If the value we'd write out would match exactly the a reserved string, we
|
||||
|
|
|
@ -14,16 +14,17 @@ public:
|
|||
*/
|
||||
struct SeparatorInfo
|
||||
{
|
||||
string separator; // Separator between columns
|
||||
string set_separator; // Separator between set elements.
|
||||
string unset_field; // String marking an unset field.
|
||||
string empty_field; // String marking an empty (but set) field.
|
||||
std::string separator; // Separator between columns
|
||||
std::string set_separator; // Separator between set elements.
|
||||
std::string unset_field; // String marking an unset field.
|
||||
std::string empty_field; // String marking an empty (but set) field.
|
||||
|
||||
/**
|
||||
* Constructor that defines all the configuration options.
|
||||
* Use if you need either ValToODesc or EntryToVal.
|
||||
*/
|
||||
SeparatorInfo(const string& separator, const string& set_separator, const string& unset_field, const string& empty_field);
|
||||
SeparatorInfo(const std::string& separator, const std::string& set_separator,
|
||||
const std::string& unset_field, const std::string& empty_field);
|
||||
|
||||
/**
|
||||
* Constructor that leaves separators etc unset to dummy
|
||||
|
@ -46,10 +47,11 @@ public:
|
|||
Ascii(threading::MsgThread* t, const SeparatorInfo& info);
|
||||
virtual ~Ascii();
|
||||
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const;
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const;
|
||||
virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields,
|
||||
threading::Value** vals) const;
|
||||
virtual threading::Value* ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const;
|
||||
virtual threading::Value* ParseValue(const std::string& s, const std::string& name,
|
||||
TypeTag type, TypeTag subtype = TYPE_ERROR) const;
|
||||
|
||||
private:
|
||||
bool CheckNumberError(const char* start, const char* end) const;
|
||||
|
|
|
@ -55,7 +55,7 @@ bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool JSON::Describe(ODesc* desc, Value* val, const string& name) const
|
||||
bool JSON::Describe(ODesc* desc, Value* val, const std::string& name) const
|
||||
{
|
||||
if ( desc->IsBinary() )
|
||||
{
|
||||
|
@ -78,13 +78,13 @@ bool JSON::Describe(ODesc* desc, Value* val, const string& name) const
|
|||
return true;
|
||||
}
|
||||
|
||||
threading::Value* JSON::ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype) const
|
||||
threading::Value* JSON::ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype) const
|
||||
{
|
||||
GetThread()->Error("JSON formatter does not support parsing yet.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const string& name) const
|
||||
void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& name) const
|
||||
{
|
||||
if ( ! val->present )
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const string& name) c
|
|||
case TYPE_FILE:
|
||||
case TYPE_FUNC:
|
||||
{
|
||||
writer.String(json_escape_utf8(string(val->val.string_val.data, val->val.string_val.length)));
|
||||
writer.String(json_escape_utf8(std::string(val->val.string_val.data, val->val.string_val.length)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ public:
|
|||
JSON(threading::MsgThread* t, TimeFormat tf);
|
||||
~JSON() override;
|
||||
|
||||
bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const override;
|
||||
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 string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const override;
|
||||
threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const override;
|
||||
|
||||
class NullDoubleWriter : public rapidjson::Writer<rapidjson::StringBuffer> {
|
||||
public:
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
void BuildJSON(NullDoubleWriter& writer, Value* val, const string& name = "") const;
|
||||
void BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& name = "") const;
|
||||
|
||||
TimeFormat timestamps;
|
||||
bool surrounding_braces;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue