Add CUtils::Get/SetMessageTags()

This commit is contained in:
J-P Nurmi
2014-03-02 01:56:26 +01:00
parent 0a0be7710f
commit 5f8f747704
2 changed files with 34 additions and 0 deletions

View File

@@ -459,6 +459,37 @@ SCString CUtils::GetTimezones() {
return result;
}
MCString CUtils::GetMessageTags(const CString& sLine) {
if (sLine.StartsWith("@")) {
VCString vsTags;
sLine.Token(0).TrimPrefix_n("@").Split(";", vsTags, false);
MCString mssTags;
for (VCString::const_iterator it = vsTags.begin(); it != vsTags.end(); ++it) {
mssTags[it->Token(0, false, "=")] = it->Token(1, true, "=");
}
return mssTags;
}
return MCString::EmptyMap;
}
void CUtils::SetMessageTags(CString& sLine, const MCString& mssTags) {
if (sLine.StartsWith("@")) {
sLine.LeftChomp(sLine.Token(0).length() + 1);
}
if (!mssTags.empty()) {
CString sTags;
for (MCString::const_iterator it = mssTags.begin(); it != mssTags.end(); ++it) {
if (!sTags.empty()) {
sTags += ";";
}
sTags += it->first + "=" + it->second;
}
sLine = "@" + sTags + " " + sLine;
}
}
bool CTable::AddColumn(const CString& sName) {
for (unsigned int a = 0; a < m_vsHeaders.size(); a++) {
if (m_vsHeaders[a].Equals(sName)) {