Guest User

Untitled

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // @eyny@Force[TW]@
  2. #include "forcetw20101226b001.h"
  3. //
  4. CStrTok::CStrTok(void)
  5. {
  6. this->m_str.clear();
  7. this->m_token = NULL;
  8. this->m_vstr.clear();
  9. }
  10. CStrTok::CStrTok(const string str)
  11. {
  12. if ( str.empty() )
  13. {
  14. return;
  15. }
  16. stringstream ss(str);
  17. ss >> this->m_str;
  18. ss >> this->m_token;
  19. this->m_vstr.clear();
  20. this->Token();
  21. }
  22. CStrTok::~CStrTok(void)
  23. {
  24. this->m_str.clear();
  25. this->m_token = NULL;
  26. this->m_vstr.clear();
  27. }
  28. void CStrTok::setString(const string str)
  29. {
  30. if ( str.empty() )
  31. {
  32. return;
  33. }
  34. stringstream ss(str);
  35. ss >> this->m_str;
  36. ss >> this->m_token;
  37. this->m_vstr.clear();
  38. this->Token();
  39. }
  40. void CStrTok::Token(void)
  41. {
  42. if ( this->m_str.empty() )
  43. {
  44. return;
  45. }
  46. string buffer = this->m_str;
  47. unsigned int i = 0;
  48. for (; i < buffer.size(); i ++)
  49. {
  50. if ( buffer[i] == this->m_token )
  51. {
  52. buffer[i] = ' ';
  53. }
  54. }
  55. stringstream ss(buffer);
  56. buffer.clear();
  57. while ( ss >> buffer )
  58. {
  59. this->m_vstr.push_back(buffer);
  60. }
  61. }
  62. void CStrTok::Print(void)
  63. {
  64. if ( this->m_vstr.empty() )
  65. {
  66. return;
  67. }
  68. for (vStr::iterator it = this->m_vstr.begin(); it != this->m_vstr.end(); it ++)
  69. {
  70. cout << (*it) << endl;
  71. }
  72. }
Add Comment
Please, Sign In to add comment