From a5aae85a3c8a4032ab18b82afe6c77673125d888 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Thu, 5 Apr 2018 20:13:04 -0500 Subject: Remove 'using namespace std' from header files, properly namespace all std symbols --- src/build.h | 62 ++++++++++++++++++++++----------------------- src/build_log.h | 15 +++++------ src/clean.h | 16 +++++------- src/clparser.h | 15 +++++------ src/depfile_parser.h | 5 ++-- src/deps_log.h | 17 ++++++------- src/disk_interface.h | 29 ++++++++++----------- src/dyndep_parser.h | 11 ++++---- src/eval_env.h | 43 +++++++++++++++---------------- src/graph.h | 55 ++++++++++++++++++++-------------------- src/includes_normalize.h | 16 ++++++------ src/lexer.cc | 66 +++++++++++++++++++++--------------------------- src/lexer.h | 12 ++++----- src/line_printer.h | 9 +++---- src/manifest_parser.h | 16 ++++++------ src/metrics.h | 7 +++-- src/msvc_helper.h | 5 ++-- src/parser.h | 10 +++----- src/state.h | 27 ++++++++++---------- src/string_piece.h | 9 +++---- src/string_piece_util.cc | 1 + src/string_piece_util.h | 5 ++-- src/subprocess.h | 13 +++++----- src/test.h | 34 ++++++++++++------------- src/util.h | 23 ++++++++--------- src/version.h | 5 ++-- 26 files changed, 250 insertions(+), 276 deletions(-) diff --git a/src/build.h b/src/build.h index 97773c4..41120e1 100644 --- a/src/build.h +++ b/src/build.h @@ -46,7 +46,7 @@ struct Plan { /// Add a target to our plan (including all its dependencies). /// Returns false if we don't need to build this target; may /// fill in |err| with an error message if there's a problem. - bool AddTarget(const Node* node, string* err); + bool AddTarget(const Node* node, std::string* err); // Pop a ready edge off the queue of edges to build. // Returns NULL if there's no work to do. @@ -67,11 +67,11 @@ struct Plan { /// If any of the edge's outputs are dyndep bindings of their dependents, /// this loads dynamic dependencies from the nodes' paths. /// Returns 'false' if loading dyndep info fails and 'true' otherwise. - bool EdgeFinished(Edge* edge, EdgeResult result, string* err); + bool EdgeFinished(Edge* edge, EdgeResult result, std::string* err); /// Clean the given node during the build. /// Return false on error. - bool CleanNode(DependencyScan* scan, Node* node, string* err); + bool CleanNode(DependencyScan* scan, Node* node, std::string* err); /// Number of edges with commands to run. int command_edge_count() const { return command_edges_; } @@ -82,18 +82,18 @@ struct Plan { /// Update the build plan to account for modifications made to the graph /// by information loaded from a dyndep file. bool DyndepsLoaded(DependencyScan* scan, const Node* node, - const DyndepFile& ddf, string* err); + const DyndepFile& ddf, std::string* err); private: - bool RefreshDyndepDependents(DependencyScan* scan, const Node* node, string* err); - void UnmarkDependents(const Node* node, set* dependents); - bool AddSubTarget(const Node* node, const Node* dependent, string* err, - set* dyndep_walk); + bool RefreshDyndepDependents(DependencyScan* scan, const Node* node, std::string* err); + void UnmarkDependents(const Node* node, std::set* dependents); + bool AddSubTarget(const Node* node, const Node* dependent, std::string* err, + std::set* dyndep_walk); /// Update plan with knowledge that the given node is up to date. /// If the node is a dyndep binding on any of its dependents, this /// loads dynamic dependencies from the node's path. /// Returns 'false' if loading dyndep info fails and 'true' otherwise. - bool NodeFinished(Node* node, string* err); + bool NodeFinished(Node* node, std::string* err); /// Enumerate possible steps we want for an edge. enum Want @@ -109,20 +109,20 @@ private: }; void EdgeWanted(const Edge* edge); - bool EdgeMaybeReady(map::iterator want_e, string* err); + bool EdgeMaybeReady(std::map::iterator want_e, std::string* err); /// Submits a ready edge as a candidate for execution. /// The edge may be delayed from running, for example if it's a member of a /// currently-full pool. - void ScheduleWork(map::iterator want_e); + void ScheduleWork(std::map::iterator want_e); /// Keep track of which edges we want to build in this plan. If this map does /// not contain an entry for an edge, we do not want to build the entry or its /// dependents. If it does contain an entry, the enumeration indicates what /// we want for the edge. - map want_; + std::map want_; - set ready_; + std::set ready_; Builder* builder_; @@ -146,13 +146,13 @@ struct CommandRunner { Result() : edge(NULL) {} Edge* edge; ExitStatus status; - string output; + std::string output; bool success() const { return status == ExitSuccess; } }; /// Wait for a command to complete, or return false if interrupted. virtual bool WaitForCommand(Result* result) = 0; - virtual vector GetActiveEdges() { return vector(); } + virtual std::vector GetActiveEdges() { return std::vector(); } virtual void Abort() {} }; @@ -186,24 +186,24 @@ struct Builder { /// Clean up after interrupted commands by deleting output files. void Cleanup(); - Node* AddTarget(const string& name, string* err); + Node* AddTarget(const std::string& name, std::string* err); /// Add a target to the build, scanning dependencies. /// @return false on error. - bool AddTarget(Node* target, string* err); + bool AddTarget(Node* target, std::string* err); /// Returns true if the build targets are already up to date. bool AlreadyUpToDate() const; /// Run the build. Returns false on error. /// It is an error to call this function when AlreadyUpToDate() is true. - bool Build(string* err); + bool Build(std::string* err); - bool StartEdge(Edge* edge, string* err); + bool StartEdge(Edge* edge, std::string* err); /// Update status ninja logs following a command termination. /// @return false if the build can not proceed further due to a fatal error. - bool FinishCommand(CommandRunner::Result* result, string* err); + bool FinishCommand(CommandRunner::Result* result, std::string* err); /// Used for tests. void SetBuildLog(BuildLog* log) { @@ -211,22 +211,22 @@ struct Builder { } /// Load the dyndep information provided by the given node. - bool LoadDyndeps(Node* node, string* err); + bool LoadDyndeps(Node* node, std::string* err); State* state_; const BuildConfig& config_; Plan plan_; #if __cplusplus < 201703L - auto_ptr command_runner_; + std::auto_ptr command_runner_; #else - unique_ptr command_runner_; // auto_ptr was removed in C++17. + std::unique_ptr command_runner_; // auto_ptr was removed in C++17. #endif BuildStatus* status_; private: - bool ExtractDeps(CommandRunner::Result* result, const string& deps_type, - const string& deps_prefix, vector* deps_nodes, - string* err); + bool ExtractDeps(CommandRunner::Result* result, const std::string& deps_type, + const std::string& deps_prefix, std::vector* deps_nodes, + std::string* err); DiskInterface* disk_interface_; DependencyScan scan_; @@ -241,7 +241,7 @@ struct BuildStatus { explicit BuildStatus(const BuildConfig& config); void PlanHasTotalEdges(int total); void BuildEdgeStarted(const Edge* edge); - void BuildEdgeFinished(Edge* edge, bool success, const string& output, + void BuildEdgeFinished(Edge* edge, bool success, const std::string& output, int* start_time, int* end_time); void BuildLoadDyndeps(); void BuildStarted(); @@ -257,8 +257,8 @@ struct BuildStatus { /// placeholders. /// @param progress_status_format The format of the progress status. /// @param status The status of the edge. - string FormatProgressStatus(const char* progress_status_format, - EdgeStatus status) const; + std::string FormatProgressStatus(const char* progress_status_format, + EdgeStatus status) const; private: void PrintStatus(const Edge* edge, EdgeStatus status); @@ -271,7 +271,7 @@ struct BuildStatus { int started_edges_, finished_edges_, total_edges_; /// Map of running edge to time the edge started running. - typedef map RunningEdgeMap; + typedef std::map RunningEdgeMap; RunningEdgeMap running_edges_; /// Prints progress output. @@ -327,7 +327,7 @@ struct BuildStatus { double rate_; Stopwatch stopwatch_; const size_t N; - queue times_; + std::queue times_; int last_update_; }; diff --git a/src/build_log.h b/src/build_log.h index 6d060d1..842c467 100644 --- a/src/build_log.h +++ b/src/build_log.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include "hash_map.h" #include "load_status.h" @@ -47,17 +46,17 @@ struct BuildLog { /// Prepares writing to the log file without actually opening it - that will /// happen when/if it's needed - bool OpenForWrite(const string& path, const BuildLogUser& user, string* err); + bool OpenForWrite(const std::string& path, const BuildLogUser& user, std::string* err); bool RecordCommand(Edge* edge, int start_time, int end_time, TimeStamp mtime = 0); void Close(); /// Load the on-disk log. - LoadStatus Load(const string& path, string* err); + LoadStatus Load(const std::string& path, std::string* err); struct LogEntry { - string output; + std::string output; uint64_t command_hash; int start_time; int end_time; @@ -72,19 +71,19 @@ struct BuildLog { mtime == o.mtime; } - explicit LogEntry(const string& output); - LogEntry(const string& output, uint64_t command_hash, + explicit LogEntry(const std::string& output); + LogEntry(const std::string& output, uint64_t command_hash, int start_time, int end_time, TimeStamp restat_mtime); }; /// Lookup a previously-run command by its output path. - LogEntry* LookupByOutput(const string& path); + LogEntry* LookupByOutput(const std::string& path); /// Serialize an entry into a log file. bool WriteEntry(FILE* f, const LogEntry& entry); /// Rewrite the known log entries, throwing away old data. - bool Recompact(const string& path, const BuildLogUser& user, string* err); + bool Recompact(const std::string& path, const BuildLogUser& user, std::string* err); /// Restat all outputs in the log bool Restat(StringPiece path, const DiskInterface& disk_interface, diff --git a/src/clean.h b/src/clean.h index 4c02ff6..cf3f1c3 100644 --- a/src/clean.h +++ b/src/clean.h @@ -22,8 +22,6 @@ #include "dyndep.h" #include "build_log.h" -using namespace std; - struct State; struct Node; struct Rule; @@ -78,15 +76,15 @@ struct Cleaner { private: /// Remove the file @a path. /// @return whether the file has been removed. - int RemoveFile(const string& path); + int RemoveFile(const std::string& path); /// @returns whether the file @a path exists. - bool FileExists(const string& path); - void Report(const string& path); + bool FileExists(const std::string& path); + void Report(const std::string& path); /// Remove the given @a path file only if it has not been already removed. - void Remove(const string& path); + void Remove(const std::string& path); /// @return whether the given @a path has already been removed. - bool IsAlreadyRemoved(const string& path); + bool IsAlreadyRemoved(const std::string& path); /// Remove the depfile and rspfile for an Edge. void RemoveEdgeFiles(Edge* edge); @@ -103,8 +101,8 @@ struct Cleaner { State* state_; const BuildConfig& config_; DyndepLoader dyndep_loader_; - set removed_; - set cleaned_; + std::set removed_; + std::set cleaned_; int cleaned_files_count_; DiskInterface* disk_interface_; int status_; diff --git a/src/clparser.h b/src/clparser.h index e597e7e..2a33628 100644 --- a/src/clparser.h +++ b/src/clparser.h @@ -17,7 +17,6 @@ #include #include -using namespace std; /// Visual Studio's cl.exe requires some massaging to work with Ninja; /// for example, it emits include information on stderr in a funny @@ -27,26 +26,26 @@ struct CLParser { /// Parse a line of cl.exe output and extract /showIncludes info. /// If a dependency is extracted, returns a nonempty string. /// Exposed for testing. - static string FilterShowIncludes(const string& line, - const string& deps_prefix); + static std::string FilterShowIncludes(const std::string& line, + const std::string& deps_prefix); /// Return true if a mentioned include file is a system path. /// Filtering these out reduces dependency information considerably. - static bool IsSystemInclude(string path); + static bool IsSystemInclude(std::string path); /// Parse a line of cl.exe output and return true if it looks like /// it's printing an input filename. This is a heuristic but it appears /// to be the best we can do. /// Exposed for testing. - static bool FilterInputFilename(string line); + static bool FilterInputFilename(std::string line); /// Parse the full output of cl, filling filtered_output with the text that /// should be printed (if any). Returns true on success, or false with err /// filled. output must not be the same object as filtered_object. - bool Parse(const string& output, const string& deps_prefix, - string* filtered_output, string* err); + bool Parse(const std::string& output, const std::string& deps_prefix, + std::string* filtered_output, std::string* err); - set includes_; + std::set includes_; }; #endif // NINJA_CLPARSER_H_ diff --git a/src/depfile_parser.h b/src/depfile_parser.h index 11b1228..0e8db81 100644 --- a/src/depfile_parser.h +++ b/src/depfile_parser.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include "string_piece.h" @@ -33,10 +32,10 @@ struct DepfileParser { /// Parse an input file. Input must be NUL-terminated. /// Warning: may mutate the content in-place and parsed StringPieces are /// pointers within it. - bool Parse(string* content, string* err); + bool Parse(std::string* content, std::string* err); std::vector outs_; - vector ins_; + std::vector ins_; DepfileParserOptions options_; }; diff --git a/src/deps_log.h b/src/deps_log.h index c4ada8b..cc44b41 100644 --- a/src/deps_log.h +++ b/src/deps_log.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include @@ -71,8 +70,8 @@ struct DepsLog { ~DepsLog(); // Writing (build-time) interface. - bool OpenForWrite(const string& path, string* err); - bool RecordDeps(Node* node, TimeStamp mtime, const vector& nodes); + bool OpenForWrite(const std::string& path, std::string* err); + bool RecordDeps(Node* node, TimeStamp mtime, const std::vector& nodes); bool RecordDeps(Node* node, TimeStamp mtime, int node_count, Node** nodes); void Close(); @@ -85,11 +84,11 @@ struct DepsLog { int node_count; Node** nodes; }; - LoadStatus Load(const string& path, State* state, string* err); + LoadStatus Load(const std::string& path, State* state, std::string* err); Deps* GetDeps(Node* node); /// Rewrite the known log entries, throwing away old data. - bool Recompact(const string& path, string* err); + bool Recompact(const std::string& path, std::string* err); /// Returns if the deps entry for a node is still reachable from the manifest. /// @@ -100,8 +99,8 @@ struct DepsLog { bool IsDepsEntryLiveFor(Node* node); /// Used for tests. - const vector& nodes() const { return nodes_; } - const vector& deps() const { return deps_; } + const std::vector& nodes() const { return nodes_; } + const std::vector& deps() const { return deps_; } private: // Updates the in-memory representation. Takes ownership of |deps|. @@ -119,9 +118,9 @@ struct DepsLog { std::string file_path_; /// Maps id -> Node. - vector nodes_; + std::vector nodes_; /// Maps id -> deps of that id. - vector deps_; + std::vector deps_; friend struct DepsLogTest; }; diff --git a/src/disk_interface.h b/src/disk_interface.h index 145e089..b75f1f6 100644 --- a/src/disk_interface.h +++ b/src/disk_interface.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include "timestamp.h" @@ -35,8 +34,8 @@ struct FileReader { /// Read and store in given string. On success, return Okay. /// On error, return another Status and fill |err|. - virtual Status ReadFile(const string& path, string* contents, - string* err) = 0; + virtual Status ReadFile(const std::string& path, std::string* contents, + std::string* err) = 0; }; /// Interface for accessing the disk. @@ -46,25 +45,25 @@ struct FileReader { struct DiskInterface: public FileReader { /// stat() a file, returning the mtime, or 0 if missing and -1 on /// other errors. - virtual TimeStamp Stat(const string& path, string* err) const = 0; + virtual TimeStamp Stat(const std::string& path, std::string* err) const = 0; /// Create a directory, returning false on failure. - virtual bool MakeDir(const string& path) = 0; + virtual bool MakeDir(const std::string& path) = 0; /// Create a file, with the specified name and contents /// Returns true on success, false on failure - virtual bool WriteFile(const string& path, const string& contents) = 0; + virtual bool WriteFile(const std::string& path, const std::string& contents) = 0; /// Remove the file named @a path. It behaves like 'rm -f path' so no errors /// are reported if it does not exists. /// @returns 0 if the file has been removed, /// 1 if the file does not exist, and /// -1 if an error occurs. - virtual int RemoveFile(const string& path) = 0; + virtual int RemoveFile(const std::string& path) = 0; /// Create all the parent directories for path; like mkdir -p /// `basename path`. - bool MakeDirs(const string& path); + bool MakeDirs(const std::string& path); }; /// Implementation of DiskInterface that actually hits the disk. @@ -75,11 +74,11 @@ struct RealDiskInterface : public DiskInterface { #endif {} virtual ~RealDiskInterface() {} - virtual TimeStamp Stat(const string& path, string* err) const; - virtual bool MakeDir(const string& path); - virtual bool WriteFile(const string& path, const string& contents); - virtual Status ReadFile(const string& path, string* contents, string* err); - virtual int RemoveFile(const string& path); + virtual TimeStamp Stat(const std::string& path, std::string* err) const; + virtual bool MakeDir(const std::string& path); + virtual bool WriteFile(const std::string& path, const std::string& contents); + virtual Status ReadFile(const std::string& path, std::string* contents, std::string* err); + virtual int RemoveFile(const std::string& path); /// Whether stat information can be cached. Only has an effect on Windows. void AllowStatCache(bool allow); @@ -89,10 +88,10 @@ struct RealDiskInterface : public DiskInterface { /// Whether stat information can be cached. bool use_cache_; - typedef map DirCache; + typedef std::map DirCache; // TODO: Neither a map nor a hashmap seems ideal here. If the statcache // works out, come up with a better data structure. - typedef map Cache; + typedef std::map Cache; mutable Cache cache_; #endif }; diff --git a/src/dyndep_parser.h b/src/dyndep_parser.h index 09a3722..8f4c28d 100644 --- a/src/dyndep_parser.h +++ b/src/dyndep_parser.h @@ -27,17 +27,18 @@ struct DyndepParser: public Parser { DyndepFile* dyndep_file); /// Parse a text string of input. Used by tests. - bool ParseTest(const string& input, string* err) { + bool ParseTest(const std::string& input, std::string* err) { return Parse("input", input, err); } private: /// Parse a file, given its contents as a string. - bool Parse(const string& filename, const string& input, string* err); + bool Parse(const std::string& filename, const std::string& input, + std:: string* err); - bool ParseDyndepVersion(string* err); - bool ParseLet(string* key, EvalString* val, string* err); - bool ParseEdge(string* err); + bool ParseDyndepVersion(std::string* err); + bool ParseLet(std::string* key, EvalString* val, std::string* err); + bool ParseEdge(std::string* err); DyndepFile* dyndep_file_; BindingEnv env_; 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 #include #include -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 > TokenList; + typedef std::vector > 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 Bindings; + std::string name_; + typedef std::map 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& GetRules() const; + const Rule* LookupRule(const std::string& rule_name); + const Rule* LookupRuleCurrentScope(const std::string& rule_name); + const std::map& 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 bindings_; - map rules_; + std::map bindings_; + std::map rules_; BindingEnv* parent_; }; diff --git a/src/graph.h b/src/graph.h index 2fa54af..4833f49 100644 --- a/src/graph.h +++ b/src/graph.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include "dyndep.h" #include "eval_env.h" @@ -36,7 +35,7 @@ struct State; /// Information about a node in the dependency graph: the file, whether /// it's dirty, mtime, etc. struct Node { - Node(const string& path, uint64_t slash_bits) + Node(const std::string& path, uint64_t slash_bits) : path_(path), slash_bits_(slash_bits), mtime_(-1), @@ -46,10 +45,10 @@ struct Node { id_(-1) {} /// Return false on error. - bool Stat(DiskInterface* disk_interface, string* err); + bool Stat(DiskInterface* disk_interface, std::string* err); /// Return false on error. - bool StatIfNecessary(DiskInterface* disk_interface, string* err) { + bool StatIfNecessary(DiskInterface* disk_interface, std::string* err) { if (status_known()) return true; return Stat(disk_interface, err); @@ -74,13 +73,13 @@ struct Node { return mtime_ != -1; } - const string& path() const { return path_; } + const std::string& path() const { return path_; } /// Get |path()| but use slash_bits to convert back to original slash styles. - string PathDecanonicalized() const { + std::string PathDecanonicalized() const { return PathDecanonicalized(path_, slash_bits_); } - static string PathDecanonicalized(const string& path, - uint64_t slash_bits); + static std::string PathDecanonicalized(const std::string& path, + uint64_t slash_bits); uint64_t slash_bits() const { return slash_bits_; } TimeStamp mtime() const { return mtime_; } @@ -98,13 +97,13 @@ struct Node { int id() const { return id_; } void set_id(int id) { id_ = id; } - const vector& out_edges() const { return out_edges_; } + const std::vector& out_edges() const { return out_edges_; } void AddOutEdge(Edge* edge) { out_edges_.push_back(edge); } void Dump(const char* prefix="") const; private: - string path_; + std::string path_; /// Set bits starting from lowest for backslashes that were normalized to /// forward slashes by CanonicalizePath. See |PathDecanonicalized|. @@ -130,7 +129,7 @@ private: Edge* in_edge_; /// All Edges that use this Node as an input. - vector out_edges_; + std::vector out_edges_; /// A dense integer id for the node, assigned and used by DepsLog. int id_; @@ -158,13 +157,13 @@ struct Edge { std::string EvaluateCommand(bool incl_rsp_file = false) const; /// Returns the shell-escaped value of |key|. - std::string GetBinding(const string& key) const; - bool GetBindingBool(const string& key) const; + std::string GetBinding(const std::string& key) const; + bool GetBindingBool(const std::string& key) const; /// Like GetBinding("depfile"), but without shell escaping. - string GetUnescapedDepfile() const; + std::string GetUnescapedDepfile() const; /// Like GetBinding("dyndep"), but without shell escaping. - string GetUnescapedDyndep() const; + std::string GetUnescapedDyndep() const; /// Like GetBinding("rspfile"), but without shell escaping. std::string GetUnescapedRspfile() const; @@ -172,8 +171,8 @@ struct Edge { const Rule* rule_; Pool* pool_; - vector inputs_; - vector outputs_; + std::vector inputs_; + std::vector outputs_; Node* dyndep_; BindingEnv* env_; VisitMark mark_; @@ -232,7 +231,7 @@ struct ImplicitDepLoader { /// Load implicit dependencies for \a edge. /// @return false on error (without filling \a err if info is just missing // or out of date). - bool LoadDeps(Edge* edge, string* err); + bool LoadDeps(Edge* edge, std::string* err); DepsLog* deps_log() const { return deps_log_; @@ -241,15 +240,15 @@ struct ImplicitDepLoader { private: /// Load implicit dependencies for \a edge from a depfile attribute. /// @return false on error (without filling \a err if info is just missing). - bool LoadDepFile(Edge* edge, const string& path, string* err); + bool LoadDepFile(Edge* edge, const std::string& path, std::string* err); /// Load implicit dependencies for \a edge from the DepsLog. /// @return false on error (without filling \a err if info is just missing). - bool LoadDepsFromLog(Edge* edge, string* err); + bool LoadDepsFromLog(Edge* edge, std::string* err); /// Preallocate \a count spaces in the input array on \a edge, returning /// an iterator pointing at the first new space. - vector::iterator PreallocateSpace(Edge* edge, int count); + std::vector::iterator PreallocateSpace(Edge* edge, int count); /// If we don't have a edge that generates this input already, /// create one; this makes us not abort if the input is missing, @@ -279,12 +278,12 @@ struct DependencyScan { /// needs to be re-run, and update outputs_ready_ and each outputs' |dirty_| /// state accordingly. /// Returns false on failure. - bool RecomputeDirty(Node* node, string* err); + bool RecomputeDirty(Node* node, std::string* err); /// Recompute whether any output of the edge is dirty, if so sets |*dirty|. /// Returns false on failure. bool RecomputeOutputsDirty(Edge* edge, Node* most_recent_input, - bool* dirty, string* err); + bool* dirty, std::string* err); BuildLog* build_log() const { return build_log_; @@ -301,17 +300,17 @@ struct DependencyScan { /// build graph with the new information. One overload accepts /// a caller-owned 'DyndepFile' object in which to store the /// information loaded from the dyndep file. - bool LoadDyndeps(Node* node, string* err) const; - bool LoadDyndeps(Node* node, DyndepFile* ddf, string* err) const; + bool LoadDyndeps(Node* node, std::string* err) const; + bool LoadDyndeps(Node* node, DyndepFile* ddf, std::string* err) const; private: - bool RecomputeDirty(Node* node, vector* stack, string* err); - bool VerifyDAG(Node* node, vector* stack, string* err); + bool RecomputeDirty(Node* node, std::vector* stack, std::string* err); + bool VerifyDAG(Node* node, std::vector* stack, std::string* err); /// Recompute whether a given single output should be marked dirty. /// Returns true if so. bool RecomputeOutputDirty(const Edge* edge, const Node* most_recent_input, - const string& command, Node* output); + const std::string& command, Node* output); BuildLog* build_log_; DiskInterface* disk_interface_; diff --git a/src/includes_normalize.h b/src/includes_normalize.h index 0339581..1b852e1 100644 --- a/src/includes_normalize.h +++ b/src/includes_normalize.h @@ -14,7 +14,6 @@ #include #include -using namespace std; struct StringPiece; @@ -22,18 +21,19 @@ struct StringPiece; /// TODO: this likely duplicates functionality of CanonicalizePath; refactor. struct IncludesNormalize { /// Normalize path relative to |relative_to|. - IncludesNormalize(const string& relative_to); + IncludesNormalize(const std::string& relative_to); // Internal utilities made available for testing, maybe useful otherwise. - static string AbsPath(StringPiece s, string* err); - static string Relativize(StringPiece path, - const vector& start_list, string* err); + static std::string AbsPath(StringPiece s, std::string* err); + static std::string Relativize(StringPiece path, + const std::vector& start_list, + std::string* err); /// Normalize by fixing slashes style, fixing redundant .. and . and makes the /// path |input| relative to |this->relative_to_| and store to |result|. - bool Normalize(const string& input, string* result, string* err) const; + bool Normalize(const std::string& input, std::string* result, std::string* err) const; private: - string relative_to_; - vector split_relative_to_; + std::string relative_to_; + std::vector split_relative_to_; }; diff --git a/src/lexer.cc b/src/lexer.cc index 35ae97b..6e4a470 100644 --- a/src/lexer.cc +++ b/src/lexer.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 */ +/* Generated by re2c 1.1.1 */ // Copyright 2011 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,8 @@ #include "eval_env.h" #include "util.h" +using namespace std; + bool Lexer::Error(const string& message, string* err) { // Compute line/column. int line = 1; @@ -233,8 +235,7 @@ yy8: goto yy5; yy9: yyaccept = 0; - q = ++p; - yych = *p; + yych = *(q = ++p); if (yybm[0+yych] & 32) { goto yy9; } @@ -252,8 +253,7 @@ yy12: if (yych <= 0x00) goto yy5; goto yy33; yy13: - ++p; - yych = *p; + yych = *++p; yy14: if (yybm[0+yych] & 64) { goto yy13; @@ -290,8 +290,8 @@ yy25: if (yych == 'u') goto yy41; goto yy14; yy26: - ++p; - if ((yych = *p) == '|') goto yy42; + yych = *++p; + if (yych == '|') goto yy42; { token = PIPE; break; } yy28: ++p; @@ -307,8 +307,7 @@ yy31: goto yy5; } yy32: - ++p; - yych = *p; + yych = *++p; yy33: if (yybm[0+yych] & 128) { goto yy32; @@ -380,14 +379,14 @@ yy52: if (yych == 'u') goto yy61; goto yy14; yy53: - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = POOL; break; } yy55: - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = RULE; break; } @@ -396,8 +395,8 @@ yy57: if (yych == 'i') goto yy62; goto yy14; yy58: - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = BUILD; break; } @@ -426,22 +425,22 @@ yy65: if (yych == 'j') goto yy70; goto yy14; yy66: - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = DEFAULT; break; } yy68: - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = INCLUDE; break; } yy70: yych = *++p; if (yych != 'a') goto yy14; - ++p; - if (yybm[0+(yych = *p)] & 64) { + yych = *++p; + if (yybm[0+yych] & 64) { goto yy13; } { token = SUBNINJA; break; } @@ -521,8 +520,7 @@ yy77: yy78: { break; } yy79: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 128) { goto yy79; } @@ -600,8 +598,7 @@ bool Lexer::ReadIdent(string* out) { return false; } yy93: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 128) { goto yy93; } @@ -681,8 +678,7 @@ yy98: return Error("unexpected EOF", err); } yy100: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 16) { goto yy100; } @@ -704,8 +700,8 @@ yy103: } } yy105: - ++p; - if ((yych = *p) == '\n') goto yy108; + yych = *++p; + if (yych == '\n') goto yy108; { last_token_ = start; return Error(DescribeLastError(), err); @@ -750,8 +746,7 @@ yy111: return Error("bad $-escape (literal $ must be written as $$)", err); } yy112: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 32) { goto yy112; } @@ -775,8 +770,7 @@ yy118: continue; } yy120: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 64) { goto yy120; } @@ -797,15 +791,13 @@ yy125: } goto yy111; yy126: - ++p; - yych = *p; + yych = *++p; if (yych == ' ') goto yy126; { continue; } yy129: - ++p; - yych = *p; + yych = *++p; if (yybm[0+yych] & 128) { goto yy129; } diff --git a/src/lexer.h b/src/lexer.h index f366556..788d948 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -55,7 +55,7 @@ struct Lexer { /// If the last token read was an ERROR token, provide more info /// or the empty string. - string DescribeLastError(); + std::string DescribeLastError(); /// Start parsing some input. void Start(StringPiece filename, StringPiece input); @@ -71,30 +71,30 @@ struct Lexer { /// Read a simple identifier (a rule or variable name). /// Returns false if a name can't be read. - bool ReadIdent(string* out); + bool ReadIdent(std::string* out); /// Read a path (complete with $escapes). /// Returns false only on error, returned path may be empty if a delimiter /// (space, newline) is hit. - bool ReadPath(EvalString* path, string* err) { + bool ReadPath(EvalString* path, std::string* err) { return ReadEvalString(path, true, err); } /// Read the value side of a var = value line (complete with $escapes). /// Returns false only on error. - bool ReadVarValue(EvalString* value, string* err) { + bool ReadVarValue(EvalString* value, std::string* err) { return ReadEvalString(value, false, err); } /// Construct an error message with context. - bool Error(const string& message, string* err); + bool Error(const std::string& message, std::string* err); private: /// Skip past whitespace (called after each read token/ident/etc.). void EatWhitespace(); /// Read a $-escaped string. - bool ReadEvalString(EvalString* eval, bool path, string* err); + bool ReadEvalString(EvalString* eval, bool path, std::string* err); StringPiece filename_; StringPiece input_; diff --git a/src/line_printer.h b/src/line_printer.h index 92d4dc4..a8ec9ff 100644 --- a/src/line_printer.h +++ b/src/line_printer.h @@ -17,7 +17,6 @@ #include #include -using namespace std; /// Prints lines of text, possibly overprinting previously printed lines /// if the terminal supports it. @@ -35,10 +34,10 @@ struct LinePrinter { }; /// Overprints the current line. If type is ELIDE, elides to_print to fit on /// one line. - void Print(string to_print, LineType type); + void Print(std::string to_print, LineType type); /// Prints a string on a new line, not overprinting previous output. - void PrintOnNewLine(const string& to_print); + void PrintOnNewLine(const std::string& to_print); /// Lock or unlock the console. Any output sent to the LinePrinter while the /// console is locked will not be printed until it is unlocked. @@ -58,13 +57,13 @@ struct LinePrinter { bool console_locked_; /// Buffered current line while console is locked. - string line_buffer_; + std::string line_buffer_; /// Buffered line type while console is locked. LineType line_type_; /// Buffered console output while console is locked. - string output_buffer_; + std::string output_buffer_; #ifdef _WIN32 void* console_; diff --git a/src/manifest_parser.h b/src/manifest_parser.h index e14d069..887be50 100644 --- a/src/manifest_parser.h +++ b/src/manifest_parser.h @@ -44,24 +44,24 @@ struct ManifestParser : public Parser { ManifestParserOptions options = ManifestParserOptions()); /// Parse a text string of input. Used by tests. - bool ParseTest(const string& input, string* err) { + bool ParseTest(const std::string& input, std::string* err) { quiet_ = true; return Parse("input", input, err); } private: /// Parse a file, given its contents as a string. - bool Parse(const string& filename, const string& input, string* err); + bool Parse(const std::string& filename, const std::string& input, std::string* err); /// Parse various statement types. - bool ParsePool(string* err); - bool ParseRule(string* err); - bool ParseLet(string* key, EvalString* val, string* err); - bool ParseEdge(string* err); - bool ParseDefault(string* err); + bool ParsePool(std::string* err); + bool ParseRule(std::string* err); + bool ParseLet(std::string* key, EvalString* val, std::string* err); + bool ParseEdge(std::string* err); + bool ParseDefault(std::string* err); /// Parse either a 'subninja' or 'include' line. - bool ParseFileInclude(bool new_scope, string* err); + bool ParseFileInclude(bool new_scope, std::string* err); BindingEnv* env_; ManifestParserOptions options_; diff --git a/src/metrics.h b/src/metrics.h index b6da859..11239b5 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -17,7 +17,6 @@ #include #include -using namespace std; #include "util.h" // For int64_t. @@ -26,7 +25,7 @@ using namespace std; /// A single metrics we're tracking, like "depfile load time". struct Metric { - string name; + std::string name; /// Number of times we've hit the code path. int count; /// Total time (in micros) we've spent on the code path. @@ -49,13 +48,13 @@ private: /// The singleton that stores metrics and prints the report. struct Metrics { - Metric* NewMetric(const string& name); + Metric* NewMetric(const std::string& name); /// Print a summary report to stdout. void Report(); private: - vector metrics_; + std::vector metrics_; }; /// Get the current time as relative to some epoch. diff --git a/src/msvc_helper.h b/src/msvc_helper.h index 70d1fff..568b9f9 100644 --- a/src/msvc_helper.h +++ b/src/msvc_helper.h @@ -13,9 +13,8 @@ // limitations under the License. #include -using namespace std; -string EscapeForDepfile(const string& path); +std::string EscapeForDepfile(const std::string& path); /// Wraps a synchronous execution of a CL subprocess. struct CLWrapper { @@ -27,7 +26,7 @@ struct CLWrapper { /// Start a process and gather its raw output. Returns its exit code. /// Crashes (calls Fatal()) on error. - int Run(const string& command, string* output); + int Run(const std::string& command, std::string* output); void* env_block_; }; diff --git a/src/parser.h b/src/parser.h index e2d2b97..011fad8 100644 --- a/src/parser.h +++ b/src/parser.h @@ -17,8 +17,6 @@ #include -using namespace std; - #include "lexer.h" struct FileReader; @@ -30,12 +28,12 @@ struct Parser { : state_(state), file_reader_(file_reader) {} /// Load and parse a file. - bool Load(const string& filename, string* err, Lexer* parent = NULL); + bool Load(const std::string& filename, std::string* err, Lexer* parent = NULL); protected: /// If the next token is not \a expected, produce an error string /// saying "expected foo, got bar". - bool ExpectToken(Lexer::Token expected, string* err); + bool ExpectToken(Lexer::Token expected, std::string* err); State* state_; FileReader* file_reader_; @@ -43,8 +41,8 @@ protected: private: /// Parse a file, given its contents as a string. - virtual bool Parse(const string& filename, const string& input, - string* err) = 0; + virtual bool Parse(const std::string& filename, const std::string& input, + std::string* err) = 0; }; #endif // NINJA_PARSER_H_ diff --git a/src/state.h b/src/state.h index 6fe886c..f553ed4 100644 --- a/src/state.h +++ b/src/state.h @@ -19,7 +19,6 @@ #include #include #include -using namespace std; #include "eval_env.h" #include "hash_map.h" @@ -38,13 +37,13 @@ struct Rule; /// the total scheduled weight diminishes enough (i.e. when a scheduled edge /// completes). struct Pool { - Pool(const string& name, int depth) + Pool(const std::string& name, int depth) : name_(name), current_use_(0), depth_(depth), delayed_(&WeightedEdgeCmp) {} // A depth of 0 is infinite bool is_valid() const { return depth_ >= 0; } int depth() const { return depth_; } - const string& name() const { return name_; } + const std::string& name() const { return name_; } int current_use() const { return current_use_; } /// true if the Pool might delay this edge @@ -62,13 +61,13 @@ struct Pool { void DelayEdge(Edge* edge); /// Pool will add zero or more edges to the ready_queue - void RetrieveReadyEdges(set* ready_queue); + void RetrieveReadyEdges(std::set* ready_queue); /// Dump the Pool and its edges (useful for debugging). void Dump() const; private: - string name_; + std::string name_; /// |current_use_| is the total of the weights of the edges which are /// currently scheduled in the Plan (i.e. the edges in Plan::ready_). @@ -77,7 +76,7 @@ struct Pool { static bool WeightedEdgeCmp(const Edge* a, const Edge* b); - typedef set DelayedEdges; + typedef std::set DelayedEdges; DelayedEdges delayed_; }; @@ -90,17 +89,17 @@ struct State { State(); void AddPool(Pool* pool); - Pool* LookupPool(const string& pool_name); + Pool* LookupPool(const std::string& pool_name); Edge* AddEdge(const Rule* rule); Node* GetNode(StringPiece path, uint64_t slash_bits); Node* LookupNode(StringPiece path) const; - Node* SpellcheckNode(const string& path); + Node* SpellcheckNode(const std::string& path); void AddIn(Edge* edge, StringPiece path, uint64_t slash_bits); bool AddOut(Edge* edge, StringPiece path, uint64_t slash_bits); - bool AddDefault(StringPiece path, string* error); + bool AddDefault(StringPiece path, std::string* error); /// Reset state. Keeps all nodes and edges, but restores them to the /// state where we haven't yet examined the disk for dirty state. @@ -111,21 +110,21 @@ struct State { /// @return the root node(s) of the graph. (Root nodes have no output edges). /// @param error where to write the error message if somethings went wrong. - vector RootNodes(string* error) const; - vector DefaultNodes(string* error) const; + std::vector RootNodes(std::string* error) const; + std::vector DefaultNodes(std::string* error) const; /// Mapping of path -> Node. typedef ExternalStringHashMap::Type Paths; Paths paths_; /// All the pools used in the graph. - map pools_; + std::map pools_; /// All the edges of the graph. - vector edges_; + std::vector edges_; BindingEnv bindings_; - vector defaults_; + std::vector defaults_; }; #endif // NINJA_STATE_H_ diff --git a/src/string_piece.h b/src/string_piece.h index 031bda4..1c0bee6 100644 --- a/src/string_piece.h +++ b/src/string_piece.h @@ -17,8 +17,6 @@ #include -using namespace std; - #include /// StringPiece represents a slice of a string whose memory is managed @@ -30,7 +28,7 @@ struct StringPiece { StringPiece() : str_(NULL), len_(0) {} /// The constructors intentionally allow for implicit conversions. - StringPiece(const string& str) : str_(str.data()), len_(str.size()) {} + StringPiece(const std::string& str) : str_(str.data()), len_(str.size()) {} StringPiece(const char* str) : str_(str), len_(strlen(str)) {} StringPiece(const char* str, size_t len) : str_(str), len_(len) {} @@ -38,14 +36,15 @@ struct StringPiece { bool operator==(const StringPiece& other) const { return len_ == other.len_ && memcmp(str_, other.str_, len_) == 0; } + bool operator!=(const StringPiece& other) const { return !(*this == other); } /// Convert the slice into a full-fledged std::string, copying the /// data into a new string. - string AsString() const { - return len_ ? string(str_, len_) : string(); + std::string AsString() const { + return len_ ? std::string(str_, len_) : std::string(); } const_iterator begin() const { diff --git a/src/string_piece_util.cc b/src/string_piece_util.cc index 69513f5..5a77294 100644 --- a/src/string_piece_util.cc +++ b/src/string_piece_util.cc @@ -17,6 +17,7 @@ #include #include #include + using namespace std; vector SplitStringPiece(StringPiece input, char sep) { diff --git a/src/string_piece_util.h b/src/string_piece_util.h index 2e40b9f..28470f1 100644 --- a/src/string_piece_util.h +++ b/src/string_piece_util.h @@ -19,11 +19,10 @@ #include #include "string_piece.h" -using namespace std; -vector SplitStringPiece(StringPiece input, char sep); +std::vector SplitStringPiece(StringPiece input, char sep); -string JoinStringPiece(const vector& list, char sep); +std::string JoinStringPiece(const std::vector& list, char sep); inline char ToLowerASCII(char c) { return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; diff --git a/src/subprocess.h b/src/subprocess.h index b2d486c..9e3d2ee 100644 --- a/src/subprocess.h +++ b/src/subprocess.h @@ -18,7 +18,6 @@ #include #include #include -using namespace std; #ifdef _WIN32 #include @@ -49,14 +48,14 @@ struct Subprocess { bool Done() const; - const string& GetOutput() const; + const std::string& GetOutput() const; private: Subprocess(bool use_console); - bool Start(struct SubprocessSet* set, const string& command); + bool Start(struct SubprocessSet* set, const std::string& command); void OnPipeReady(); - string buf_; + std::string buf_; #ifdef _WIN32 /// Set up pipe_ as the parent-side pipe of the subprocess; return the @@ -84,13 +83,13 @@ struct SubprocessSet { SubprocessSet(); ~SubprocessSet(); - Subprocess* Add(const string& command, bool use_console = false); + Subprocess* Add(const std::string& command, bool use_console = false); bool DoWork(); Subprocess* NextFinished(); void Clear(); - vector running_; - queue finished_; + std::vector running_; + std::queue finished_; #ifdef _WIN32 static BOOL WINAPI NotifyInterrupted(DWORD dwCtrlType); diff --git a/src/test.h b/src/test.h index 6af17b3..7fee55e 100644 --- a/src/test.h +++ b/src/test.h @@ -118,7 +118,7 @@ struct StateTestWithBuiltinRules : public testing::Test { void AddCatRule(State* state); /// Short way to get a Node by its path from state_. - Node* GetNode(const string& path); + Node* GetNode(const std::string& path); State state_; }; @@ -135,7 +135,7 @@ struct VirtualFileSystem : public DiskInterface { VirtualFileSystem() : now_(1) {} /// "Create" a file with contents. - void Create(const string& path, const string& contents); + void Create(const std::string& path, const std::string& contents); /// Tick "time" forwards; subsequent file operations will be newer than /// previous ones. @@ -144,25 +144,25 @@ struct VirtualFileSystem : public DiskInterface { } // DiskInterface - virtual TimeStamp Stat(const string& path, string* err) const; - virtual bool WriteFile(const string& path, const string& contents); - virtual bool MakeDir(const string& path); - virtual Status ReadFile(const string& path, string* contents, string* err); - virtual int RemoveFile(const string& path); + virtual TimeStamp Stat(const std::string& path, std::string* err) const; + virtual bool WriteFile(const std::string& path, const std::string& contents); + virtual bool MakeDir(const std::string& path); + virtual Status ReadFile(const std::string& path, std::string* contents, std::string* err); + virtual int RemoveFile(const std::string& path); /// An entry for a single in-memory file. struct Entry { int mtime; - string stat_error; // If mtime is -1. - string contents; + std::string stat_error; // If mtime is -1. + std::string contents; }; - vector directories_made_; - vector files_read_; - typedef map FileMap; + std::vector directories_made_; + std::vector files_read_; + typedef std::map FileMap; FileMap files_; - set files_removed_; - set files_created_; + std::set files_removed_; + std::set files_created_; /// A simple fake timestamp for file operations. int now_; @@ -170,15 +170,15 @@ struct VirtualFileSystem : public DiskInterface { struct ScopedTempDir { /// Create a temporary directory and chdir into it. - void CreateAndEnter(const string& name); + void CreateAndEnter(const std::string& name); /// Clean up the temporary directory. void Cleanup(); /// The temp directory containing our dir. - string start_dir_; + std::string start_dir_; /// The subdirectory name for our dir, or empty if it hasn't been set up. - string temp_dir_name_; + std::string temp_dir_name_; }; #endif // NINJA_TEST_H_ diff --git a/src/util.h b/src/util.h index 6a4a7a9..b2ba1cd 100644 --- a/src/util.h +++ b/src/util.h @@ -23,7 +23,6 @@ #include #include -using namespace std; #ifdef _MSC_VER #define NORETURN __declspec(noreturn) @@ -57,29 +56,29 @@ void Error(const char* msg, ...); /// Canonicalize a path like "foo/../bar.h" into just "bar.h". /// |slash_bits| has bits set starting from lowest for a backslash that was /// normalized to a forward slash. (only used on Windows) -bool CanonicalizePath(string* path, uint64_t* slash_bits, string* err); +bool CanonicalizePath(std::string* path, uint64_t* slash_bits, std::string* err); bool CanonicalizePath(char* path, size_t* len, uint64_t* slash_bits, - string* err); + std::string* err); /// Appends |input| to |*result|, escaping according to the whims of either /// Bash, or Win32's CommandLineToArgvW(). /// Appends the string directly to |result| without modification if we can /// determine that it contains no problematic characters. -void GetShellEscapedString(const string& input, string* result); -void GetWin32EscapedString(const string& input, string* result); +void GetShellEscapedString(const std::string& input, std::string* result); +void GetWin32EscapedString(const std::string& input, std::string* result); /// Read a file to a string (in text mode: with CRLF conversion /// on Windows). /// Returns -errno and fills in \a err on error. -int ReadFile(const string& path, string* contents, string* err); +int ReadFile(const std::string& path, std::string* contents, std::string* err); /// Mark a file descriptor to not be inherited on exec()s. void SetCloseOnExec(int fd); /// Given a misspelled string and a list of correct spellings, returns /// the closest match or NULL if there is no close enough match. -const char* SpellcheckStringV(const string& text, - const vector& words); +const char* SpellcheckStringV(const std::string& text, + const std::vector& words); /// Like SpellcheckStringV, but takes a NULL-terminated list. const char* SpellcheckString(const char* text, ...); @@ -87,7 +86,7 @@ const char* SpellcheckString(const char* text, ...); bool islatinalpha(int c); /// Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm). -string StripAnsiEscapeCodes(const string& in); +std::string StripAnsiEscapeCodes(const std::string& in); /// @return the number of processors on the machine. Useful for an initial /// guess for how many jobs to run in parallel. @return 0 on error. @@ -99,10 +98,10 @@ double GetLoadAverage(); /// Elide the given string @a str with '...' in the middle if the length /// exceeds @a width. -string ElideMiddle(const string& str, size_t width); +std::string ElideMiddle(const std::string& str, size_t width); /// Truncates a file to the given size. -bool Truncate(const string& path, size_t size, string* err); +bool Truncate(const std::string& path, size_t size, std::string* err); #ifdef _MSC_VER #define snprintf _snprintf @@ -116,7 +115,7 @@ bool Truncate(const string& path, size_t size, string* err); #ifdef _WIN32 /// Convert the value returned by GetLastError() into a string. -string GetLastErrorString(); +std::string GetLastErrorString(); /// Calls Fatal() with a function name and GetLastErrorString. NORETURN void Win32Fatal(const char* function, const char* hint = NULL); diff --git a/src/version.h b/src/version.h index bd6b9ff..9d84ecb 100644 --- a/src/version.h +++ b/src/version.h @@ -16,17 +16,16 @@ #define NINJA_VERSION_H_ #include -using namespace std; /// The version number of the current Ninja release. This will always /// be "git" on trunk. extern const char* kNinjaVersion; /// Parse the major/minor components of a version string. -void ParseVersion(const string& version, int* major, int* minor); +void ParseVersion(const std::string& version, int* major, int* minor); /// Check whether \a version is compatible with the current Ninja version, /// aborting if not. -void CheckNinjaVersion(const string& required_version); +void CheckNinjaVersion(const std::string& required_version); #endif // NINJA_VERSION_H_ -- cgit v0.12