Skip to content
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ set(source_files
src/binsrv/time_unit.cpp

# various utility files
src/util/bnf_parser_helpers.hpp

src/util/bounded_string_storage_fwd.hpp
src/util/bounded_string_storage.hpp

Expand Down
3 changes: 1 addition & 2 deletions src/binsrv/ctime_timestamp_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
#ifndef BINSRV_CTIME_TIMESTAMP_FWD_HPP
#define BINSRV_CTIME_TIMESTAMP_FWD_HPP

#include <istream>
#include <ostream>
#include <iosfwd>

#include "util/nv_tuple_json_support.hpp"

Expand Down
27 changes: 21 additions & 6 deletions src/binsrv/gtids/gtid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

#include "binsrv/gtids/gtid.hpp"

#include <cstddef>
#include <limits>
#include <ostream>
#include <stdexcept>
#include <string>

#include "binsrv/gtids/common_types.hpp"
#include "binsrv/gtids/tag_fwd.hpp"
Expand All @@ -26,6 +29,23 @@

namespace binsrv::gtids {

[[nodiscard]] std::string gtid::str() const {
std::string result;
static constexpr std::size_t gno_str_max_length{
std::numeric_limits<gno_t>::digits10 + 1U};

result.reserve(uuid::readable_size + (has_tag() ? tag_.get_size() + 1U : 0U) +
1U + gno_str_max_length);
result += uuid_.str();
if (has_tag()) {
result += component_separator;
result += tag_.get_name();
}
result += component_separator;
result += std::to_string(gno_);
return result;
}

void gtid::validate_components(const uuid &uuid_component,
const tag & /*tag_component*/,
gno_t gno_component) {
Expand All @@ -40,12 +60,7 @@ void gtid::validate_components(const uuid &uuid_component,
}

std::ostream &operator<<(std::ostream &output, const gtid &obj) {
output << obj.get_uuid();
if (obj.has_tag()) {
output << gtid::tag_separator << obj.get_tag();
}
output << gtid::gno_separator << obj.get_gno();
return output;
return output << obj.str();
}

} // namespace binsrv::gtids
5 changes: 3 additions & 2 deletions src/binsrv/gtids/gtid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace binsrv::gtids {

class gtid {
public:
static constexpr char tag_separator{':'};
static constexpr char gno_separator{':'};
static constexpr char component_separator{':'};

gtid() = default;

Expand All @@ -52,6 +51,8 @@ class gtid {

[[nodiscard]] gno_t get_gno() const noexcept { return gno_; }

[[nodiscard]] std::string str() const;

[[nodiscard]] friend bool operator==(const gtid &first,
const gtid &second) noexcept = default;

Expand Down
Loading