Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

utility.h

Go to the documentation of this file.
00001 #ifndef UTILITY_INCLUDED
00002 #define UTILITY_INCLUDED
00003 
00004 #include <string>
00005 #include <sstream>
00006 #include <iterator>
00007 #include <vector>
00008 #include <iostream>
00009 #include <algorithm>
00010 
00011 std::string dtoa(double value);
00012 std::vector<std::string> split(const std::string& s);
00013 
00014 //
00015 // dtoa() : Takes a double and returns a std::string
00016 //
00017 inline std::string dtoa(double value){
00018         
00019         std::stringstream ss;
00020         ss << value;
00021         return ss.str();
00022         
00023 }
00024 
00025 //
00026 // split(): Takes a string, tokenizes it on the white space
00027 //          and returns a std::vector of the tokens
00028 //
00029 inline std::vector<std::string> split(const std::string& s){
00030         
00031         std::istringstream is(s);
00032         return std::vector<std::string> (std::istream_iterator<std::string>(is),std::istream_iterator<std::string>());
00033         
00034 }
00035 
00036 //
00037 // stringToUpper: Returns an upper-cased transformed copy of the string
00038 //
00039 inline std::string stringToUpper(const std::string &label){
00040         std::string upperCase = label;
00041         std::transform(upperCase.begin(),upperCase.end(),upperCase.begin(),(int(*)(int))toupper);
00042         return upperCase;
00043         
00044 }
00045 
00046 
00047 #endif

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4