diff options
author | Michael Jones <jonesmz@jonesmz.com> | 2018-04-06 01:13:04 (GMT) |
---|---|---|
committer | Michael Jones <jonesmz@jonesmz.com> | 2020-09-30 21:19:11 (GMT) |
commit | a5aae85a3c8a4032ab18b82afe6c77673125d888 (patch) | |
tree | 0a2a857d7c717d15d4d1cf04b3cab414b9e52f21 /src/eval_env.h | |
parent | ff4f2a0db21b738bba743ad543d8553417aca7b0 (diff) | |
download | Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.zip Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.tar.gz Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.tar.bz2 |
Remove 'using namespace std' from header files, properly namespace all std symbols
Diffstat (limited to 'src/eval_env.h')
-rw-r--r-- | src/eval_env.h | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/eval_env.h b/src/eval_env.h index 8fb9bf4..ca7daa4 100644 --- a/src/eval_env.h +++ b/src/eval_env.h @@ -18,7 +18,6 @@ #include <map> #include <string> #include <vector> -using namespace std; #include "string_piece.h" @@ -27,7 +26,7 @@ struct Rule; /// An interface for a scope for variable (e.g. "$foo") lookups. struct Env { virtual ~Env() {} - virtual string LookupVariable(const string& var) = 0; + virtual std::string LookupVariable(const std::string& var) = 0; }; /// A tokenized string that contains variable references. @@ -35,10 +34,10 @@ struct Env { struct EvalString { /// @return The evaluated string with variable expanded using value found in /// environment @a env. - string Evaluate(Env* env) const; + std::string Evaluate(Env* env) const; /// @return The string with variables not expanded. - string Unparse() const; + std::string Unparse() const; void Clear() { parsed_.clear(); } bool empty() const { return parsed_.empty(); } @@ -48,32 +47,32 @@ struct EvalString { /// Construct a human-readable representation of the parsed state, /// for use in tests. - string Serialize() const; + std::string Serialize() const; private: enum TokenType { RAW, SPECIAL }; - typedef vector<pair<string, TokenType> > TokenList; + typedef std::vector<std::pair<std::string, TokenType> > TokenList; TokenList parsed_; }; /// An invokable build command and associated metadata (description, etc.). struct Rule { - explicit Rule(const string& name) : name_(name) {} + explicit Rule(const std::string& name) : name_(name) {} - const string& name() const { return name_; } + const std::string& name() const { return name_; } - void AddBinding(const string& key, const EvalString& val); + void AddBinding(const std::string& key, const EvalString& val); - static bool IsReservedBinding(const string& var); + static bool IsReservedBinding(const std::string& var); - const EvalString* GetBinding(const string& key) const; + const EvalString* GetBinding(const std::string& key) const; private: // Allow the parsers to reach into this object and fill out its fields. friend struct ManifestParser; - string name_; - typedef map<string, EvalString> Bindings; + std::string name_; + typedef std::map<std::string, EvalString> Bindings; Bindings bindings_; }; @@ -84,26 +83,26 @@ struct BindingEnv : public Env { explicit BindingEnv(BindingEnv* parent) : parent_(parent) {} virtual ~BindingEnv() {} - virtual string LookupVariable(const string& var); + virtual std::string LookupVariable(const std::string& var); void AddRule(const Rule* rule); - const Rule* LookupRule(const string& rule_name); - const Rule* LookupRuleCurrentScope(const string& rule_name); - const map<string, const Rule*>& GetRules() const; + const Rule* LookupRule(const std::string& rule_name); + const Rule* LookupRuleCurrentScope(const std::string& rule_name); + const std::map<std::string, const Rule*>& GetRules() const; - void AddBinding(const string& key, const string& val); + void AddBinding(const std::string& key, const std::string& val); /// This is tricky. Edges want lookup scope to go in this order: /// 1) value set on edge itself (edge_->env_) /// 2) value set on rule, with expansion in the edge's scope /// 3) value set on enclosing scope of edge (edge_->env_->parent_) /// This function takes as parameters the necessary info to do (2). - string LookupWithFallback(const string& var, const EvalString* eval, - Env* env); + std::string LookupWithFallback(const std::string& var, const EvalString* eval, + Env* env); private: - map<string, string> bindings_; - map<string, const Rule*> rules_; + std::map<std::string, std::string> bindings_; + std::map<std::string, const Rule*> rules_; BindingEnv* parent_; }; |