E:/Eigene Dateien/Eigene Projekte/c0re/myTools.cpp

Go to the documentation of this file.
00001 /*
00002         This file is part of c0re.
00003 
00004         c0re is a multiplayer RTS on a hexagonal map with an evolving unit concept.
00005     Copyright (C) 2007 Stephan Hofmann
00006 
00007     c0re is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "myTools.h"
00022 
00023 #include <sstream> 
00024 
00025 int splitLine(std::vector<std::string>& pieces, std::string toSplit, std::string delimiter, bool ignDoubleDelim)
00026 {
00027         pieces.clear();
00028         long pos=0;
00029 
00030         std::string helpString = toSplit;
00031 
00032         while ((pos = (long) toSplit.find(delimiter)) != -1 )
00033         {
00034                 toSplit.erase (pos, toSplit.length());
00035                 helpString.erase (0, pos + 1);
00036                 if ( !ignDoubleDelim && (toSplit.length() != 0) )
00037                         pieces.push_back(toSplit);
00038                 toSplit = helpString;
00039         }
00040         pieces.push_back(toSplit);
00041         return 0;
00042 }
00043 
00044 int string2int(std::string stringValue) 
00045 { 
00046     std::stringstream ssStream(stringValue); 
00047     int iReturn; 
00048     ssStream >> iReturn; 
00049 
00050     return iReturn; 
00051 } 
00052 
00053 std::string int2string(int iValue) 
00054 { 
00055     std::stringstream ssStream; 
00056     ssStream << iValue; 
00057     return ssStream.str(); 
00058 }
00059 
00060 std::string upcase(std::string val)
00061 {
00062         for (unsigned int i = 0; i < val.length(); i++)
00063                 val[i] = toupper(val[i]);
00064         return val;
00065 
00066 }

Generated on Tue Jul 17 22:02:22 2007 for C0re by  doxygen 1.5.2