4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #ifndef IH_ParserBase_
24 #define IH_ParserBase_ 1
28 ///////////////////////////////ih.p////////////////////////////////////////
37 struct Parser_traits_sentinel
40 template <class Parser>
41 struct Parser_traits_fixed_size {
42 // This differentiates between bytes being a static or
43 // non-static member of Parser ...
44 static const bool fixed_size = sizeof(
45 Parser_traits_fixed_size_check(&Parser::bytes))-sizeof(Parser_traits_sentinel<1>);
49 Parser_traits_sentinel<2> Parser_traits_fixed_size_check(R (*)());
51 template <class R,class T>
52 Parser_traits_sentinel<1> Parser_traits_fixed_size_check(R (T::*)() const);
54 template <class Parser, class Iterator>
55 bool check(Iterator const & b, Iterator const & e, ParserBase *);
57 template <class Parser, class Iterator>
58 bool check(Iterator const & b, Iterator const & e, void *);
60 template <class Parser, bool Fixed>
62 template <class Iterator>
63 static unsigned check(Iterator const & b, Iterator const & e)
64 { return Parser::check(b,e); }
67 template <class Parser>
68 struct ParserCheck<Parser,true> {
69 template <class Iterator>
70 static unsigned check(Iterator const & b, Iterator const & e)
71 { return unsigned(e-b) >= Parser::bytes(); }
74 template <class Parser>
75 unsigned min_bytes(ParserBase *);
77 template <class Parser>
78 unsigned min_bytes(void *);
80 template <class Parser, bool Fixed>
81 struct ParserMinBytes {
82 static unsigned bytes() { return Parser::min_bytes(); }
85 template <class Parser>
86 struct ParserMinBytes<Parser,true> {
87 static unsigned bytes() { return Parser::bytes(); }
92 ///////////////////////////////ih.e////////////////////////////////////////
98 // c-file-style: "satcom"