mirror of
https://github.com/znc/znc.git
synced 2026-04-30 18:42:25 +02:00
Add CUtils::Get/SetMessageTags()
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user