feisty meow concerns codebase  2.140
parser_bits.h
Go to the documentation of this file.
1 #ifndef PARSER_BITS_CLASS
2 #define PARSER_BITS_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : parser_bits *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 2000-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include <basis/astring.h>
19 
20 namespace textual {
21 
23 
25 {
26 public:
28 
31  enum line_ending {
32  LF_AT_END = -15,
34  NO_ENDING
35  };
36 
37  static const char *eol_to_chars(line_ending ending);
39 
40  static line_ending platform_eol();
42 
43  static const char *platform_eol_to_chars();
45 
46  static void translate_CR_for_platform(basis::astring &to_translate);
48 
53  bool leave_unknown = true);
55 
63  static bool is_printable_ascii(char to_check);
65 
70  static bool white_space_no_cr(char to_check);
72 
76  static bool is_eol(char to_check);
78 
80  static bool white_space(char to_check);
82 
85  static bool is_alphanumeric(char look_at);
87 
88  static bool is_alphanumeric(const char *look_at, int len);
90  static bool is_alphanumeric(const basis::astring &look_at, int len);
92 
93  static bool is_alpha(char look_at);
95 
96  static bool is_alpha(const char *look_at, int len);
98  static bool is_alpha(const basis::astring &look_at, int len);
100 
101  static bool is_numeric(char look_at);
103 
106  static bool is_numeric(const char *look_at, int len);
108  static bool is_numeric(const basis::astring &look_at, int len);
110 
111  static bool is_hexadecimal(char look_at);
113 
114  static bool is_hexadecimal(const char *look_at, int len);
116  static bool is_hexadecimal(const basis::astring &look_at, int len);
118 
119  static bool is_identifier(char look_at);
121 
122  static bool is_identifier(const char *look_at, int len);
124 
125  static bool is_identifier(const basis::astring &look_at, int len);
127 };
128 
129 } //namespace.
130 
131 #endif
132 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
Warehouses some functions that are often useful during text parsing.
Definition: parser_bits.h:25
static void translate_CR_for_platform(basis::astring &to_translate)
flips embedded EOL characters for this platform's needs.
Definition: parser_bits.cpp:74
static bool is_identifier(char look_at)
returns true if "look_at" is a valid identifier character.
static bool is_hexadecimal(char look_at)
returns true if "look_at" is one of the hexadecimal characters.
static bool white_space_no_cr(char to_check)
reports if "to_check" is white space but not a carriage return.
Definition: parser_bits.cpp:65
static bool white_space(char to_check)
returns true if the character "to_check" is considered a white space.
Definition: parser_bits.cpp:71
static bool is_alpha(char look_at)
returns true if "look_at" is one of the alphabetical characters.
static bool is_printable_ascii(char to_check)
returns true if "to_check" is a normally visible ASCII character.
Definition: parser_bits.cpp:62
line_ending
Line endings is an enumeration of the separator character(s) used for text files.
Definition: parser_bits.h:31
@ LF_AT_END
Unix standard is LF_AT_END ("\n").
Definition: parser_bits.h:32
@ CRLF_AT_END
DOS standard is CRLF_AT_END ("\r\n").
Definition: parser_bits.h:33
@ NO_ENDING
No additional characters added as line endings.
Definition: parser_bits.h:34
static basis::astring substitute_env_vars(const basis::astring &text, bool leave_unknown=true)
resolves embedded environment variables in "text".
static bool is_alphanumeric(char look_at)
returns true if "look_at" is one of the alphanumeric characters.
static line_ending platform_eol()
provides the appropriate ending on the current OS platform.
Definition: parser_bits.cpp:31
static bool is_numeric(char look_at)
returns true if "look_at" is a valid numerical character.
static const char * eol_to_chars(line_ending ending)
returns the C string form for the "ending" value.
Definition: parser_bits.cpp:45
static bool is_eol(char to_check)
returns true if "to_check" is part of an end-of-line sequence.
Definition: parser_bits.cpp:68
static const char * platform_eol_to_chars()
provides the characters that make up this platform's line ending.
Definition: parser_bits.cpp:59