extension.cc
Go to the documentation of this file.
00001 //
00002 // Copyright 2017 The Abseil Authors.
00003 //
00004 // Licensed under the Apache License, Version 2.0 (the "License");
00005 // you may not use this file except in compliance with the License.
00006 // You may obtain a copy of the License at
00007 //
00008 //      https://www.apache.org/licenses/LICENSE-2.0
00009 //
00010 // Unless required by applicable law or agreed to in writing, software
00011 // distributed under the License is distributed on an "AS IS" BASIS,
00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 // See the License for the specific language governing permissions and
00014 // limitations under the License.
00015 
00016 #include "absl/strings/internal/str_format/extension.h"
00017 
00018 #include <errno.h>
00019 #include <algorithm>
00020 #include <string>
00021 
00022 namespace absl {
00023 namespace str_format_internal {
00024 namespace {
00025 // clang-format off
00026 #define ABSL_LENGTH_MODS_EXPAND_ \
00027   X_VAL(h) X_SEP \
00028   X_VAL(hh) X_SEP \
00029   X_VAL(l) X_SEP \
00030   X_VAL(ll) X_SEP \
00031   X_VAL(L) X_SEP \
00032   X_VAL(j) X_SEP \
00033   X_VAL(z) X_SEP \
00034   X_VAL(t) X_SEP \
00035   X_VAL(q)
00036 // clang-format on
00037 }  // namespace
00038 
00039 const LengthMod::Spec LengthMod::kSpecs[] = {
00040 #define X_VAL(id) { LengthMod::id, #id, strlen(#id) }
00041 #define X_SEP ,
00042     ABSL_LENGTH_MODS_EXPAND_, {LengthMod::none, "", 0}
00043 #undef X_VAL
00044 #undef X_SEP
00045 };
00046 
00047 const ConversionChar::Spec ConversionChar::kSpecs[] = {
00048 #define X_VAL(id) { ConversionChar::id, #id[0] }
00049 #define X_SEP ,
00050     ABSL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP),
00051     {ConversionChar::none, '\0'},
00052 #undef X_VAL
00053 #undef X_SEP
00054 };
00055 
00056 std::string Flags::ToString() const {
00057   std::string s;
00058   s.append(left     ? "-" : "");
00059   s.append(show_pos ? "+" : "");
00060   s.append(sign_col ? " " : "");
00061   s.append(alt      ? "#" : "");
00062   s.append(zero     ? "0" : "");
00063   return s;
00064 }
00065 
00066 const size_t LengthMod::kNumValues;
00067 
00068 const size_t ConversionChar::kNumValues;
00069 
00070 bool FormatSinkImpl::PutPaddedString(string_view v, int w, int p, bool l) {
00071   size_t space_remaining = 0;
00072   if (w >= 0) space_remaining = w;
00073   size_t n = v.size();
00074   if (p >= 0) n = std::min(n, static_cast<size_t>(p));
00075   string_view shown(v.data(), n);
00076   space_remaining = Excess(shown.size(), space_remaining);
00077   if (!l) Append(space_remaining, ' ');
00078   Append(shown);
00079   if (l) Append(space_remaining, ' ');
00080   return true;
00081 }
00082 
00083 }  // namespace str_format_internal
00084 }  // namespace absl


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:14