daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //AMENDMENT: USE A INTRUSIVE CONTAINER (NOT A std::wstring OBJECT) TO REDUCE MEMORY OVERHEAD
  2.  
  3. //Tokenizes a buffer string using white spaces and quotes as delimiters
  4. //cbf conjoining string tokens atm
  5.  
  6. #define MAX_TOKENS 128
  7. #define MAX_TOKEN_LEN 256
  8.  
  9. size_t Tokenize(LPCWSTR lpcwszBuffer, boost::scoped_array<WCHAR>* lppwszTokens)
  10. {
  11.    size_t nTokens = 0;
  12.  
  13.    if (lpcwszBuffer == NULL)
  14.       return nTokens;
  15.  
  16.    boost::char_separator<WCHAR> Delimiters(L" ", L"\"");
  17.  
  18. //AMENDMENT: FIX THIS SHIT, NIGGER
  19.    //undesired...
  20.    std::wstring wsBuffer = lpcwszBuffer;
  21.    //i'm not even gonna bother using hungarian notation on this bitch...
  22.    boost::tokenizer<boost::char_separator<WCHAR>, std::wstring::const_iterator, std::wstring> Tokens(wsBuffer, Delimiters);
  23.  
  24.    BOOST_FOREACH(std::wstring Token, Tokens)
  25.    {
  26.       StringCchCopy(lppwszTokens[nTokens++].get(), MAX_TOKEN_LEN, Token.c_str());
  27.    }
  28.  
  29.    return nTokens;
  30. }
RAW Paste Data
Top