nidas v1.2.3
|
Class providing sscanf functionality for parsing ASCII data. More...
#include <AsciiSscanf.h>
Classes | |
struct | FormatField |
Information we determine from each conversion field in the sscanf format. More... | |
Public Types | |
enum | fieldtype { DOUBLE =258 , FLOAT , INT , SHORT , CHAR , UINT , USHORT , LONG , ULONG , UNKNOWN } |
Public Member Functions | |
AsciiSscanf () | |
virtual | ~AsciiSscanf () |
void | setFormat (const std::string &val) |
Set the format to be used to sscanf samples. | |
const std::string & | getFormat () const |
void | setSampleTag (SampleTag *val) |
const SampleTag * | getSampleTag () const |
SampleTag * | getSampleTag () |
int | sscanf (const char *input, float *output, int nout) throw () |
scan input, storing up to nout number of values into output, as floats. | |
int | getNumberOfFields () const |
Public Attributes | |
const int | MAX_OUTPUT_VALUES |
Maximum number of fields that we can scan. | |
Private Member Functions | |
AsciiSscanf (const AsciiSscanf &) | |
No copying. | |
AsciiSscanf & | operator= (const AsciiSscanf &) |
No assignment. | |
Private Attributes | |
std::string | _format |
scanf format that we scan to count the number and type of % converters. | |
char * | _charfmt |
Same scanf format, converted to character for quick use by sscanf. | |
int | _lexpos |
Current lexical scanner position. | |
struct FormatField * | _currentField |
Pointer to current FormatField that we are scanning. | |
std::vector< FormatField * > | _fields |
Information scanned from each field. | |
bool | _allFloats |
Are all fields floats? | |
char * | _databuf0 |
A local buffer to store results of sscanf. | |
char ** | _bufptrs |
Pointers into the local buffer for each field in the format string. | |
SampleTag * | _sampleTag |
A scanner may produce dsm samples. | |
AsciiSscanfAdapter * | _lexer |
Friends | |
class | AsciiSscanfAdapter |
Class providing sscanf functionality for parsing ASCII data.
One sets the sscanf format with setFormat then calls sscanf method. This class does a lexical parse of the sscanf conversion format string to determine the number and types of the conversions.
nidas::core::AsciiSscanf::AsciiSscanf | ( | ) |
|
virtual |
|
private |
No copying.
|
inline |
References _format.
Referenced by nidas::dynld::WxtSensor::init(), and nidas::core::CharacterSensor::searchSampleScanners().
|
inline |
References _fields.
Referenced by nidas::core::CharacterSensor::init(), nidas::dynld::WxtSensor::init(), nidas::dynld::TSI_CPC3772::process(), nidas::core::CharacterSensor::scanSample(), nidas::dynld::WxtSensor::scanSample(), nidas::core::CharacterSensor::searchSampleScanners(), nidas::core::CharacterSensor::validateSscanfs(), nidas::dynld::isff::Wind2D::validateSscanfs(), nidas::dynld::isff::Wind3D::validateSscanfs(), and nidas::dynld::WxtSensor::wxtValidateSscanfs().
|
inline |
References _sampleTag.
References _sampleTag.
Referenced by nidas::dynld::WxtSensor::init(), nidas::dynld::TSI_CPC3772::process(), nidas::dynld::WxtSensor::scanSample(), nidas::core::CharacterSensor::searchSampleScanners(), nidas::core::CharacterSensor::validateSscanfs(), nidas::dynld::isff::Wind2D::validateSscanfs(), and nidas::dynld::WxtSensor::wxtValidateSscanfs().
|
private |
No assignment.
Set the format to be used to sscanf samples.
Throws ParseException if there is a conversion field that it doesn't recognize. Supports the basic conversions: f, g, d, o, x, u, c. The 'l' flag can be used with f and g for converting to a double: lf. The 'h' flag can be used with the integer conversions for converting to a short int: hd. Each can also include a maximum field width. Each can also have the suppression flag ('*'). Example: "%*2c%f%f%*5c%x" skips two characters, converts 2 float fields, skips five characters, converts a hex value.
nidas::util::ParseException |
Referenced by nidas::core::CharacterSensor::init().
References _sampleTag, and nidas::core::getSample().
Referenced by nidas::core::CharacterSensor::init().
scan input, storing up to nout number of values into output, as floats.
If a conversion field is not for a float, like "%d", then the field is scanned into a the appropriate type (integer in this example) and then cast to a float. So a scanf of "99" with a "%d" will result in a float, with value 99.0.
Referenced by nidas::dynld::TSI_CPC3772::process(), and nidas::core::CharacterSensor::scanSample().
|
friend |
|
private |
Are all fields floats?
|
private |
Pointers into the local buffer for each field in the format string.
The pointers are aligned appropriately for the type of the format conversion. The sscanf looks like so: sscanf(inputstr,format,bufptrs[0],bufptrs[1],bufptrs[2],...)
|
private |
Same scanf format, converted to character for quick use by sscanf.
|
private |
Pointer to current FormatField that we are scanning.
|
private |
A local buffer to store results of sscanf.
|
private |
Information scanned from each field.
Referenced by getNumberOfFields().
|
private |
scanf format that we scan to count the number and type of % converters.
This format is then used to do sscanf's on ASCII data coming from a sensor.
Referenced by getFormat().
|
private |
|
private |
Current lexical scanner position.
|
private |
A scanner may produce dsm samples.
sampleTag points to to SampleTag describing the samples produced.
Referenced by getSampleTag(), getSampleTag(), and setSampleTag().