Last active
August 29, 2015 14:25
-
-
Save tadamatu/4399a511714c54cf9973 to your computer and use it in GitHub Desktop.
文字列をデリミタで分解しリスト化する関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[cocos2d-x] | |
//文字列をデリミタで分解しリスト化する関数 | |
//str 対象文字列 | |
//delim デリミタ | |
//Return 分解後リスト | |
std::list<std::string> split(std::string str, std::string delim) { | |
std::list<std::string> result; | |
long cutAt; | |
while( (cutAt = str.find_first_of(delim)) != str.npos ) { | |
if(cutAt > 0) { | |
result.push_back(trim(str.substr(0, cutAt))); | |
} | |
str = str.substr(cutAt + 1); | |
} | |
if(str.length() > 0) { | |
result.push_back(trim(str)); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://tadamatu.blogspot.jp/2015/07/cocos2d-xsplit.html