WXP C++ Library Version 6.74.6
Loading...
Searching...
No Matches
Public Member Functions | List of all members
WXP::Scanp Class Reference

This class parses data given expressions to search for. More...

#include "../include/Scanp.h"

Public Member Functions

int init ()
 
int scan (const char *pat,...)
 This routine scans a character string for data and parses information using a pattern description string. More...
 
int set (const char *str)
 
int getOffset ()
 
int offset (int off)
 
int inc (int off)
 
int inc ()
 
const char * string ()
 
char getChar (int off)
 
int search (const char *str)
 
int print ()
 
int length ()
 
int matched ()
 
int assigned ()
 
bool finished ()
 

Detailed Description

This class parses data given expressions to search for.

Author
Dan Vietor

Member Function Documentation

◆ getChar()

char Scanp::getChar ( int  roff)

Returns character at specific offset

Parameters
offOffset
Returns
Character

Referenced by WXP::RcmFile::decode(), WXP::MetarTool::decode(), and WXP::SaoTool::decode().

◆ getOffset()

int Scanp::getOffset ( )

Returns current offset into string

Returns
Current offset

Referenced by WXP::SaoTool::decode().

◆ inc() [1/2]

int Scanp::inc ( )

Increments offset based on matched length of previous scan (see scan)

◆ inc() [2/2]

int Scanp::inc ( int  roff)

Increments offset into string

Parameters
offIncrement value

Referenced by WXP::ClimatTool::decode(), WXP::RcmFile::decode(), WXP::MetarTool::decode(), WXP::SaoTool::decode(), and WXP::SynopTool::decode().

◆ init()

int Scanp::init ( )

Initializes class values

Referenced by scan().

◆ offset()

int Scanp::offset ( int  roff)

Sets offset into string

Parameters
Currentoffset

Referenced by WXP::MosUFile::decodeETA().

◆ scan()

int Scanp::scan ( const char *  pat,
  ... 
)

This routine scans a character string for data and parses information using a pattern description string.

Scans and decodes data

Parameters
patPattern to use

Formatting similar to scanf except more robust:

%{*}{<}{f}{!m!}t

  • * Don't assign to a variable
  • f Field width - match exactly this number of characters
  • <f Field width - match up to this number of characters
  • !m! Specifies that a missing value can be specified
    either is nothing or the string m
  • t Format type
    – s Standard string delimited by spaces
    – S Match all characters - terminatint null character
    – c Standard characters - no terminating null character
    – A Alphabetic string only
    – N Numeric string only
    – n Current position in string
    – d Integer
    – D Integer, no white space skip
    – f Floating point
    – F Floating point, no white space skip
    – w Whitespace
    – W Whitespace, no newline
    – (s) Match exact string
    – (s|s|..) Match strings in this set of string delimited with |
    – [s] Match character types or specific characters s = A for alphabetic, N for numeric, all others literal
    – [^s] Match everythin but character types or specific characters

    Leading whitespace are not read on S,A,N,D or F formats.

    Non-format characters are literal except space which matches any number of whitespace characters.

References init(), WXP::Const::MISS, and WXP::Wxp::outDebug().

Referenced by WXP::ClimatTool::decode(), WXP::RcmFile::decode(), WXP::MetarTool::decode(), WXP::SaoTool::decode(), WXP::SynopTool::decode(), and WXP::MosUFile::decodeETA().

◆ search()

int Scanp::search ( const char *  rstr)

Searches the current string for another string

Parameters
rstrString to search for
Returns
1 if found, 0 if not

◆ set()

int Scanp::set ( const char *  rstr)

◆ string()

const char * Scanp::string ( )

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