fork download
  1. #include <iostream> /* C++ iostream C++98/11 */
  2. #include <string> /* C++ strings C++98/11 */
  3. #include <boost/algorithm/string.hpp>
  4. #include <map>
  5. #include <set>
  6. #include <vector>
  7.  
  8. int main() {
  9.  
  10. std::map<std::string, std::string> messageFields;
  11. std::string fldStr = "MSGLOG_LIFECYCLE_ID,MSG_TYPE,CLMS_CARD_UID,FLD_002_MASKED,FLD_003,FLD_004::INT,FLD_006::INT,FLD_024,FLD_038,FLD_039,FLD_043,FLD_049,FLD_126";
  12. if (!fldStr.empty()) {
  13. //boost::split(messageFields, fldStr, boost::is_any_of(","));
  14. static std::set<std::string> fields;
  15. boost::split(fields, fldStr, boost::is_any_of(","));
  16. for (auto& fld : fields) {
  17. std::size_t pos = fld.find("::");
  18. if (pos != std::string::npos) {
  19. std::string key = fld.substr(0, pos);
  20. std::string value = fld.substr(pos + 2);
  21. messageFields[key] = value;
  22. } else {
  23. messageFields[fld] = "AUTO";
  24. }
  25. }
  26. }
  27.  
  28. }
  29.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
KEY: FLD_004 VALUE: INT 
KEY: FLD_006 VALUE: INT