Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @eyny@Force[TW]@
- #include "forcetw20101226b001.h"
- //
- CStrTok::CStrTok(void)
- {
- this->m_str.clear();
- this->m_token = NULL;
- this->m_vstr.clear();
- }
- CStrTok::CStrTok(const string str)
- {
- if ( str.empty() )
- {
- return;
- }
- stringstream ss(str);
- ss >> this->m_str;
- ss >> this->m_token;
- this->m_vstr.clear();
- this->Token();
- }
- CStrTok::~CStrTok(void)
- {
- this->m_str.clear();
- this->m_token = NULL;
- this->m_vstr.clear();
- }
- void CStrTok::setString(const string str)
- {
- if ( str.empty() )
- {
- return;
- }
- stringstream ss(str);
- ss >> this->m_str;
- ss >> this->m_token;
- this->m_vstr.clear();
- this->Token();
- }
- void CStrTok::Token(void)
- {
- if ( this->m_str.empty() )
- {
- return;
- }
- string buffer = this->m_str;
- unsigned int i = 0;
- for (; i < buffer.size(); i ++)
- {
- if ( buffer[i] == this->m_token )
- {
- buffer[i] = ' ';
- }
- }
- stringstream ss(buffer);
- buffer.clear();
- while ( ss >> buffer )
- {
- this->m_vstr.push_back(buffer);
- }
- }
- void CStrTok::Print(void)
- {
- if ( this->m_vstr.empty() )
- {
- return;
- }
- for (vStr::iterator it = this->m_vstr.begin(); it != this->m_vstr.end(); it ++)
- {
- cout << (*it) << endl;
- }
- }
Add Comment
Please, Sign In to add comment