]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/CDMUtilities.h
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / CDMUtilities.h
index f807d3262b59df22e837f09a8d71834e28655a02..935ce941635e63e787d60b23f8491c8b25bba9ab 100644 (file)
@@ -93,6 +93,13 @@ namespace CDMUtilities
   static std::string TERMINAL = "gnome-terminal";
 #endif
 
+#ifndef _WIN32
+  /**
+   * Build Command
+   */
+  static std::string BUILD_COMMAND = "make";
+#endif
+
   /**
    * Structure that handles the split method for c++
    * It calls the split method to split a string given certain delimiters.
@@ -118,7 +125,29 @@ namespace CDMUtilities
         const typename Container::value_type& s,
         const typename Container::value_type& delimiters,
         empties_t empties = empties_ok
-    );
+      )
+      {
+        result.clear();
+        size_t current;
+        size_t next = -1;
+        do
+        {
+          if (empties == no_empties)
+          {
+            next = s.find_first_not_of(delimiters, next + 1);
+            if (next == Container::value_type::npos)
+            {
+              break;
+            }
+            next -= 1;
+          }
+          current = next + 1;
+          next = s.find_first_of(delimiters, current);
+          result.push_back(s.substr(current, next - current));
+        }
+        while (next != Container::value_type::npos);
+        return result;
+      }
   };
 
   /**
@@ -198,6 +227,20 @@ namespace CDMUtilities
    */
   typedef std::vector<syntaxElement> CMLFile;
 
+  /**
+   * Reads a file as string and returns the read data.
+   * @param file_path Full path of the CMakeLists file.
+   * @return A string with the contents of the given file.
+   */
+  std::string readFile(const std::string& file_path);
+  /**
+   * Writes the given string into a file and returns whether the operation is successful.
+   * @param file_path Full path of the CMakeLists file.
+   * @param st string to write.
+   * @return True if the operation was successful.
+   */
+  bool writeFile(const std::string& file_path, const std::string& st);
+
   /**
    * Reads a CMakeLists file and returns the read data.
    * @param file_path Full path of the CMakeLists file.
@@ -213,6 +256,11 @@ namespace CDMUtilities
    */
   bool writeCMLFile(const std::string& file_path, const CMLFile& data);
 
+  /**
+   * @param st Strips all space character at the beginning and at the end of the string.
+   */
+  void normalizeStr(std::string& st);
+
 };
 
 #endif /* CDMUTILITIES_H_ */