#include <vul_awk.h>
vul_awk reads lines from a vcl_istream and breaks them into whitespace-separated fields. Its primary advantage is that its name defines the semantics of its methods---except that this C++ version uses zero-based fields. The usage is exemplified in this example, to print the second field in every line:
for (vul_awk awk=cin; awk; ++awk) vcl_cout << awk[2] << vcl_endl;
Definition at line 35 of file vul_awk.h.
Public Types | |
| enum | ModeFlags { none = 0x00, verbose = 0x01, strip_comments = 0x02, backslash_continuations = 0x04 } |
Public Member Functions | |
| vul_awk (vcl_istream &s, ModeFlags mode=none) | |
| Construct from input stream. | |
| ~vul_awk () | |
| char const * | operator[] (unsigned i) const |
| Return field i. Counting starts at 0. | |
| int | NR () const |
| Return the current "record number", i.e. line number. | |
| int | NF () const |
| Return the number of fields on this line. | |
| char const * | line () const |
| Return the entire line. | |
| char const * | line_from (int field_number) const |
| Return the remainder of the line, starting from field_number. | |
| operator safe_bool () const | |
| Return true if this line is not the last. | |
| bool | operator! () const |
| Return false if this line is not the last. | |
| vul_awk & | operator++ () |
| Advance to the next line. | |
| void | error (vcl_ostream &, char const *message, int field=-1, int char_within_field=0) |
| Display error message, line number. | |
Protected Member Functions | |
| void | next () |
| vul_awk (const vul_awk &that) | |
| vul_awk & | operator= (const vul_awk &that) |
Protected Attributes | |
| vcl_istream & | fd_ |
| ModeFlags | mode_ |
| vcl_string | line_ |
| char * | split_line_ |
| vcl_vector< char * > | fields_ |
| int | line_number_ |
| bool | done_ |
Private Attributes | |
| VCL_SAFE_BOOL_DEFINE | |
| enum vul_awk::ModeFlags |
| vul_awk::vul_awk | ( | vcl_istream & | s, | |
| ModeFlags | mode = none | |||
| ) |
| vul_awk::~vul_awk | ( | ) |
Definition at line 31 of file vul_awk.cxx.
| vul_awk::vul_awk | ( | const vul_awk & | that | ) | [protected] |
| char const* vul_awk::operator[] | ( | unsigned | i | ) | const [inline] |
| int vul_awk::NR | ( | ) | const [inline] |
| int vul_awk::NF | ( | ) | const [inline] |
| char const* vul_awk::line | ( | ) | const [inline] |
| char const * vul_awk::line_from | ( | int | field_number | ) | const |
Return the remainder of the line, starting from field_number.
(0 is from the first non-whitespace character)
Definition at line 87 of file vul_awk.cxx.
| vul_awk::operator safe_bool | ( | ) | const [inline] |
| bool vul_awk::operator! | ( | ) | const [inline] |
| vul_awk& vul_awk::operator++ | ( | ) | [inline] |
| void vul_awk::error | ( | vcl_ostream & | , | |
| char const * | message, | |||
| int | field = -1, |
|||
| int | char_within_field = 0 | |||
| ) |
Display error message, line number.
Also display optional field number and char within field.
| void vul_awk::next | ( | ) | [protected] |
Definition at line 36 of file vul_awk.cxx.
vul_awk::VCL_SAFE_BOOL_DEFINE [private] |
vcl_istream& vul_awk::fd_ [protected] |
ModeFlags vul_awk::mode_ [protected] |
vcl_string vul_awk::line_ [protected] |
char* vul_awk::split_line_ [protected] |
vcl_vector<char *> vul_awk::fields_ [protected] |
int vul_awk::line_number_ [protected] |
bool vul_awk::done_ [protected] |
1.5.1