2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------ */
32 //==========================================================================
33 void replace(std::string& str,
34 const std::string& from,
35 const std::string& to )
37 std::string::size_type pos = str.find( from );
38 while ( pos != std::string::npos )
40 str.replace( pos, from.size(), to );
41 pos = str.find( from, pos+from.size()-1 );
44 //==========================================================================
47 //==========================================================================
48 int main(int argc, char **argv)
53 for(int i = 1; i < argc; i++){
54 std::cerr << "|||| "<<argv[i]<<std::endl;
56 std::cerr << "usage : "<< argv[0] <<" -fileIn \"-FindString\" \"-ReplaceString\"" << std::endl;
63 std::string findstring;
64 std::string replacestring;
70 replacestring = argv[3];
72 ffIn = fopen(fileIn.c_str(),"r");
75 fgets( strTmp , 255, ffIn );
77 if( feof(ffIn) && (lineStr.length()==1) ) {
79 replace( lineStr,findstring, replacestring );
85 std::cerr << "ERROR. File : "<< argv[1] <<" does not exists." << std::endl;
92 //==========================================================================