blob: 8a20d1a1b6d317fd3c1b5b2b00bb9ab8c668720e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tags.h"
#include <vespa/vespalib/stllike/string.h>
namespace configdefinitions {
vespalib::string upcase(const vespalib::string &orig)
{
vespalib::string upper(orig);
for (size_t i = 0; i < orig.size(); ++i) {
int l = (unsigned char)orig[i];
upper[i] = (unsigned char)toupper(l);
}
return upper;
}
bool tagsContain(const vespalib::string &tags, const vespalib::string &tag)
{
vespalib::string allupper = upcase(tags);
vespalib::string tagupper = upcase(tag);
for (;;) {
size_t pos = allupper.rfind(' ');
if (pos == vespalib::string::npos) {
break;
}
if (allupper.substr(pos+1) == tagupper) {
return true;
}
allupper.resize(pos);
}
return (allupper == tagupper);
}
}
|