KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
kjb::Readable Class Referenceabstract

Abstract class to read this object from an input stream. More...

#include <l_readable.h>

Inheritance diagram for kjb::Readable:
kjb::Circle_in_3d kjb::Color_histogram kjb::Corner kjb::Cylinder kjb::Edge_segment_set kjb::Features_manager kjb::Hog_responses kjb::Learned_discrete_prior kjb::Line_segment kjb::Line_segment_set kjb::Manhattan_hog kjb::Parametric_frustum kjb::Parametric_parapiped kjb::Parametric_sphere kjb::Perspective_camera kjb::Polygon kjb::Polymesh kjb::Vanishing_point

Public Member Functions

virtual ~Readable ()
 Deletes this Readable. More...
 
virtual void read (std::istream &in)=0
 Reads this Readable from an input stream. More...
 
virtual void read (const char *fname)
 Reads this Readable from a file. More...
 

Static Public Member Functions

static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':')
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More...
 
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':')
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More...
 

Detailed Description

Abstract class to read this object from an input stream.

Warning
The three-parameter version of read_field_value is not thread-safe.

Constructor & Destructor Documentation

virtual kjb::Readable::~Readable ( )
inlinevirtual

Deletes this Readable.

Member Function Documentation

virtual void kjb::Readable::read ( std::istream &  in)
pure virtual
void kjb::Readable::read ( const char *  fname)
virtual

Reads this Readable from a file.

Parameters
fnameInput file to read from.
Exceptions
kjb::IO_errorCould not read from fname.
kjb::Illegal_argumentInvalid arguments in the file to read from.

Reimplemented in kjb::Edge_segment_set, kjb::Perspective_camera, kjb::Features_manager, kjb::Color_histogram, kjb::Learned_discrete_prior, kjb::Parametric_frustum, kjb::Parametric_parapiped, kjb::Circle_in_3d, kjb::Line_segment_set, kjb::Cylinder, and kjb::Parametric_sphere.

const char * kjb::Readable::read_field_value ( std::istream &  in,
const char *  field_name,
char *  field_buf,
size_t  buf_len,
char  separator = ':' 
)
static

Reads a line off in into a buffer and returns a pointer to the field value in the buffer.

Reads a line off the input stream as a field with format:

field name: field value

Where the separator here is a ':'.

Parameters
inInput stream to read the field line from.
field_nameName of the field to get the value of.
field_bufBuffer to read the line of input into.
buf_lenLength of the buffer.
separatorCharacter separating the field name and value. The default is ':'. The zero character is not allowed.
Exceptions
kjb::Illegal_argumentEither the field is not the one named or it is not formatted properly.
kjb::IO_errorCould not read a line from the input stream.
Returns
A constant pointer into field_buf where the field value is or 0 if there is no value.
Note
A terminating character '\0' is always inserted in the buffer, even if it would truncate the line.
const char * kjb::Readable::read_field_value ( std::istream &  in,
const char *  field_name,
char  separator = ':' 
)
static

Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer.

Warning
This function is not thread-safe.

Reads a line off the input stream as a field with format:

field name: field value

Where the separator here is a ':'.

Parameters
inInput stream to read the field line from.
field_nameName of the field to get the value of.
separatorCharacter separating the field name and value. The default is ':'.
Exceptions
kjb::Illegal_argumentEither the field is not the one named or it is not formatted properly.
kjb::IO_errorCould not read a line from the input stream.
Returns
A constant pointer to the field value or 0 if there is no value.
Note
The buffer for reading a field value is shared, so each time the function is called, it will be overwritten.
The maximum line length to read is 255.

The documentation for this class was generated from the following files: