Merge remote-tracking branch 'origin/topic/jsiwek/remove-header-usings'

* origin/topic/jsiwek/remove-header-usings:
  Remove "using namespace std" from header files
This commit is contained in:
Johanna Amann 2019-10-31 06:37:23 +01:00
commit 6775463f13
20 changed files with 83 additions and 86 deletions

View file

@ -1,4 +1,8 @@
3.1.0-dev.237 | 2019-10-31 06:37:23 +0100
* Remove "using namespace std" from header files (Jon Siwek, Corelight)
3.1.0-dev.235 | 2019-10-30 15:04:13 -0700
* GH-649: define missing DLT_NFLOG to support OpenBSD (Jon Siwek, Corelight)

View file

@ -1 +1 @@
3.1.0-dev.235
3.1.0-dev.237

View file

@ -13,7 +13,6 @@
#include <vector>
#include <set>
#include <map>
using namespace std;
#include "Reporter.h"
#include "net_util.h"

View file

@ -7,7 +7,6 @@
#include <iostream>
#include <stdlib.h>
#include <sys/types.h>
using namespace std;
#include "util.h"
@ -20,23 +19,23 @@ class VectorVal;
class BroString {
public:
typedef vector<BroString*> Vec;
typedef std::vector<BroString*> Vec;
typedef Vec::iterator VecIt;
typedef Vec::const_iterator VecCIt;
typedef vector<const BroString*> CVec;
typedef std::vector<const BroString*> CVec;
typedef Vec::iterator CVecIt;
typedef Vec::const_iterator CVecCIt;
// IdxVecs are vectors of indices of characters in a string.
typedef vector<int> IdxVec;
typedef std::vector<int> IdxVec;
typedef IdxVec::iterator IdxVecIt;
typedef IdxVec::const_iterator IdxVecCIt;
// Constructors creating internal copies of the data passed in.
BroString(const u_char* str, int arg_n, int add_NUL);
explicit BroString(const char* str);
explicit BroString(const string& str);
explicit BroString(const std::string& str);
BroString(const BroString& bs);
// Constructor that takes owernship of the vector passed in.
@ -64,7 +63,7 @@ public:
//
void Set(const u_char* str, int len, int add_NUL=1);
void Set(const char* str);
void Set(const string& str);
void Set(const std::string& str);
void Set(const BroString &str);
void SetUseFreeToDelete(int use_it)
@ -103,13 +102,13 @@ public:
// Also more useful for debugging purposes since no deallocation
// is required on your part here.
//
ostream& Render(ostream& os, int format = ESC_SER) const;
std::ostream& Render(std::ostream& os, int format = ESC_SER) const;
// Reads a string from an input stream. Unless you use a render
// style combination that uses ESC_SER, note that the streams
// will consider whitespace as a field delimiter.
//
istream& Read(istream& is, int format = ESC_SER);
std::istream& Read(std::istream& is, int format = ESC_SER);
// XXX Fix redundancy: strings.bif implements both to_lower
// XXX and to_upper; the latter doesn't use BroString::ToUpper().
@ -165,7 +164,7 @@ public:
};
// Default output stream operator, using rendering mode EXPANDED_STRING.
ostream& operator<<(ostream& os, const BroString& bs);
std::ostream& operator<<(std::ostream& os, const BroString& bs);
extern int Bstr_eq(const BroString* s1, const BroString* s2);
extern int Bstr_cmp(const BroString* s1, const BroString* s2);

View file

@ -4,6 +4,7 @@
#pragma once
#include <assert.h>
#include <string>
class DFA_State;
@ -66,7 +67,7 @@ protected:
static unsigned int transition_counter; // see Xtion()
};
using DigestStr = basic_string<u_char>;
using DigestStr = std::basic_string<u_char>;
class DFA_State_Cache {
public:

View file

@ -5,8 +5,6 @@
#include <vector>
#include <map>
#include <string>
using namespace std;
class Stmt;
@ -35,10 +33,10 @@ class DbgWatch;
class DbgDisplay;
class StmtHashFn;
typedef map<int, DbgBreakpoint*> BPIDMapType;
typedef multimap<const Stmt*, DbgBreakpoint*> BPMapType;
typedef std::map<int, DbgBreakpoint*> BPIDMapType;
typedef std::multimap<const Stmt*, DbgBreakpoint*> BPMapType;
extern string current_module;
extern std::string current_module;
class TraceState {
public:
@ -88,8 +86,8 @@ public:
Location last_loc; // used by 'list'; the last location listed
BPIDMapType breakpoints; // BPID -> Breakpoint
vector<DbgWatch*> watches;
vector<DbgDisplay*> displays;
std::vector<DbgWatch*> watches;
std::vector<DbgDisplay*> displays;
BPMapType breakpoint_map; // maps Stmt -> Breakpoints on it
protected:
@ -135,7 +133,7 @@ extern DebuggerState g_debugger_state;
// Multiple results can be returned depending on the input, but always
// at least 1.
vector<ParseLocationRec> parse_location_string(const string& s);
std::vector<ParseLocationRec> parse_location_string(const std::string& s);
// ### TODO: Add a bunch of hook functions for various events
// e.g. variable changed, breakpoint hit, etc.
@ -171,11 +169,11 @@ Val* dbg_eval_expr(const char* expr);
int dbg_read_internal_state();
// Get line that looks like "In FnFoo(arg = val) at File:Line".
string get_context_description(const Stmt* stmt, const Frame* frame);
std::string get_context_description(const Stmt* stmt, const Frame* frame);
extern Frame* g_dbg_locals; // variables created within debugger context
extern std::map<string, Filemap*> g_dbgfilemaps; // filename => filemap
extern std::map<std::string, Filemap*> g_dbgfilemaps; // filename => filemap
// Perhaps add a code/priority argument to do selective output.
int debug_msg(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));

View file

@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#include "Queue.h"
#include "DebugCmdConstants.h"
@ -23,7 +22,7 @@ public:
int Cmd() const { return cmd; }
int NumNames() const { return num_names; }
const vector<const char *>& Names() const { return names; }
const std::vector<const char *>& Names() const { return names; }
bool ResumeExecution() const { return resume_execution; }
const char* Helpstring() const { return helpstring; }
bool Repeatable() const { return repeatable; }
@ -32,7 +31,7 @@ protected:
DebugCmd cmd;
int num_names;
vector<const char*> names;
std::vector<const char*> names;
// Whether executing this should restart execution of the script.
bool resume_execution;
@ -57,14 +56,14 @@ const DebugCmdInfo* get_debug_cmd_info(DebugCmd cmd);
// on whether or not the prefix supplied matches a name (DebugCmdString)
// of the corresponding DebugCmd. The size of the array should be at
// least NUM_DEBUG_CMDS. The total number of matches is returned.
int find_all_matching_cmds(const string& prefix, const char* array_of_matches[]);
int find_all_matching_cmds(const std::string& prefix, const char* array_of_matches[]);
// Implementation of debugging commands.
//
// These functions return <= 0 if failure, > 0 for success.
// More particular return values are command-specific: see comments w/function.
typedef int DbgCmdFn(DebugCmd cmd, const vector<string>& args);
typedef int DbgCmdFn(DebugCmd cmd, const std::vector<std::string>& args);
DbgCmdFn dbg_cmd_backtrace;
DbgCmdFn dbg_cmd_frame;

View file

@ -5,6 +5,7 @@
#include <stdio.h>
#include <set>
#include <utility>
#include <string>
#include "BroString.h"
@ -56,13 +57,13 @@ public:
void EnableUTF8();
void AddEscapeSequence(const char* s) { escape_sequences.insert(s); }
void AddEscapeSequence(const char* s, size_t n)
{ escape_sequences.insert(string(s, n)); }
void AddEscapeSequence(const string & s)
{ escape_sequences.insert(std::string(s, n)); }
void AddEscapeSequence(const std::string & s)
{ escape_sequences.insert(s); }
void RemoveEscapeSequence(const char* s) { escape_sequences.erase(s); }
void RemoveEscapeSequence(const char* s, size_t n)
{ escape_sequences.erase(string(s, n)); }
void RemoveEscapeSequence(const string & s)
{ escape_sequences.erase(std::string(s, n)); }
void RemoveEscapeSequence(const std::string & s)
{ escape_sequences.erase(s); }
void PushIndent();
@ -76,7 +77,7 @@ public:
void Add(const char* s, int do_indent=1);
void AddN(const char* s, int len) { AddBytes(s, len); }
void Add(const string& s) { AddBytes(s.data(), s.size()); }
void Add(const std::string& s) { AddBytes(s.data(), s.size()); }
void Add(int i);
void Add(uint32_t u);
void Add(int64_t i);
@ -119,7 +120,7 @@ public:
// Bypasses the escaping enabled via SetEscape().
void AddRaw(const char* s, int len) { AddBytesRaw(s, len); }
void AddRaw(const string &s) { AddBytesRaw(s.data(), s.size()); }
void AddRaw(const std::string &s) { AddBytesRaw(s.data(), s.size()); }
// Returns the description as a string.
const char* Description() const { return (const char*) base; }
@ -167,7 +168,7 @@ protected:
* second element. The first element may be 0 if nothing is
* to be escaped.
*/
pair<const char*, size_t> FirstEscapeLoc(const char* bytes, size_t n);
std::pair<const char*, size_t> FirstEscapeLoc(const char* bytes, size_t n);
/**
* @param start start of string to check for starting with an espace
@ -187,7 +188,7 @@ protected:
bool utf8; // whether valid utf-8 sequences may pass through unescaped
bool escape; // escape unprintable characters in output?
typedef set<string> escape_set;
typedef std::set<std::string> escape_set;
escape_set escape_sequences; // additional sequences of chars to escape
BroFile* f; // or the file we're using.

View file

@ -27,7 +27,7 @@ public:
bool IsExport() const { return is_export; }
void SetExport() { is_export = true; }
string ModuleName() const;
std::string ModuleName() const;
void SetType(BroType* t) { Unref(type); type = t; }
BroType* Type() { return type; }
@ -83,7 +83,7 @@ public:
void MakeDeprecated(Expr* deprecation);
string GetDeprecationWarning() const;
std::string GetDeprecationWarning() const;
void Error(const char* msg, const BroObj* o2 = 0);
@ -106,7 +106,7 @@ public:
// Takes ownership of callback.
void AddOptionHandler(Func* callback, int priority);
vector<Func*> GetOptionHandlers() const;
std::vector<Func*> GetOptionHandlers() const;
protected:
ID() { name = 0; type = 0; val = 0; attrs = 0; }

View file

@ -2,8 +2,6 @@
#pragma once
using namespace std;
#include <queue>
#include <set>
@ -35,5 +33,5 @@ struct ltipid {
}
};
typedef set<IP_ID, ltipid> IP_IDSet;
typedef std::set<IP_ID, ltipid> IP_IDSet;
uint16_t NextIP_ID(const uint32_t src_addr, const uint16_t id);

View file

@ -10,6 +10,7 @@
#include <set>
#include <map>
#include <string>
#include <ctype.h>
typedef int (*cce_func)(int);
@ -60,7 +61,7 @@ public:
// functionality.
std::string LookupDef(const std::string& def);
void InsertCCL(const char* txt, CCL* ccl) { ccl_dict[string(txt)] = ccl; }
void InsertCCL(const char* txt, CCL* ccl) { ccl_dict[std::string(txt)] = ccl; }
int InsertCCL(CCL* ccl)
{
ccl_list.push_back(ccl);
@ -68,7 +69,7 @@ public:
}
CCL* LookupCCL(const char* txt)
{
const auto& iter = ccl_dict.find(string(txt));
const auto& iter = ccl_dict.find(std::string(txt));
if ( iter != ccl_dict.end() )
return iter->second;
@ -125,8 +126,8 @@ protected:
int multiline;
char* pattern_text;
std::map<string, string> defs;
std::map<string, CCL*> ccl_dict;
std::map<std::string, std::string> defs;
std::map<std::string, CCL*> ccl_dict;
PList<CCL> ccl_list;
EquivClass equiv_class;
int* ecs;

View file

@ -15,7 +15,7 @@ class RuleHdrTest;
class Rule;
typedef PList<Rule> rule_list;
typedef std::map<string, Rule*> rule_dict;
typedef std::map<std::string, Rule*> rule_dict;
class Rule {
public:

View file

@ -47,7 +47,7 @@ public:
BroType* ReturnType() const { return return_type; }
size_t Length() const { return local.size(); }
std::map<string, ID*>& Vars() { return local; }
std::map<std::string, ID*>& Vars() { return local; }
ID* GenerateTemporary(const char* name);
@ -66,7 +66,7 @@ protected:
ID* scope_id;
attr_list* attrs;
BroType* return_type;
std::map<string, ID*> local;
std::map<std::string, ID*> local;
id_list* inits;
};
@ -90,4 +90,4 @@ extern Scope* current_scope();
extern Scope* global_scope();
// Current module (identified by its name).
extern string current_module;
extern std::string current_module;

View file

@ -4,8 +4,6 @@
#include <string>
using namespace std;
#include "util.h"
class IPAddr;
@ -29,7 +27,7 @@ public:
virtual bool Read(char* v, const char* tag) = 0;
virtual bool Read(bool* v, const char* tag) = 0;
virtual bool Read(double* d, const char* tag) = 0;
virtual bool Read(string* s, const char* tag) = 0;
virtual bool Read(std::string* s, const char* tag) = 0;
virtual bool Read(IPAddr* addr, const char* tag) = 0;
virtual bool Read(IPPrefix* prefix, const char* tag) = 0;
virtual bool Read(struct in_addr* addr, const char* tag) = 0;
@ -63,7 +61,7 @@ public:
virtual bool Write(double d, const char* tag) = 0;
virtual bool Write(const char* s, const char* tag) = 0;
virtual bool Write(const char* buf, int len, const char* tag) = 0;
virtual bool Write(const string& s, const char* tag) = 0;
virtual bool Write(const std::string& s, const char* tag) = 0;
virtual bool Write(const IPAddr& addr, const char* tag) = 0;
virtual bool Write(const IPPrefix& prefix, const char* tag) = 0;
virtual bool Write(const struct in_addr& addr, const char* tag) = 0;
@ -108,7 +106,7 @@ public:
bool Read(bool* v, const char* tag) override;
bool Read(double* d, const char* tag) override;
bool Read(char** str, int* len, const char* tag) override;
bool Read(string* s, const char* tag) override;
bool Read(std::string* s, const char* tag) override;
bool Read(IPAddr* addr, const char* tag) override;
bool Read(IPPrefix* prefix, const char* tag) override;
bool Read(struct in_addr* addr, const char* tag) override;
@ -123,7 +121,7 @@ public:
bool Write(double d, const char* tag) override;
bool Write(const char* s, const char* tag) override;
bool Write(const char* buf, int len, const char* tag) override;
bool Write(const string& s, const char* tag) override;
bool Write(const std::string& s, const char* tag) override;
bool Write(const IPAddr& addr, const char* tag) override;
bool Write(const IPPrefix& prefix, const char* tag) override;
bool Write(const struct in_addr& addr, const char* tag) override;

View file

@ -4,7 +4,6 @@
#include "BroString.h"
#include <map>
using namespace std;
// BroSubstrings are essentially BroStrings, augmented with indexing
// information required for the Smith-Waterman algorithm. Each substring
@ -15,7 +14,7 @@ using namespace std;
class BroSubstring : public BroString {
public:
typedef vector<BroSubstring*> Vec;
typedef std::vector<BroSubstring*> Vec;
typedef Vec::iterator VecIt;
typedef Vec::const_iterator VecCIt;
@ -36,11 +35,11 @@ public:
int index;
};
typedef vector<BSSAlign> BSSAlignVec;
typedef std::vector<BSSAlign> BSSAlignVec;
typedef BSSAlignVec::iterator BSSAlignVecIt;
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
explicit BroSubstring(const string& string)
explicit BroSubstring(const std::string& string)
: BroString(string), _num(), _new(false) { }
explicit BroSubstring(const BroString& string)
@ -76,7 +75,7 @@ public:
unsigned int index);
private:
typedef map<string, void*> DataMap;
typedef std::map<std::string, void*> DataMap;
typedef DataMap::iterator DataMapIt;
BroSubstring();

View file

@ -262,8 +262,8 @@ public:
virtual unsigned MemoryAllocation() const;
void SetName(const string& arg_name) { name = arg_name; }
const string& GetName() const { return name; }
void SetName(const std::string& arg_name) { name = arg_name; }
const std::string& GetName() const { return name; }
typedef std::map<std::string, std::set<BroType*> > TypeAliasMap;
@ -283,7 +283,7 @@ private:
InternalTypeTag internal_tag;
bool is_network_order;
bool base_type;
string name;
std::string name;
static TypeAliasMap type_aliases;
};
@ -402,7 +402,7 @@ public:
const BroType* YieldType() const override;
void SetYieldType(BroType* arg_yield) { yield = arg_yield; }
function_flavor Flavor() const { return flavor; }
string FlavorString() const;
std::string FlavorString() const;
// Used to convert a function type to an event or hook type.
void ClearYieldType(function_flavor arg_flav)
@ -504,7 +504,7 @@ public:
return decl && decl->FindAttr(at) != 0;
}
string GetFieldDeprecationWarning(int field, bool has_check) const;
std::string GetFieldDeprecationWarning(int field, bool has_check) const;
protected:
RecordType() { types = 0; }
@ -537,11 +537,11 @@ protected:
class OpaqueType : public BroType {
public:
explicit OpaqueType(const string& name);
explicit OpaqueType(const std::string& name);
OpaqueType* ShallowClone() override { return new OpaqueType(name); }
~OpaqueType() override { };
const string& Name() const { return name; }
const std::string& Name() const { return name; }
void Describe(ODesc* d) const override;
void DescribeReST(ODesc* d, bool roles_only = false) const override;
@ -549,29 +549,29 @@ public:
protected:
OpaqueType() { }
string name;
std::string name;
};
class EnumType : public BroType {
public:
typedef std::list<std::pair<string, bro_int_t> > enum_name_list;
typedef std::list<std::pair<std::string, bro_int_t> > enum_name_list;
explicit EnumType(const EnumType* e);
explicit EnumType(const string& arg_name);
explicit EnumType(const std::string& arg_name);
EnumType* ShallowClone() override;
~EnumType() override;
// The value of this name is next internal counter value, starting
// with zero. The internal counter is incremented.
void AddName(const string& module_name, const char* name, bool is_export, Expr* deprecation = nullptr);
void AddName(const std::string& module_name, const char* name, bool is_export, Expr* deprecation = nullptr);
// The value of this name is set to val. Once a value has been
// explicitly assigned using this method, no further names can be
// added that aren't likewise explicitly initalized.
void AddName(const string& module_name, const char* name, bro_int_t val, bool is_export, Expr* deprecation = nullptr);
void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export, Expr* deprecation = nullptr);
// -1 indicates not found.
bro_int_t Lookup(const string& module_name, const char* name) const;
bro_int_t Lookup(const std::string& module_name, const char* name) const;
const char* Lookup(bro_int_t value) const; // Returns 0 if not found
// Returns the list of defined names with their values. The names
@ -585,10 +585,10 @@ public:
protected:
EnumType() { counter = 0; }
void AddNameInternal(const string& module_name,
void AddNameInternal(const std::string& module_name,
const char* name, bro_int_t val, bool is_export);
void CheckAndAddName(const string& module_name,
void CheckAndAddName(const std::string& module_name,
const char* name, bro_int_t val, bool is_export,
Expr* deprecation = nullptr);

View file

@ -4,7 +4,6 @@
#include <vector>
#include <string>
using namespace std;
#include "BroList.h"
@ -40,7 +39,7 @@ extern const char* prog;
extern name_list prefixes; // -p flag
extern char* command_line_policy; // -e flag
extern vector<string> params;
extern std::vector<std::string> params;
class Stmt;
extern Stmt* stmts; // global statements

View file

@ -5,6 +5,8 @@
#include <string.h>
#include "module_util.h"
using namespace std;
static int streq(const char* s1, const char* s2)
{
return ! strcmp(s1, s2);

View file

@ -6,14 +6,12 @@
#include <string>
using namespace std;
static const char* GLOBAL_MODULE_NAME = "GLOBAL";
extern string extract_module_name(const char* name);
extern string extract_var_name(const char* name);
extern string normalized_module_name(const char* module_name); // w/o ::
extern std::string extract_module_name(const char* name);
extern std::string extract_var_name(const char* name);
extern std::string normalized_module_name(const char* module_name); // w/o ::
// Concatenates module_name::var_name unless var_name is already fully
// qualified, in which case it is returned unmodified.
extern string make_full_var_name(const char* module_name, const char* var_name);
extern std::string make_full_var_name(const char* module_name, const char* var_name);

View file

@ -3,6 +3,7 @@
#pragma once
#include <vector>
#include <string>
#include <broker/data.hh>
#include <broker/expected.hh>
@ -75,7 +76,7 @@ public:
* Returns a string with a representation of the Bloom filter's
* internal state. This is for debugging/testing purposes only.
*/
virtual string InternalState() const = 0;
virtual std::string InternalState() const = 0;
broker::expected<broker::data> Serialize() const;
static std::unique_ptr<BloomFilter> Unserialize(const broker::data& data);
@ -154,7 +155,7 @@ public:
void Clear() override;
bool Merge(const BloomFilter* other) override;
BasicBloomFilter* Clone() const override;
string InternalState() const override;
std::string InternalState() const override;
protected:
friend class BloomFilter;
@ -203,7 +204,7 @@ public:
void Clear() override;
bool Merge(const BloomFilter* other) override;
CountingBloomFilter* Clone() const override;
string InternalState() const override;
std::string InternalState() const override;
protected:
friend class BloomFilter;