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