MCPcopy Create free account
hub / github.com/baidu/tera / IsValidName

Function IsValidName

src/utils/string_util.cc:143–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141const size_t kNameLenMax = 512;
142
143bool IsValidName(const std::string& str) {
144 if (str.size() < kNameLenMin || kNameLenMax < str.size()) {
145 return false;
146 }
147 if (!(isupper(str[0]) || islower(str[0]))) {
148 return false;
149 }
150 for (size_t i = 0; i < str.size(); ++i) {
151 char c = str[i];
152 if (!(isdigit(c) || isupper(c) || islower(c) || (c == '_') || (c == '.') || (c == '-') ||
153 (c == '#'))) {
154 return false;
155 }
156 }
157 return true;
158}
159
160bool IsValidColumnFamilyName(const std::string& str) {
161 if ((64 * 1024 - 1) < str.size()) { // [0, 64KB)

Callers 4

IsValidTableNameFunction · 0.85
IsValidGroupNameFunction · 0.85
IsValidUserNameFunction · 0.85
TESTFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68