1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libe-book project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef FICTIONBOOK2TOKEN_H_INCLUDED
11 #define FICTIONBOOK2TOKEN_H_INCLUDED
12 
13 #include "EBOOKToken.h"
14 
15 namespace libebook
16 {
17 
18 #define FictionBook2_NO_NAMESPACE(ns) (0 == ns)
19 
20 namespace FictionBook2Token
21 {
22 
23 enum
24 {
25   INVALID_TOKEN = 0,
26   FIRST_TOKEN = EBOOKToken<FictionBook2Parser>::FIRST_TOKEN,
27 
28   // namespaces
29   NS_FICTIONBOOK,
30   NS_XLINK,
31   NS_XML,
32   NS_XMLNS,
33 
34   // elements
35   a,
36   annotation,
37   author,
38   binary,
39   body,
40   book_name,
41   book_title,
42   cite,
43   city,
44   code,
45   coverpage,
46   custom_info,
47   date,
48   description,
49   document_info,
50   email,
51   emphasis,
52   empty_line,
53   epigraph,
54   FictionBook,
55   first_name,
56   genre,
57   history,
58   home_page,
59   id,
60   image,
61   isbn,
62   keywords,
63   lang,
64   last_name,
65   middle_name,
66   nickname,
67   output,
68   output_document,
69   p,
70   part,
71   poem,
72   program_used,
73   publisher,
74   publish_info,
75   section,
76   sequence,
77   src_lang,
78   src_ocr,
79   src_title_info,
80   src_url,
81   stanza,
82   strikethrough,
83   strong,
84   style,
85   stylesheet,
86   sub,
87   subtitle,
88   sup,
89   table,
90   td,
91   text_author,
92   th,
93   title,
94   title_info,
95   tr,
96   translator,
97   v,
98   version,
99   year,
100 
101   // attributes
102   align,
103   alt,
104   colspan,
105   content_type,
106   create,
107   currency,
108   href,
109   include,
110   include_all,
111   info_type,
112   match,
113   mode,
114   name,
115   number,
116   price,
117   rowspan,
118   type,
119   value,
120 
121   // attribute values
122   image_jpg,
123   note,
124   simple,
125 
126   LAST_TOKEN
127 };
128 
129 static_assert(EBOOKToken<FictionBook2Parser>::LAST_TOKEN >= LAST_TOKEN, "token number overflow");
130 
131 }
132 
133 struct FictionBook2TokenData
134 {
135   const char *name;
136   int id;
137 };
138 
139 const FictionBook2TokenData *getFictionBook2Token(const char *str, const unsigned length);
140 const FictionBook2TokenData *getFictionBook2Token(const char *str);
141 const FictionBook2TokenData *getFictionBook2Token(const unsigned char *str);
142 
143 int getFictionBook2TokenID(const FictionBook2TokenData &token);
144 int getFictionBook2TokenID(const FictionBook2TokenData *token);
145 int getFictionBook2TokenID(const char *str, const unsigned length);
146 int getFictionBook2TokenID(const char *str);
147 int getFictionBook2TokenID(const unsigned char *str);
148 
149 const char *getFictionBook2TokenName(const FictionBook2TokenData &token);
150 const char *getFictionBook2TokenName(const FictionBook2TokenData *token);
151 const char *getFictionBook2TokenName(const char *str, const unsigned length);
152 const char *getFictionBook2TokenName(const char *str);
153 const char *getFictionBook2TokenName(const unsigned char *str);
154 
155 }
156 
157 #endif // FICTIONBOOK2TOKEN_H_INCLUDED
158 
159 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
160