String.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  String.cpp
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: $
00009  *******************************************************************************/
00010 
00011 #include "String.h"
00012 
00013 #define THIS String
00014 
00015 using namespace std;
00016 
00017 THIS::THIS()
00018 {
00019 }
00020 
00021 THIS::~THIS()
00022 {
00023 }
00024 
00025 string THIS::upCase( string text )
00026 {
00027   for (size_t i=0;i<text.length();i++) {
00028     if (text[i] >= 'a' && text[i] <= 'z') {
00029       text[i] += ('A'-'a');
00030     }
00031   }
00032   return text;
00033 }
00034 
00035 string THIS::downCase( string text )
00036 {
00037   for (size_t i=0;i<text.length();i++) {
00038     if (text[i] >= 'A' && text[i] <= 'Z') {
00039       text[i] -= ('A'-'a');
00040     }
00041   }
00042   return text;
00043 }
00044 
00045 std::vector<std::string> THIS::explode (const std::string& text, const std::string& separators, bool keepSeparators)
00046 {
00047   size_t n     = text.length ();
00048   size_t start = text.find_first_not_of (separators);
00049   std::vector<std::string> words;
00050 
00051   while (start < n)
00052   {
00053     size_t stop = text.find_first_of (separators, start);
00054     if (stop > n) stop = n;
00055     if ( keepSeparators )
00056     {
00057       words.push_back (text.substr (start, stop-start+1));
00058     }
00059     else
00060     {
00061       words.push_back (text.substr (start, stop-start));
00062     }
00063     start = text.find_first_not_of (separators, stop+1);
00064   };
00065   return words;
00066 }
00067 
00068 std::string THIS::removeCharacters( std::string text, std::string characters )
00069 {
00070   std::vector<std::string> parts = explode( text, characters, false );
00071 
00072   string result="";
00073   for ( unsigned i=0; i<parts.size(); i++ )
00074   {
00075     result += parts[i];
00076   }
00077 
00078   return result;
00079 }
00080 
00081 
00082 
00083 #undef THIS


robbie_architecture
Author(s): Viktor Seib
autogenerated on Mon Oct 6 2014 02:53:09