tstring.h 656 B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. #include <contrib/libs/yaml-cpp/include/yaml-cpp/yaml.h>
  3. #include <util/generic/string.h>
  4. namespace YAML {
  5. template <>
  6. inline TString Node::as<TString>() const {
  7. const auto& converted = as<std::string>();
  8. return TString(converted.c_str(), converted.size());
  9. }
  10. template <>
  11. struct convert<TString> {
  12. static Node encode(const TString& rhs) {
  13. return Node(std::string(rhs));
  14. }
  15. static bool decode(const Node& node, TString& rhs) {
  16. if (!node.IsScalar())
  17. return false;
  18. rhs = node.Scalar();
  19. return true;
  20. }
  21. };
  22. }