Browse Source

cmcmd: Pass args vector by const&

Artur Ryt 6 years ago
parent
commit
e9bbfdd9a1
2 changed files with 18 additions and 17 deletions
  1. 11 10
      Source/cmcmd.cxx
  2. 7 7
      Source/cmcmd.h

+ 11 - 10
Source/cmcmd.cxx

@@ -368,7 +368,7 @@ struct CoCompileJob
 };
 };
 
 
 // called when args[0] == "__run_co_compile"
 // called when args[0] == "__run_co_compile"
-int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
+int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args)
 {
 {
   std::vector<CoCompileJob> jobs;
   std::vector<CoCompileJob> jobs;
   std::string sourceFile;             // store --source=
   std::string sourceFile;             // store --source=
@@ -466,7 +466,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
   return ret;
   return ret;
 }
 }
 
 
-int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
+int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
 {
 {
   // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
   // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
   if (args.size() > 1) {
   if (args.size() > 1) {
@@ -1262,7 +1262,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
   return 1;
   return 1;
 }
 }
 
 
-int cmcmd::HashSumFile(std::vector<std::string>& args, cmCryptoHash::Algo algo)
+int cmcmd::HashSumFile(std::vector<std::string> const& args,
+                       cmCryptoHash::Algo algo)
 {
 {
   if (args.size() < 3) {
   if (args.size() < 3) {
     return -1;
     return -1;
@@ -1289,7 +1290,7 @@ int cmcmd::HashSumFile(std::vector<std::string>& args, cmCryptoHash::Algo algo)
   return retval;
   return retval;
 }
 }
 
 
-int cmcmd::SymlinkLibrary(std::vector<std::string>& args)
+int cmcmd::SymlinkLibrary(std::vector<std::string> const& args)
 {
 {
   int result = 0;
   int result = 0;
   std::string realName = args[2];
   std::string realName = args[2];
@@ -1313,7 +1314,7 @@ int cmcmd::SymlinkLibrary(std::vector<std::string>& args)
   return result;
   return result;
 }
 }
 
 
-int cmcmd::SymlinkExecutable(std::vector<std::string>& args)
+int cmcmd::SymlinkExecutable(std::vector<std::string> const& args)
 {
 {
   int result = 0;
   int result = 0;
   std::string const& realName = args[2];
   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<std::string>& args)
+int cmcmd::ExecuteEchoColor(std::vector<std::string> const& args)
 {
 {
   // The arguments are
   // The arguments are
   //   args[0] == <cmake-executable>
   //   args[0] == <cmake-executable>
@@ -1445,7 +1446,7 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string>& args)
   return 0;
   return 0;
 }
 }
 
 
-int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
+int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args)
 {
 {
   // The arguments are
   // The arguments are
   //   args[0] == <cmake-executable>
   //   args[0] == <cmake-executable>
@@ -1658,9 +1659,9 @@ std::ostream& operator<<(std::ostream& stream,
   return stream;
   return stream;
 }
 }
 
 
-static bool RunCommand(const char* comment, std::vector<std::string>& command,
-                       bool verbose, NumberFormat exitFormat,
-                       int* retCodeOut = nullptr,
+static bool RunCommand(const char* comment,
+                       std::vector<std::string> const& command, bool verbose,
+                       NumberFormat exitFormat, int* retCodeOut = nullptr,
                        bool (*retCodeOkay)(int) = nullptr)
                        bool (*retCodeOkay)(int) = nullptr)
 {
 {
   if (verbose) {
   if (verbose) {

+ 7 - 7
Source/cmcmd.h

@@ -16,18 +16,18 @@ public:
    * Execute commands during the build process. Supports options such
    * Execute commands during the build process. Supports options such
    * as echo, remove file etc.
    * as echo, remove file etc.
    */
    */
-  static int ExecuteCMakeCommand(std::vector<std::string>&);
+  static int ExecuteCMakeCommand(std::vector<std::string> const&);
 
 
 protected:
 protected:
-  static int HandleCoCompileCommands(std::vector<std::string>& args);
-  static int HashSumFile(std::vector<std::string>& args,
+  static int HandleCoCompileCommands(std::vector<std::string> const& args);
+  static int HashSumFile(std::vector<std::string> const& args,
                          cmCryptoHash::Algo algo);
                          cmCryptoHash::Algo algo);
-  static int SymlinkLibrary(std::vector<std::string>& args);
-  static int SymlinkExecutable(std::vector<std::string>& args);
+  static int SymlinkLibrary(std::vector<std::string> const& args);
+  static int SymlinkExecutable(std::vector<std::string> const& args);
   static bool SymlinkInternal(std::string const& file,
   static bool SymlinkInternal(std::string const& file,
                               std::string const& link);
                               std::string const& link);
-  static int ExecuteEchoColor(std::vector<std::string>& args);
-  static int ExecuteLinkScript(std::vector<std::string>& args);
+  static int ExecuteEchoColor(std::vector<std::string> const& args);
+  static int ExecuteLinkScript(std::vector<std::string> const& args);
   static int WindowsCEEnvironment(const char* version,
   static int WindowsCEEnvironment(const char* version,
                                   const std::string& name);
                                   const std::string& name);
   static int VisualStudioLink(std::vector<std::string> const& args, int type);
   static int VisualStudioLink(std::vector<std::string> const& args, int type);