MCPcopy Create free account
hub / github.com/apache/impala / SubstitutedSize

Function SubstitutedSize

be/src/gutil/strings/substitute.cc:29–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28namespace internal {
29int SubstitutedSize(StringPiece format,
30 const SubstituteArg* const* args_array) {
31 int size = 0;
32 for (int i = 0; i < format.size(); i++) {
33 if (format[i] == '$') {
34 if (i+1 >= format.size()) {
35 LOG(DFATAL) << "Invalid strings::Substitute() format string: \""
36 << CEscape(format) << "\".";
37 return 0;
38 } else if (ascii_isdigit(format[i+1])) {
39 int index = format[i+1] - '0';
40 if (args_array[index]->size() == -1) {
41 LOG(DFATAL)
42 << "strings::Substitute format string invalid: asked for \"$"
43 << index << "\", but only " << CountSubstituteArgs(args_array)
44 << " args were given. Full format string was: \""
45 << CEscape(format) << "\".";
46 return 0;
47 }
48 size += args_array[index]->size();
49 ++i; // Skip next char.
50 } else if (format[i+1] == '$') {
51 ++size;
52 ++i; // Skip next char.
53 } else {
54 LOG(DFATAL) << "Invalid strings::Substitute() format string: \""
55 << CEscape(format) << "\".";
56 return 0;
57 }
58 } else {
59 ++size;
60 }
61 }
62 return size;
63}
64
65char* SubstituteToBuffer(StringPiece format,
66 const SubstituteArg* const* args_array,

Callers 2

SubstituteAndTraceMethod · 0.85
SubstituteAndAppendFunction · 0.85

Calls 4

CEscapeFunction · 0.85
ascii_isdigitFunction · 0.85
CountSubstituteArgsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected