1 // Copyright 2024 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "domatolpm.h" 6 7 namespace domatolpm { 8 view()9std::string_view TextSampleBuilder::view() { 10 return data_; 11 } 12 append(std::string_view v)13void TextSampleBuilder::append(std::string_view v) { 14 data_ += v; 15 } 16 GetBuilder()17SampleBuilder* Context::GetBuilder() { 18 return &builder_; 19 } 20 HasVar(const std::string & var_type)21bool Context::HasVar(const std::string& var_type) { 22 return vars_.count(var_type) > 0; 23 } 24 SetVar(const std::string & var_type,const std::string & var_name)25void Context::SetVar(const std::string& var_type, const std::string& var_name) { 26 vars_[var_type].insert(var_name); 27 } 28 GetVar(const std::string & var_type,int32_t id)29std::string_view Context::GetVar(const std::string& var_type, int32_t id) { 30 id = id % vars_[var_type].size(); 31 return *std::next(std::begin(vars_[var_type]), id); 32 } 33 GetNewID()34std::string Context::GetNewID() { 35 return base::NumberToString(id_++); 36 } 37 38 } // namespace domatolpm 39