userver: userver/storages/postgres/detail/db_data_type_name.hpp Source File
Loading...
Searching...
No Matches
db_data_type_name.hpp
1#pragma once
2
3#include <string_view>
4#include <utility>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace storages::postgres::utils {
9
10/// @brief A simple constexpr parser splitting a string by dot.
11/// Doesn't do any checks (yet).
12constexpr std::pair<std::string_view, std::string_view> ParseDBName(
13 std::string_view db_name) {
14 const std::size_t pos = db_name.find('.');
15 if (pos == std::string_view::npos) return {{}, db_name};
16 return {db_name.substr(0, pos), db_name.substr(pos + 1)};
17}
18
19} // namespace storages::postgres::utils
20
21USERVER_NAMESPACE_END