aboutsummaryrefslogtreecommitdiff
path: root/absl/strings/internal/str_format/bind.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2023-12-05 14:15:15 -0800
committerCopybara-Service <copybara-worker@google.com>2023-12-05 14:15:57 -0800
commit5dc2cc1a6a992e09d9cf930cdce7984640e2b7e0 (patch)
treea02601dddbd8a5ccbe63fdc5fee787d37cf103ed /absl/strings/internal/str_format/bind.cc
parent3e6ecec7d3c9c504c9951b34230b22527758e0cd (diff)
downloadabseil-5dc2cc1a6a992e09d9cf930cdce7984640e2b7e0.tar.gz
abseil-5dc2cc1a6a992e09d9cf930cdce7984640e2b7e0.tar.bz2
abseil-5dc2cc1a6a992e09d9cf930cdce7984640e2b7e0.zip
Adds support for wchar_t/wchar_t*/std::wstring{_view} arguments to StrFormat().
This converts to UTF-8 regardless of locale. PiperOrigin-RevId: 588186076 Change-Id: I2c9598279b413d460e13ad65da2ba421c0b40b83
Diffstat (limited to 'absl/strings/internal/str_format/bind.cc')
-rw-r--r--absl/strings/internal/str_format/bind.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/absl/strings/internal/str_format/bind.cc b/absl/strings/internal/str_format/bind.cc
index 77a42223..87e23b56 100644
--- a/absl/strings/internal/str_format/bind.cc
+++ b/absl/strings/internal/str_format/bind.cc
@@ -14,10 +14,24 @@
#include "absl/strings/internal/str_format/bind.h"
+#include <algorithm>
+#include <cassert>
#include <cerrno>
+#include <cstddef>
+#include <cstdio>
+#include <ios>
#include <limits>
+#include <ostream>
#include <sstream>
#include <string>
+#include "absl/base/config.h"
+#include "absl/base/optimization.h"
+#include "absl/strings/internal/str_format/arg.h"
+#include "absl/strings/internal/str_format/constexpr_parser.h"
+#include "absl/strings/internal/str_format/extension.h"
+#include "absl/strings/internal/str_format/output.h"
+#include "absl/strings/string_view.h"
+#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -90,6 +104,8 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound,
} else {
FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound);
}
+
+ FormatConversionSpecImplFriend::SetLengthMod(unbound->length_mod, bound);
} else {
FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound);
FormatConversionSpecImplFriend::SetWidth(-1, bound);
@@ -215,7 +231,7 @@ std::string& AppendPack(std::string* out, const UntypedFormatSpecImpl format,
return *out;
}
-std::string FormatPack(const UntypedFormatSpecImpl format,
+std::string FormatPack(UntypedFormatSpecImpl format,
absl::Span<const FormatArgImpl> args) {
std::string out;
if (ABSL_PREDICT_FALSE(!FormatUntyped(&out, format, args))) {