From e9bbfdd9a115332deb40da10784d478f4930c68f Mon Sep 17 00:00:00 2001 From: Artur Ryt Date: Sat, 30 Mar 2019 15:34:59 +0100 Subject: cmcmd: Pass args vector by const& --- Source/cmcmd.cxx | 21 +++++++++++---------- Source/cmcmd.h | 14 +++++++------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 8d63971..757a46c 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -368,7 +368,7 @@ struct CoCompileJob }; // called when args[0] == "__run_co_compile" -int cmcmd::HandleCoCompileCommands(std::vector& args) +int cmcmd::HandleCoCompileCommands(std::vector const& args) { std::vector jobs; std::string sourceFile; // store --source= @@ -466,7 +466,7 @@ int cmcmd::HandleCoCompileCommands(std::vector& args) return ret; } -int cmcmd::ExecuteCMakeCommand(std::vector& args) +int cmcmd::ExecuteCMakeCommand(std::vector const& args) { // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx if (args.size() > 1) { @@ -1262,7 +1262,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) return 1; } -int cmcmd::HashSumFile(std::vector& args, cmCryptoHash::Algo algo) +int cmcmd::HashSumFile(std::vector const& args, + cmCryptoHash::Algo algo) { if (args.size() < 3) { return -1; @@ -1289,7 +1290,7 @@ int cmcmd::HashSumFile(std::vector& args, cmCryptoHash::Algo algo) return retval; } -int cmcmd::SymlinkLibrary(std::vector& args) +int cmcmd::SymlinkLibrary(std::vector const& args) { int result = 0; std::string realName = args[2]; @@ -1313,7 +1314,7 @@ int cmcmd::SymlinkLibrary(std::vector& args) return result; } -int cmcmd::SymlinkExecutable(std::vector& args) +int cmcmd::SymlinkExecutable(std::vector const& args) { int result = 0; std::string const& realName = args[2]; @@ -1387,7 +1388,7 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num) } } -int cmcmd::ExecuteEchoColor(std::vector& args) +int cmcmd::ExecuteEchoColor(std::vector const& args) { // The arguments are // args[0] == @@ -1445,7 +1446,7 @@ int cmcmd::ExecuteEchoColor(std::vector& args) return 0; } -int cmcmd::ExecuteLinkScript(std::vector& args) +int cmcmd::ExecuteLinkScript(std::vector const& args) { // The arguments are // args[0] == @@ -1658,9 +1659,9 @@ std::ostream& operator<<(std::ostream& stream, return stream; } -static bool RunCommand(const char* comment, std::vector& command, - bool verbose, NumberFormat exitFormat, - int* retCodeOut = nullptr, +static bool RunCommand(const char* comment, + std::vector const& command, bool verbose, + NumberFormat exitFormat, int* retCodeOut = nullptr, bool (*retCodeOkay)(int) = nullptr) { if (verbose) { diff --git a/Source/cmcmd.h b/Source/cmcmd.h index d1e03d0..69a7ecb 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -16,18 +16,18 @@ public: * Execute commands during the build process. Supports options such * as echo, remove file etc. */ - static int ExecuteCMakeCommand(std::vector&); + static int ExecuteCMakeCommand(std::vector const&); protected: - static int HandleCoCompileCommands(std::vector& args); - static int HashSumFile(std::vector& args, + static int HandleCoCompileCommands(std::vector const& args); + static int HashSumFile(std::vector const& args, cmCryptoHash::Algo algo); - static int SymlinkLibrary(std::vector& args); - static int SymlinkExecutable(std::vector& args); + static int SymlinkLibrary(std::vector const& args); + static int SymlinkExecutable(std::vector const& args); static bool SymlinkInternal(std::string const& file, std::string const& link); - static int ExecuteEchoColor(std::vector& args); - static int ExecuteLinkScript(std::vector& args); + static int ExecuteEchoColor(std::vector const& args); + static int ExecuteLinkScript(std::vector const& args); static int WindowsCEEnvironment(const char* version, const std::string& name); static int VisualStudioLink(std::vector const& args, int type); -- cgit v0.12