/usr/include/pj++/scanner.hpp is in libpjproject-dev 2.1.0.0.ast20130823-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | /* $Id: scanner.hpp 2394 2008-12-23 17:27:53Z bennylp $ */
/*
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJPP_SCANNER_HPP__
#define __PJPP_SCANNER_HPP__
#include <pjlib-util/scanner.h>
#include <pj++/string.hpp>
class Pj_Cis;
class Pj_Cis_Buffer;
class Pj_Scanner;
class Pj_Cis_Buffer
{
friend class Pj_Cis;
public:
Pj_Cis_Buffer()
{
pj_cis_buf_init(&buf_);
}
private:
pj_cis_buf_t buf_;
};
class Pj_Cis
{
friend class Pj_Scanner;
public:
Pj_Cis(Pj_Cis_Buffer *buf)
{
pj_cis_init(&buf->buf_, &cis_);
}
Pj_Cis(const Pj_Cis &rhs)
{
pj_cis_dup(&cis_, (pj_cis_t*)&rhs.cis_);
}
void add_range(int start, int end)
{
pj_cis_add_range(&cis_, start, end);
}
void add_alpha()
{
pj_cis_add_alpha(&cis_);
}
void add_num()
{
pj_cis_add_num(&cis_);
}
void add_str(const char *str)
{
pj_cis_add_str(&cis_, str);
}
void add_cis(const Pj_Cis &rhs)
{
pj_cis_add_cis(&cis_, &rhs.cis_);
}
void del_range(int start, int end)
{
pj_cis_del_range(&cis_, start, end);
}
void del_str(const char *str)
{
pj_cis_del_str(&cis_, str);
}
void invert()
{
pj_cis_invert(&cis_);
}
bool match(int c) const
{
return pj_cis_match(&cis_, c) != 0;
}
private:
pj_cis_t cis_;
};
class Pj_Scanner
{
public:
Pj_Scanner() {}
enum
{
SYNTAX_ERROR = 101
};
static void syntax_error_handler_throw_pj(pj_scanner *);
typedef pj_scan_state State;
void init(char *buf, int len, unsigned options=PJ_SCAN_AUTOSKIP_WS,
pj_syn_err_func_ptr callback = &syntax_error_handler_throw_pj)
{
pj_scan_init(&scanner_, buf, len, options, callback);
}
void fini()
{
pj_scan_fini(&scanner_);
}
int eof() const
{
return pj_scan_is_eof(&scanner_);
}
int peek_char() const
{
return *scanner_.curptr;
}
int peek(const Pj_Cis *cis, Pj_String *out)
{
return pj_scan_peek(&scanner_, &cis->cis_, out);
}
int peek_n(pj_size_t len, Pj_String *out)
{
return pj_scan_peek_n(&scanner_, len, out);
}
int peek_until(const Pj_Cis *cis, Pj_String *out)
{
return pj_scan_peek_until(&scanner_, &cis->cis_, out);
}
void get(const Pj_Cis *cis, Pj_String *out)
{
pj_scan_get(&scanner_, &cis->cis_, out);
}
void get_n(unsigned N, Pj_String *out)
{
pj_scan_get_n(&scanner_, N, out);
}
int get_char()
{
return pj_scan_get_char(&scanner_);
}
void get_quote(int begin_quote, int end_quote, Pj_String *out)
{
pj_scan_get_quote(&scanner_, begin_quote, end_quote, out);
}
void get_newline()
{
pj_scan_get_newline(&scanner_);
}
void get_until(const Pj_Cis *cis, Pj_String *out)
{
pj_scan_get_until(&scanner_, &cis->cis_, out);
}
void get_until_ch(int until_ch, Pj_String *out)
{
pj_scan_get_until_ch(&scanner_, until_ch, out);
}
void get_until_chr(const char *spec, Pj_String *out)
{
pj_scan_get_until_chr(&scanner_, spec, out);
}
void advance_n(unsigned N, bool skip_ws=true)
{
pj_scan_advance_n(&scanner_, N, skip_ws);
}
int strcmp(const char *s, int len)
{
return pj_scan_strcmp(&scanner_, s, len);
}
int stricmp(const char *s, int len)
{
return pj_scan_stricmp(&scanner_, s, len);
}
void skip_ws()
{
pj_scan_skip_whitespace(&scanner_);
}
void save_state(State *state) const
{
pj_scan_save_state(&scanner_, state);
}
void restore_state(State *state)
{
pj_scan_restore_state(&scanner_, state);
}
int get_pos_line() const
{
return scanner_.line;
}
int get_pos_col() const
{
return pj_scan_get_col(&scanner_);
}
private:
pj_scanner scanner_;
};
#endif /* __PJPP_SCANNER_HPP__ */
|