Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.4 KiB

  1. //
  2. //-------------------------------------------------------------
  3. // Copyright (c) 1997 Microsoft. All rights reserved.
  4. //
  5. // This is unpublished source code of Microsoft.
  6. // The copyright notice above does not evidence any
  7. // actual or intended publication of such source code.
  8. //-------------------------------------------------------------
  9. //
  10. //-------------------------------------------------------------
  11. // OneLiner: Tokenizer.
  12. // DevUnit:
  13. // Author: Murtaza Hakim
  14. //-------------------------------------------------------------
  15. //-------------------------------------------------------------
  16. // Description:
  17. // ------------
  18. // Gets the tokens in the string.
  19. //
  20. //-------------------------------------------------------------
  21. //
  22. //-------------------------------------------------------------
  23. // include files:
  24. #include "WTokens.h"
  25. #include <stdio.h>
  26. //
  27. //-------------------------------------------------------------
  28. //
  29. //-------------------------------------------------------------
  30. // External References
  31. // none
  32. //-------------------------------------------------------------
  33. //
  34. //-------------------------------------------------------------
  35. // global variables
  36. // none
  37. //-------------------------------------------------------------
  38. //
  39. //-------------------------------------------------------------
  40. // static variables
  41. // none
  42. //-------------------------------------------------------------
  43. //
  44. //-------------------------------------------------------------
  45. // global function declarations
  46. // none
  47. //-------------------------------------------------------------
  48. //
  49. //-------------------------------------------------------------
  50. // static function declarations
  51. // none
  52. //-------------------------------------------------------------
  53. //
  54. // constructor
  55. WTokens::WTokens( wstring strToken, wstring strDelimit )
  56. : _strToken( strToken ), _strDelimit( strDelimit )
  57. {}
  58. //
  59. // default constructor
  60. WTokens::WTokens()
  61. {}
  62. //
  63. // destructor
  64. WTokens::~WTokens()
  65. {}
  66. //
  67. // tokenize
  68. vector<wstring>
  69. WTokens::tokenize()
  70. {
  71. vector<wstring> vecTokens;
  72. wchar_t* token;
  73. token = wcstok( (wchar_t *) _strToken.c_str() , _strDelimit.c_str() );
  74. while( token != NULL )
  75. {
  76. vecTokens.push_back( token );
  77. token = wcstok( NULL, _strDelimit.c_str() );
  78. }
  79. return vecTokens;
  80. }
  81. //
  82. void
  83. WTokens::init(
  84. wstring strToken,
  85. wstring strDelimit )
  86. {
  87. _strToken = strToken;
  88. _strDelimit = strDelimit;
  89. }