Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ FILE: ../../../flutter/fml/platform/win/native_library_win.cc
FILE: ../../../flutter/fml/platform/win/paths_win.cc
FILE: ../../../flutter/fml/platform/win/wstring_conversion.h
FILE: ../../../flutter/fml/size.h
FILE: ../../../flutter/fml/string_view.cc
FILE: ../../../flutter/fml/string_view.h
FILE: ../../../flutter/fml/string_view_unittest.cc
FILE: ../../../flutter/fml/synchronization/atomic_object.h
FILE: ../../../flutter/fml/synchronization/count_down_latch.cc
FILE: ../../../flutter/fml/synchronization/count_down_latch.h
Expand Down
3 changes: 0 additions & 3 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ source_set("fml") {
"paths.cc",
"paths.h",
"size.h",
"string_view.cc",
"string_view.h",
"synchronization/atomic_object.h",
"synchronization/count_down_latch.cc",
"synchronization/count_down_latch.h",
Expand Down Expand Up @@ -206,7 +204,6 @@ executable("fml_unittests") {
"message_unittests.cc",
"paths_unittests.cc",
"platform/darwin/string_range_sanitization_unittests.mm",
"string_view_unittest.cc",
"synchronization/count_down_latch_unittests.cc",
"synchronization/semaphore_unittest.cc",
"synchronization/thread_annotations_unittest.cc",
Expand Down
5 changes: 2 additions & 3 deletions fml/base32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
#include "flutter/fml/base32.h"

#include <limits>

#include "flutter/fml/macros.h"
#include <string>

namespace fml {

static constexpr char kEncoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";

std::pair<bool, std::string> Base32Encode(StringView input) {
std::pair<bool, std::string> Base32Encode(std::string_view input) {
if (input.empty()) {
return {true, ""};
}
Expand Down
6 changes: 2 additions & 4 deletions fml/base32.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
#ifndef FLUTTER_FML_BASE32_H_
#define FLUTTER_FML_BASE32_H_

#include <string>
#include <string_view>
#include <utility>

#include "flutter/fml/string_view.h"

namespace fml {

std::pair<bool, std::string> Base32Encode(StringView input);
std::pair<bool, std::string> Base32Encode(std::string_view input);

} // namespace fml

Expand Down
19 changes: 10 additions & 9 deletions fml/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,27 @@ CommandLine& CommandLine::operator=(const CommandLine& from) = default;

CommandLine& CommandLine::operator=(CommandLine&& from) = default;

bool CommandLine::HasOption(StringView name, size_t* index) const {
auto it = option_index_.find(name.ToString());
bool CommandLine::HasOption(std::string_view name, size_t* index) const {
auto it = option_index_.find(name.data());
if (it == option_index_.end())
return false;
if (index)
*index = it->second;
return true;
}

bool CommandLine::GetOptionValue(StringView name, std::string* value) const {
bool CommandLine::GetOptionValue(std::string_view name,
std::string* value) const {
size_t index;
if (!HasOption(name, &index))
return false;
*value = options_[index].value;
return true;
}

std::vector<fml::StringView> CommandLine::GetOptionValues(
StringView name) const {
std::vector<fml::StringView> ret;
std::vector<std::string_view> CommandLine::GetOptionValues(
std::string_view name) const {
std::vector<std::string_view> ret;
for (const auto& option : options_) {
if (option.name == name)
ret.push_back(option.value);
Expand All @@ -64,11 +65,11 @@ std::vector<fml::StringView> CommandLine::GetOptionValues(
}

std::string CommandLine::GetOptionValueWithDefault(
StringView name,
StringView default_value) const {
std::string_view name,
std::string_view default_value) const {
size_t index;
if (!HasOption(name, &index))
return default_value.ToString();
return {default_value.data(), default_value.size()};
return options_[index].value;
}

Expand Down
12 changes: 6 additions & 6 deletions fml/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

#include <initializer_list>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>

#include "flutter/fml/macros.h"
#include "flutter/fml/string_view.h"

namespace fml {

Expand Down Expand Up @@ -108,21 +108,21 @@ class CommandLine final {
// Returns true if this command line has the option |name| (and if |index| is
// non-null, sets |*index| to the index of the *last* occurrence of the given
// option in |options()|) and false if not.
bool HasOption(StringView name, size_t* index = nullptr) const;
bool HasOption(std::string_view name, size_t* index = nullptr) const;

// Gets the value of the option |name|. Returns true (and sets |*value|) on
// success and false (leaving |*value| alone) on failure.
bool GetOptionValue(StringView name, std::string* value) const;
bool GetOptionValue(std::string_view name, std::string* value) const;

// Gets all values of the option |name|. Returns all values, which may be
// empty if the option is not specified.
std::vector<StringView> GetOptionValues(StringView name) const;
std::vector<std::string_view> GetOptionValues(std::string_view name) const;

// Gets the value of the option |name|, with a default if the option is not
// specified. (Note: This doesn't return a const reference, since this would
// make the |default_value| argument inconvenient/dangerous.)
std::string GetOptionValueWithDefault(StringView name,
StringView default_value) const;
std::string GetOptionValueWithDefault(std::string_view name,
std::string_view default_value) const;

private:
bool has_argv0_ = false;
Expand Down
3 changes: 2 additions & 1 deletion fml/command_line_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "flutter/fml/command_line.h"

#include <string_view>
#include <utility>

#include "flutter/fml/macros.h"
Expand Down Expand Up @@ -315,7 +316,7 @@ TEST(CommandLineTest, MultipleOccurrencesOfOption) {
CommandLine::Option("flag1", "value3")};
EXPECT_EQ("value3", cl.GetOptionValueWithDefault("flag1", "nope"));
EXPECT_EQ("value2", cl.GetOptionValueWithDefault("flag2", "nope"));
std::vector<StringView> values = cl.GetOptionValues("flag1");
std::vector<std::string_view> values = cl.GetOptionValues("flag1");
ASSERT_EQ(2u, values.size());
EXPECT_EQ("value1", values[0]);
EXPECT_EQ("value3", values[1]);
Expand Down
212 changes: 0 additions & 212 deletions fml/string_view.cc

This file was deleted.

Loading