| 808 | } |
| 809 | |
| 810 | std::string JoinStringEnvStyle(const StringUtils::StringVec & outputvec) |
| 811 | { |
| 812 | std::string result; |
| 813 | const int nElement = static_cast<int>(outputvec.size()); |
| 814 | if( nElement == 0 ) |
| 815 | { |
| 816 | return ""; |
| 817 | } |
| 818 | |
| 819 | // Check if the value contains a symbol that could be interpreted as a separator |
| 820 | // and if it is not already surrounded by quotes. |
| 821 | const std::string& firstValue = outputvec[0]; |
| 822 | if( firstValue.find_first_of(",:") != std::string::npos && |
| 823 | firstValue.size() > 1 && |
| 824 | firstValue[0] != '"' && |
| 825 | firstValue[firstValue.size() - 1] != '"' ) |
| 826 | { |
| 827 | result += "\"" + firstValue + "\""; |
| 828 | } |
| 829 | else |
| 830 | { |
| 831 | result += firstValue; |
| 832 | } |
| 833 | |
| 834 | for( int i = 1; i < nElement; ++i ) |
| 835 | { |
| 836 | if( outputvec[i].find_first_of(",:") != std::string::npos && |
| 837 | outputvec[i].size() > 1 && |
| 838 | outputvec[i][0] != '"' && |
| 839 | outputvec[i][outputvec[i].size() - 1] != '"' ) |
| 840 | { |
| 841 | result += ", \"" + outputvec[i] + "\""; |
| 842 | } |
| 843 | else |
| 844 | { |
| 845 | result += ", " + outputvec[i]; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | return result; |
| 850 | } |
| 851 | |
| 852 | // Return a vector of strings that are both in vec1 and vec2. |
| 853 | // Case is ignored to find strings. |