Files
2025-12-05 08:54:02 +01:00

59 lines
1.3 KiB
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_sg_sf_string
#define tools_sg_sf_string
#include "sf"
#include "../HEADER"
namespace tools {
namespace sg {
class sf_string : public bsf<std::string> {
TOOLS_HEADER(sf_string,tools::sg::sf_string,bsf<std::string>)
public:
virtual bool write(io::iwbuf& a_buffer) {
return a_buffer.write_cstr(m_value.c_str());
}
virtual bool read(io::irbuf& a_buffer) {
char* cstr = 0;
if(!a_buffer.read_cstr(cstr)) return false;
m_value = cstr;
::free(cstr);
return true;
}
virtual bool dump(std::ostream& a_out) {
a_out << m_value << std::endl;
return true;
}
virtual bool s_value(std::string& a_s) const {
a_s = m_value;
return true;
}
virtual bool s2value(const std::string& a_s) {
value(a_s);
return true;
}
public:
sf_string():parent(){}
sf_string(const std::string& a_value):parent(a_value){}
virtual ~sf_string(){}
public:
sf_string(const sf_string& a_from):parent(a_from){}
sf_string& operator=(const sf_string& a_from){
parent::operator=(a_from);
return *this;
}
public:
sf_string& operator=(const std::string& a_value){
parent::operator=(a_value);
return *this;
}
};
}}
#endif