| 777 | } |
| 778 | |
| 779 | std::string CcToUnderline(const std::string& in) { |
| 780 | std::string res; |
| 781 | res.reserve(in.size() * 2); |
| 782 | for (size_t ii = 0; ii < in.size(); ii++) { |
| 783 | if (isupper(in[ii])) { |
| 784 | if (ii > 0) { |
| 785 | res.push_back('_'); |
| 786 | } |
| 787 | res.push_back(tolower(in[ii])); |
| 788 | } else { |
| 789 | res.push_back(in[ii]); |
| 790 | } |
| 791 | } |
| 792 | return res; |
| 793 | } |
| 794 | |
| 795 | /// returns the occurency count of 'toCount' in 'in' |
| 796 | size_t StringCountChar(const std::string& in, const char toCount) { |