Replace rtc::Optional with absl::optional in rtc_base
This is a no-op change because rtc::Optional is an alias to absl::optional
This CL generated by running script with parameter 'rtc_base'
Then manually fix where Optional was used without rtc prefix (patchset#3)
find $@ -type f \( -name \*.h -o -name \*.cc \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+
find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;
git cl format
Bug: webrtc:9078
Change-Id: I825f80cc8089747876ba6316d9e7c30e05716974
Reviewed-on: https://webrtc-review.googlesource.com/84585
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23700}
diff --git a/rtc_base/experiments/field_trial_parser.h b/rtc_base/experiments/field_trial_parser.h
index ba60499..ff00b90 100644
--- a/rtc_base/experiments/field_trial_parser.h
+++ b/rtc_base/experiments/field_trial_parser.h
@@ -13,7 +13,7 @@
#include <stdint.h>
#include <initializer_list>
#include <string>
-#include "api/optional.h"
+#include "absl/types/optional.h"
// Field trial parser functionality. Provides funcitonality to parse field trial
// argument strings in key:value format. Each parameter is described using
@@ -39,7 +39,7 @@
friend void ParseFieldTrial(
std::initializer_list<FieldTrialParameterInterface*> fields,
std::string raw_string);
- virtual bool Parse(rtc::Optional<std::string> str_value) = 0;
+ virtual bool Parse(absl::optional<std::string> str_value) = 0;
std::string Key() const;
private:
@@ -52,10 +52,10 @@
std::initializer_list<FieldTrialParameterInterface*> fields,
std::string raw_string);
-// Specialize this in code file for custom types. Should return rtc::nullopt if
+// Specialize this in code file for custom types. Should return absl::nullopt if
// the given string cannot be properly parsed.
template <typename T>
-rtc::Optional<T> ParseTypedParameter(std::string);
+absl::optional<T> ParseTypedParameter(std::string);
// This class uses the ParseTypedParameter function to implement a parameter
// implementation with an enforced default value.
@@ -68,9 +68,9 @@
operator T() const { return Get(); }
protected:
- bool Parse(rtc::Optional<std::string> str_value) override {
+ bool Parse(absl::optional<std::string> str_value) override {
if (str_value) {
- rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
+ absl::optional<T> value = ParseTypedParameter<T>(*str_value);
if (value.has_value()) {
value_ = value.value();
return true;
@@ -84,31 +84,31 @@
};
// This class uses the ParseTypedParameter function to implement an optional
-// parameter implementation that can default to rtc::nullopt.
+// parameter implementation that can default to absl::nullopt.
template <typename T>
class FieldTrialOptional : public FieldTrialParameterInterface {
public:
explicit FieldTrialOptional(std::string key)
: FieldTrialParameterInterface(key) {}
- FieldTrialOptional(std::string key, rtc::Optional<T> default_value)
+ FieldTrialOptional(std::string key, absl::optional<T> default_value)
: FieldTrialParameterInterface(key), value_(default_value) {}
- rtc::Optional<T> Get() const { return value_; }
+ absl::optional<T> Get() const { return value_; }
protected:
- bool Parse(rtc::Optional<std::string> str_value) override {
+ bool Parse(absl::optional<std::string> str_value) override {
if (str_value) {
- rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
+ absl::optional<T> value = ParseTypedParameter<T>(*str_value);
if (!value.has_value())
return false;
value_ = value.value();
} else {
- value_ = rtc::nullopt;
+ value_ = absl::nullopt;
}
return true;
}
private:
- rtc::Optional<T> value_;
+ absl::optional<T> value_;
};
// Equivalent to a FieldTrialParameter<bool> in the case that both key and value
@@ -121,7 +121,7 @@
bool Get() const;
protected:
- bool Parse(rtc::Optional<std::string> str_value) override;
+ bool Parse(absl::optional<std::string> str_value) override;
private:
bool value_;