g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::rroot::leaf_string Class Reference
Inheritance diagram for tools::rroot::leaf_string:
Inheritance graph
[legend]
Collaboration diagram for tools::rroot::leaf_string:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const
 
virtual void * cast (cid a_class) const
 
virtual irocopy () const
 
virtual bool stream (buffer &a_buffer)
 
virtual bool read_buffer (buffer &a_buffer)
 
virtual bool print_value (std::ostream &a_out, uint32) const
 
virtual uint32 num_elem () const
 
 leaf_string (std::ostream &a_out, ifac &a_fac)
 
virtual ~leaf_string ()
 
const char * value () const
 
- Public Member Functions inherited from tools::rroot::base_leaf
 base_leaf (std::ostream &a_out, ifac &a_fac)
 
virtual ~base_leaf ()
 
const std::string & name () const
 
const std::string & title () const
 
const base_leafleaf_count () const
 
- Public Member Functions inherited from tools::rroot::iro
virtual ~iro ()
 

Static Public Member Functions

static const std::string & s_class ()
 
static cid id_class ()
 
- Static Public Member Functions inherited from tools::rroot::base_leaf
static const std::string & s_class ()
 
static cid id_class ()
 

Protected Member Functions

 leaf_string (const leaf_string &a_from)
 
leaf_stringoperator= (const leaf_string &)
 
- Protected Member Functions inherited from tools::rroot::base_leaf
 base_leaf (const base_leaf &a_from)
 
base_leafoperator= (const base_leaf &)
 

Protected Attributes

int m_min
 
int m_max
 
char * m_value
 
- Protected Attributes inherited from tools::rroot::base_leaf
std::ostream & m_out
 
ifacm_fac
 
std::string m_name
 
std::string m_title
 
uint32 m_length
 
uint32 m_length_type
 
bool m_is_range
 
base_leafm_leaf_count
 
bool m_own_leaf_count
 

Detailed Description

Definition at line 207 of file leaf.

Constructor & Destructor Documentation

◆ leaf_string() [1/2]

tools::rroot::leaf_string::leaf_string ( std::ostream &  a_out,
ifac a_fac 
)
inline

Definition at line 295 of file leaf.

296  :base_leaf(a_out,a_fac)
297  ,m_min(0),m_max(0),m_value(0){}

◆ ~leaf_string()

virtual tools::rroot::leaf_string::~leaf_string ( )
inlinevirtual

Definition at line 298 of file leaf.

298  {
299  delete [] m_value;
300  }

◆ leaf_string() [2/2]

tools::rroot::leaf_string::leaf_string ( const leaf_string a_from)
inlineprotected

Definition at line 302 of file leaf.

303  :iro(a_from),base_leaf(a_from)
304  ,m_min(0),m_max(0),m_value(0){}

Member Function Documentation

◆ cast() [1/2]

virtual void* tools::rroot::leaf_string::cast ( cid  a_class) const
inlinevirtual

Reimplemented from tools::rroot::base_leaf.

Definition at line 225 of file leaf.

225  {
226  if(void* p = cmp_cast<leaf_string>(this,a_class)) {return p;}
227  return base_leaf::cast(a_class);
228  }

◆ cast() [2/2]

virtual void* tools::rroot::leaf_string::cast ( const std::string &  a_class) const
inlinevirtual

Reimplemented from tools::rroot::base_leaf.

Definition at line 218 of file leaf.

218  {
219  if(void* p = cmp_cast<leaf_string>(this,a_class)) {return p;}
220  return base_leaf::cast(a_class);
221  }

◆ copy()

virtual iro* tools::rroot::leaf_string::copy ( ) const
inlinevirtual

Implements tools::rroot::iro.

Definition at line 230 of file leaf.

230 {return new leaf_string(*this);}

◆ id_class()

static cid tools::rroot::leaf_string::id_class ( )
inlinestatic

Definition at line 224 of file leaf.

224 {return leaf_string_cid();}

◆ num_elem()

virtual uint32 tools::rroot::leaf_string::num_elem ( ) const
inlinevirtual

Implements tools::rroot::base_leaf.

Definition at line 293 of file leaf.

293 {return 1;}

◆ operator=()

leaf_string& tools::rroot::leaf_string::operator= ( const leaf_string )
inlineprotected

Definition at line 305 of file leaf.

305 {return *this;}

◆ print_value()

virtual bool tools::rroot::leaf_string::print_value ( std::ostream &  a_out,
uint32   
) const
inlinevirtual

Implements tools::rroot::base_leaf.

Definition at line 289 of file leaf.

289  {
290  if(m_value) a_out << m_value;
291  return true;
292  }

◆ read_buffer()

virtual bool tools::rroot::leaf_string::read_buffer ( buffer a_buffer)
inlinevirtual

Implements tools::rroot::base_leaf.

Definition at line 242 of file leaf.

242  {
243  delete [] m_value;
244  m_value = 0;
245 
246  unsigned char lenchar;
247  if(!a_buffer.read(lenchar)) {
248  m_out << "tools::rroot::leaf_string::read_buffer :"
249  << " read(uchar) failed."
250  << std::endl;
251  return false;
252  }
253  uint32 len = 0;
254  if(lenchar < 255) {
255  len = lenchar;
256  } else {
257  if(!a_buffer.read(len)) {
258  m_out << "tools::rroot::leaf_string::read_buffer :"
259  << " read(int) failed."
260  << std::endl;
261  return false;
262  }
263  }
264  if(len) {
265  //if(!m_length) {
266  // m_out << "tools::rroot::leaf_string::read_buffer : m_length is zero." << std::endl;
267  // return false;
268  //}
269  //if(len >= m_length) len = m_length-1;
270 
271  m_value = new char[len+1];
272 
273  if(!a_buffer.read_fast_array(m_value,len)) {
274  m_out << "tools::rroot::leaf_string::read_buffer :"
275  << " read_fast_array failed."
276  << std::endl;
277  delete [] m_value;
278  m_value = 0;
279  return false;
280  }
281  m_value[len] = 0;
282  } else {
283  m_value = new char[1];
284  m_value[0] = 0;
285  }
286 
287  return true;
288  }

◆ s_class()

static const std::string& tools::rroot::leaf_string::s_class ( )
inlinestatic

Definition at line 213 of file leaf.

213  {
214  static const std::string s_v("tools::rroot::leaf_string");
215  return s_v;
216  }

◆ s_cls()

virtual const std::string& tools::rroot::leaf_string::s_cls ( ) const
inlinevirtual

Reimplemented from tools::rroot::base_leaf.

Definition at line 222 of file leaf.

222 {return s_class();}

◆ stream()

virtual bool tools::rroot::leaf_string::stream ( buffer a_buffer)
inlinevirtual

Reimplemented from tools::rroot::base_leaf.

Definition at line 231 of file leaf.

231  {
232  short v;
233  unsigned int s,c;
234  if(!a_buffer.read_version(v,s,c)) return false;
235  if(!base_leaf::stream(a_buffer)) return false;
236  if(!a_buffer.read(m_min)) return false;
237  if(!a_buffer.read(m_max)) return false;
238  if(!a_buffer.check_byte_count(s,c,s_store_class())) return false;
239  return true;
240  }

◆ value()

const char* tools::rroot::leaf_string::value ( ) const
inline

Definition at line 307 of file leaf.

307 {return m_value;}

Member Data Documentation

◆ m_max

int tools::rroot::leaf_string::m_max
protected

Definition at line 310 of file leaf.

◆ m_min

int tools::rroot::leaf_string::m_min
protected

Definition at line 309 of file leaf.

◆ m_value

char* tools::rroot::leaf_string::m_value
protected

Definition at line 311 of file leaf.


The documentation for this class was generated from the following file:
tools::rroot::leaf_string::m_min
int m_min
Definition: leaf:309
tools::rroot::base_leaf::m_out
std::ostream & m_out
Definition: base_leaf:174
tools::rroot::leaf_string::s_class
static const std::string & s_class()
Definition: leaf:213
tools::rroot::leaf_string::leaf_string
leaf_string(std::ostream &a_out, ifac &a_fac)
Definition: leaf:295
tools::rroot::leaf_string::m_value
char * m_value
Definition: leaf:311
tools::rroot::base_leaf::stream
virtual bool stream(buffer &a_buffer)
Definition: base_leaf:35
tools::rroot::base_leaf::cast
virtual void * cast(const std::string &a_class) const
Definition: base_leaf:23
tools::rroot::leaf_string_cid
cid leaf_string_cid()
Definition: cids:31
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::rroot::base_leaf::base_leaf
base_leaf(std::ostream &a_out, ifac &a_fac)
Definition: base_leaf:105
tools::rroot::leaf_string::m_max
int m_max
Definition: leaf:310