2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
31 * Created on: Nov 23, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #ifndef CDMUTILITIES_H_
36 #define CDMUTILITIES_H_
41 namespace CDMUtilities
48 static std::string SLASH = "\\";
51 static std::string SLASH = "/";
53 static std::string SLASH = "/";
61 static std::string TEXT_EDITOR = "notepad";
64 //TODO: implementation for apple
66 static std::string TEXT_EDITOR = "gedit";
70 * File explorer program
74 static std::string FILE_EXPLORER = "explorer";
77 //TODO: implementation for apple
79 static std::string FILE_EXPLORER = "nautilus";
87 static std::string TERMINAL = "start cmd.exe";
90 //TODO: implementation for apple
92 static std::string TERMINAL = "gnome-terminal";
97 * Structure that handles the split method for c++
98 * It calls the split method to split a string given certain delimiters.
103 * Enum to allow or not empty resulting strings after performing splits.
105 enum empties_t { empties_ok, no_empties };
107 * Method to split a string given a set of delimiter characters.
108 * @param result Resulting container.
109 * @param s String to be splitted.
110 * @param delimiters Delimiter characters to split the string.
111 * @param empties Either allow or not empty resulting strings after performing split.
112 * @return Resulting container.
114 template <typename Container>
115 static Container& split
118 const typename Container::value_type& s,
119 const typename Container::value_type& delimiters,
120 empties_t empties = empties_ok
125 * Fixes a given path to avoid double slash directories
126 * @param path Unfixed path.
127 * @return Fixed path.
129 const std::string fixPath(const std::string& path);
132 * Opens the default text editor. If a file is given, then it tries to open the given file.
133 * @param file Full path to the file.
134 * @return True if there was an error on the execution of the operation.
136 int openTextEditor(const std::string& file = "");
138 * Opens the system file explorer on the given file path
139 * @param file Path of the desired folder to open.
140 * @return True if there was an error on the execution of the operation.
142 int openFileExplorer(const std::string& file = "");
144 * Opens a file with a given command.
145 * @param file Full path of the file to open.
146 * @param command Command to execute the file with.
147 * @return True if there was an error on the execution of the operation.
149 int openFileWithCommand(const std::string& file, const std::string& command);
151 * Opens the BBTK Graphical Editor
152 * @return True if there was an error on the execution of the operation.
156 * Opens the minitools or the creaTools
157 * @return True if there was an error on the execution of the operation.
159 int openCreaToolsTools();
161 * Open a command line interpreter and executes the given command if any.
162 * @param command Command to execute.
163 * @return True if there was an error on the execution of the operation.
165 int openTerminal(const std::string& command = "");
167 * Creates a blank class(.h and .cpp files).
168 * @param name Name of the new class.
169 * @param path Path where the class is to be created.
170 * @return True if the class was successfully created.
172 bool createEmptyClass(const std::string& name, const std::string& path);
174 * Creates a string replacing each \ by double \ .
175 * @param line String to stringify.
176 * @return line stringified.
178 std::string stringify(const std::string& line);
181 #endif /* CDMUTILITIES_H_ */