String.hxx

00001 // Copyright (C) 2004-2007, Vivien Mallet
00002 //
00003 // This file is part of Talos library, which provides miscellaneous tools to
00004 // make up for C++ lacks and to ease C++ programming.
00005 //
00006 // Talos is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 2 of the License, or (at your option) any later
00009 // version.
00010 //
00011 // Talos is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00014 // details.
00015 //
00016 // For more information, visit the Talos home page:
00017 //     http://vivienmallet.net/lib/talos/
00018 
00019 
00020 #ifndef TALOS_FILE_STRING_HXX
00021 
00022 
00023 #include <iostream>
00024 #include <algorithm>
00025 #include <string>
00026 #include <fstream>
00027 #include <sstream>
00028 #include <vector>
00029 #include <stdexcept>
00030 
00031 #include "Date.hxx"
00032 
00033 
00034 namespace Talos
00035 {
00036 
00037   using namespace std;
00038 
00039   template<typename T>
00040   string to_str(const T& input);
00041 
00042 #ifndef SWIG
00043   string fill(const string& input, int l = 2, char c = ' ',
00044               ostringstream::fmtflags flags = ostringstream::left);
00045 
00046   template<typename T>
00047   string to_str_fill(const T& input, int l = 2, char c = ' ',
00048                      ostringstream::fmtflags flags = ostringstream::left);
00049 #endif
00050 
00051   template <class T>
00052   void to_num(const string& s, T& num);
00053 
00054   template <class T>
00055   T to_num(const string& s);
00056 
00057   template <class T>
00058   void convert(const string& s, T& num);
00059   void convert(const string& s, string& num);
00060 
00061   template <class T>
00062   T convert(const string& s);
00063   
00064   string lower_case(string str);
00065   string upper_case(string str);
00066   
00067   bool is_num(const string& s);
00068 
00069   // The functions with 'char*' and 'const char*' are provided for convenience
00070   // and to adequately overload the function 'is_integer' of the scientific
00071   // library Blitz++.
00072   bool is_integer(char* s);
00073   bool is_integer(const char* s);
00074   bool is_integer(const string& s);
00075 
00076   bool is_unsigned_integer(const string& s);
00077 
00078   bool is_date(const string& s);
00079 
00080   bool is_delta(const string& s);
00081 
00082   string find_replace(string str, string old_str, string new_str = "");
00083 
00084   string trim(string str, string delimiters = " \n\t");
00085 
00086   string trim_beg(string str, string delimiters = " \n\t");
00087 
00088   string trim_end(string str, string delimiters = " \n\t");
00089 
00090   template <class T>
00091   void split(string str, vector<T>& vect, string delimiters = " \n\t");
00092   vector<string> split(string str, string delimiters = " \n\t");
00093 
00094   template <class T>
00095   void split_markup(string str, vector<T>& elements, vector<bool>& is_markup,
00096                     string delimiters = "$");
00097   
00098   template <class T>
00099   void print(const vector<T>& v);
00100   
00101 }  // namespace Talos.
00102 
00103 
00104 #define TALOS_FILE_STRING_HXX
00105 #endif

Generated on Mon Nov 17 18:20:41 2008 for Talos by  doxygen 1.5.1