]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/CDMUtilities.h
By Leonardo Florez
[crea.git] / lib / creaDevManagerLib / CDMUtilities.h
index e245450c831aaed17ad39616d0ffdab7881b8e4e..8ec696733767b7052c1cf099974a0e5644a013f9 100644 (file)
@@ -118,7 +118,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;
+      }
   };
 
   /**
@@ -204,6 +226,13 @@ namespace CDMUtilities
    * @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.