MCPcopy Create free account
hub / github.com/comaps/comaps / CharData

Method CharData

libs/kml/serdes.cpp:1056–1405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1054}
1055
1056void KmlParser::CharData(std::string & value)
1057{
1058 strings::Trim(value);
1059
1060 size_t const count = m_tags.size();
1061 if (count > 1 && !value.empty())
1062 {
1063 using namespace std;
1064 string const & currTag = m_tags[count - 1];
1065 string const & prevTag = m_tags[count - 2];
1066 string_view const ppTag = count > 2 ? m_tags[count - 3] : string_view{};
1067 string_view const pppTag = count > 3 ? m_tags[count - 4] : string_view{};
1068 string_view const ppppTag = count > 4 ? m_tags[count - 5] : string_view{};
1069
1070 auto const TrackTag = [this, &prevTag, &currTag, &value]()
1071 {
1072 if (!IsTrack(prevTag))
1073 return false;
1074
1075 if (IsTimestamp(currTag))
1076 {
1077 auto & timestamps = m_geometry.m_timestamps;
1078 ASSERT(!timestamps.empty(), ());
1079 timestamps.back().emplace_back(base::StringToTimestamp(value));
1080 }
1081 else if (IsCoord(currTag))
1082 {
1083 auto & lines = m_geometry.m_lines;
1084 ASSERT(!lines.empty(), ());
1085 ParseAndAddPoints(lines.back(), value, "\n\r\t", " ");
1086 }
1087 return true;
1088 };
1089
1090 if (prevTag == kDocument)
1091 {
1092 if (currTag == "name")
1093 m_categoryData->m_name[kDefaultLang] = value;
1094 else if (currTag == "description")
1095 m_categoryData->m_description[kDefaultLang] = value;
1096 else if (currTag == "visibility")
1097 m_categoryData->m_visible = value != "0";
1098 }
1099 else if ((prevTag == kExtendedData && ppTag == kDocument) ||
1100 (prevTag == kCompilation && ppTag == kExtendedData && pppTag == kDocument))
1101 {
1102 if (currTag == "mwm:author")
1103 {
1104 m_categoryData->m_authorName = value;
1105 m_categoryData->m_authorId = m_attrId;
1106 m_attrId.clear();
1107 }
1108 else if (currTag == "mwm:lastModified")
1109 {
1110 auto const ts = base::StringToTimestamp(value);
1111 if (ts != base::INVALID_TIME_STAMP)
1112 m_categoryData->m_lastModified = TimestampClock::from_time_t(ts);
1113 }

Callers

nothing calls this directly

Calls 15

TrimFunction · 0.85
IsTrackFunction · 0.85
IsTimestampFunction · 0.85
ASSERTFunction · 0.85
StringToTimestampFunction · 0.85
IsCoordFunction · 0.85
to_uintFunction · 0.85
GetIconFunction · 0.85
to_intFunction · 0.85
backMethod · 0.80
HasTypesMappingMethod · 0.80

Tested by

no test coverage detected