Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stringUtils.cpp Source File

stringUtils.cpp

00001 
00002 
00003 #include "stringUtils.h"
00004 
00005 using namespace std;
00006 
00007 string trim(const string& src, const string& c)
00008 {
00009     int p2 = src.find_last_not_of(c);
00010     if (p2 == string::npos) 
00011     {
00012         return string();
00013     }
00014     
00015     int p1 = src.find_first_not_of(c);
00016     if (p1 == string::npos) 
00017     {
00018         p1 = 0;
00019     }
00020     
00021     return src.substr(p1, (p2-p1)+1);
00022 }
00023 
00024 vector<string> tokenize(const string& str, const string& delimiters)
00025 {
00026     vector<string> tokens;
00027 
00028     // Skip delimiters at beginning.
00029     string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00030     // Find first "non-delimiter".
00031     string::size_type pos     = str.find_first_of(delimiters, lastPos);
00032 
00033     while (string::npos != pos || string::npos != lastPos)
00034     {
00035         // Found a token, add it to the vector.
00036         tokens.push_back(str.substr(lastPos, pos - lastPos));
00037         // Skip delimiters.  Note the "not_of"
00038         lastPos = str.find_first_not_of(delimiters, pos);
00039         // Find next "non-delimiter"
00040         pos = str.find_first_of(delimiters, lastPos);
00041     }
00042     
00043     return tokens;
00044 }