Browse Source

update: using `std::string_view` instead of `std::string`

master
Dnomd343 6 months ago
parent
commit
cade87e93f
  1. 4
      src/core/common_code/common_code.h
  2. 4
      src/core/common_code/internal/common_code.inl
  3. 2
      src/core/raw_code/internal/raw_code.inl
  4. 2
      src/core/raw_code/raw_code.h
  5. 4
      src/core/short_code/internal/short_code.inl
  6. 4
      src/core/short_code/short_code.h

4
src/core/common_code/common_code.h

@ -116,7 +116,7 @@ public:
// ------------------------------------------------------------------------------------- //
/// Create CommonCode from string form.
static std::optional<CommonCode> from_string(const std::string &common_code);
static std::optional<CommonCode> from_string(std::string_view common_code);
// ------------------------------------------------------------------------------------- //
@ -135,7 +135,7 @@ public:
static std::optional<CommonCode> from_short_code(uint32_t short_code);
/// Create CommonCode from ShortCode in string form.
static std::optional<CommonCode> from_short_code(const std::string &short_code);
static std::optional<CommonCode> from_short_code(std::string_view short_code);
// ------------------------------------------------------------------------------------- //

4
src/core/common_code/internal/common_code.inl

@ -64,7 +64,7 @@ inline std::string CommonCode::to_string(const bool shorten) const {
// ------------------------------------------------------------------------------------- //
inline std::optional<CommonCode> CommonCode::from_string(const std::string &common_code) {
inline std::optional<CommonCode> CommonCode::from_string(const std::string_view common_code) {
return string_decode(common_code).transform(unsafe_create);
}
@ -94,7 +94,7 @@ inline std::optional<CommonCode> CommonCode::from_short_code(const uint32_t shor
return ShortCode::create(short_code).transform(convert);
}
inline std::optional<CommonCode> CommonCode::from_short_code(const std::string &short_code) {
inline std::optional<CommonCode> CommonCode::from_short_code(const std::string_view short_code) {
const auto convert = [](const ShortCode code) {
return code.to_common_code();
};

2
src/core/raw_code/internal/raw_code.inl

@ -50,7 +50,7 @@ inline std::optional<RawCode> RawCode::from_common_code(const uint64_t common_co
return CommonCode::create(common_code).transform(convert);
}
inline std::optional<RawCode> RawCode::from_common_code(const std::string &common_code) {
inline std::optional<RawCode> RawCode::from_common_code(const std::string_view common_code) {
const auto convert = [](const CommonCode code) {
return code.to_raw_code();
};

2
src/core/raw_code/raw_code.h

@ -115,7 +115,7 @@ public:
static std::optional<RawCode> from_common_code(uint64_t common_code);
/// Create RawCode from CommonCode in string form.
static std::optional<RawCode> from_common_code(const std::string &common_code);
static std::optional<RawCode> from_common_code(std::string_view common_code);
// ------------------------------------------------------------------------------------- //

4
src/core/short_code/internal/short_code.inl

@ -73,7 +73,7 @@ inline CommonCode ShortCode::to_common_code() const {
// ----------------------------------------------------------------------------------------- //
inline std::optional<ShortCode> ShortCode::from_string(const std::string &short_code) {
inline std::optional<ShortCode> ShortCode::from_string(const std::string_view short_code) {
return string_decode(short_code).transform(unsafe_create);
}
@ -90,7 +90,7 @@ inline std::optional<ShortCode> ShortCode::from_common_code(const uint64_t commo
return CommonCode::create(common_code).transform(convert);
}
inline std::optional<ShortCode> ShortCode::from_common_code(const std::string &common_code) {
inline std::optional<ShortCode> ShortCode::from_common_code(const std::string_view common_code) {
const auto convert = [](const CommonCode code) {
return code.to_short_code();
};

4
src/core/short_code/short_code.h

@ -126,7 +126,7 @@ public:
// ------------------------------------------------------------------------------------- //
/// Create ShortCode from string form.
static std::optional<ShortCode> from_string(const std::string &short_code);
static std::optional<ShortCode> from_string(std::string_view short_code);
// ------------------------------------------------------------------------------------- //
@ -137,7 +137,7 @@ public:
static std::optional<ShortCode> from_common_code(uint64_t common_code);
/// Create ShortCode from CommonCode in string form.
static std::optional<ShortCode> from_common_code(const std::string &common_code);
static std::optional<ShortCode> from_common_code(std::string_view common_code);
// ------------------------------------------------------------------------------------- //

Loading…
Cancel
Save