Rename typefdefs for C++17
These typedefs are no longer necessary:
base::char16 -> char16_t
base::string16 -> std::u16string
base::StringPiece -> std::string_view
base::StringPiece16 -> std::u16string_view
There should be no behavior change since the objects are already the
C++17 types.
Change-Id: I482a9371bc668e72d12811c17b4f1128715ea62a
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/6060
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h
index d91bead..f3030f2 100644
--- a/base/json/json_value_converter.h
+++ b/base/json/json_value_converter.h
@@ -9,13 +9,12 @@
#include <memory>
#include <string>
+#include <string_view>
#include <vector>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "base/strings/string16.h"
-#include "base/strings/string_piece.h"
#include "base/values.h"
// JSONValueConverter converts a JSON value into a C++ struct in a
@@ -70,8 +69,8 @@
//
// Sometimes JSON format uses string representations for other types such
// like enum, timestamp, or URL. You can use RegisterCustomField method
-// and specify a function to convert a StringPiece to your type.
-// bool ConvertFunc(StringPiece s, YourEnum* result) {
+// and specify a function to convert a std::string_view to your type.
+// bool ConvertFunc(std::string_view s, YourEnum* result) {
// // do something and return true if succeed...
// }
// struct Message {
@@ -158,11 +157,12 @@
};
template <>
-class BasicValueConverter<string16> : public ValueConverter<string16> {
+class BasicValueConverter<std::u16string>
+ : public ValueConverter<std::u16string> {
public:
BasicValueConverter() = default;
- bool Convert(const base::Value& value, string16* field) const override;
+ bool Convert(const base::Value& value, std::u16string* field) const override;
private:
DISALLOW_COPY_AND_ASSIGN(BasicValueConverter);
@@ -211,7 +211,7 @@
template <typename FieldType>
class CustomFieldConverter : public ValueConverter<FieldType> {
public:
- typedef bool (*ConvertFunc)(StringPiece value, FieldType* field);
+ typedef bool (*ConvertFunc)(std::string_view value, FieldType* field);
explicit CustomFieldConverter(ConvertFunc convert_func)
: convert_func_(convert_func) {}
@@ -367,10 +367,11 @@
}
void RegisterStringField(const std::string& field_name,
- string16 StructType::*field) {
+ std::u16string StructType::*field) {
fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, string16>>(
- field_name, field, new internal::BasicValueConverter<string16>));
+ std::make_unique<internal::FieldConverter<StructType, std::u16string>>(
+ field_name, field,
+ new internal::BasicValueConverter<std::u16string>));
}
void RegisterBoolField(const std::string& field_name,
@@ -398,7 +399,7 @@
template <typename FieldType>
void RegisterCustomField(const std::string& field_name,
FieldType StructType::*field,
- bool (*convert_func)(StringPiece, FieldType*)) {
+ bool (*convert_func)(std::string_view, FieldType*)) {
fields_.push_back(
std::make_unique<internal::FieldConverter<StructType, FieldType>>(
field_name, field,
@@ -436,10 +437,12 @@
void RegisterRepeatedString(
const std::string& field_name,
- std::vector<std::unique_ptr<string16>> StructType::*field) {
- fields_.push_back(std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<string16>>>>(
- field_name, field, new internal::RepeatedValueConverter<string16>));
+ std::vector<std::unique_ptr<std::u16string>> StructType::*field) {
+ fields_.push_back(
+ std::make_unique<internal::FieldConverter<
+ StructType, std::vector<std::unique_ptr<std::u16string>>>>(
+ field_name, field,
+ new internal::RepeatedValueConverter<std::u16string>));
}
void RegisterRepeatedDouble(