-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat chaotic: more stuff for openapi parameters
commit_hash:33b332173cadcb98aee398cc4d24484abff1dbf5
- Loading branch information
Showing
8 changed files
with
398 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <userver/chaotic/openapi/parameters_read.hpp> | ||
|
||
#include <stdexcept> | ||
|
||
#include <boost/algorithm/string/split.hpp> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace chaotic::openapi { | ||
|
||
namespace impl { | ||
|
||
void SplitByDelimiter(std::string_view str, char delimiter, utils::function_ref<void(std::string)> func) { | ||
for (auto it = boost::algorithm::make_split_iterator(str, boost::token_finder([delimiter](char c) { | ||
return c == delimiter; | ||
})); | ||
it != decltype(it){}; | ||
++it) { | ||
func(std::string{it->begin(), it->end()}); | ||
} | ||
} | ||
|
||
} // namespace impl | ||
|
||
std::string FromStr(std::string&& str_value, parse::To<std::string>) { return std::move(str_value); } | ||
|
||
bool FromStr(std::string&& str_value, parse::To<bool>) { | ||
if (str_value == "true") return true; | ||
if (str_value == "false") return false; | ||
throw std::runtime_error("Unknown bool value: " + str_value); | ||
} | ||
|
||
double FromStr(std::string&& str_value, parse::To<double>) { return utils::FromString<double>(str_value); } | ||
|
||
} // namespace chaotic::openapi | ||
|
||
USERVER_NAMESPACE_END |
Oops, something went wrong.