| 927 | typename alloc |
| 928 | > |
| 929 | const std::vector<std::basic_string<charT,traits,alloc> > split ( |
| 930 | const std::basic_string<charT,traits,alloc>& str, |
| 931 | const charT* delim = _dT(charT," \n\r\t") |
| 932 | ) |
| 933 | { |
| 934 | std::basic_string<charT,traits,alloc> temp; |
| 935 | |
| 936 | std::vector<std::basic_string<charT,traits,alloc> > res; |
| 937 | |
| 938 | for (unsigned long i = 0; i < str.size(); ++i) |
| 939 | { |
| 940 | // check if delim contains the character str[i] |
| 941 | bool hit = false; |
| 942 | const charT* d = delim; |
| 943 | while (*d != '\0') |
| 944 | { |
| 945 | if (str[i] == *d) |
| 946 | { |
| 947 | hit = true; |
| 948 | break; |
| 949 | } |
| 950 | ++d; |
| 951 | } |
| 952 | |
| 953 | if (hit) |
| 954 | { |
| 955 | if (temp.size() != 0) |
| 956 | { |
| 957 | res.push_back(temp); |
| 958 | temp.clear(); |
| 959 | } |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | temp.push_back(str[i]); |
| 964 | } |
| 965 | } |
| 966 | |
| 967 | if (temp.size() != 0) |
| 968 | res.push_back(temp); |
| 969 | |
| 970 | return res; |
| 971 | } |
| 972 | |
| 973 | template < |
| 974 | typename charT, |