cheshirekow  v0.1.0
name.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of cppfontconfig.
5  *
6  * cppfontconfig is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * cppfontconfig is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with cppfontconfig. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef CPPFONTCONFIG_NAME_H_
28 #define CPPFONTCONFIG_NAME_H_
29 
30 
31 #include <cpp_fontconfig/common.h>
34 
35 namespace fontconfig {
36 
37 
38 
41 
59 {
60  public:
61  class Item;
62  class BuildToken;
63 
64  private:
65  FcObjectType* m_ptr;
66  int m_nItems;
67 
69 
72 
73  public:
75  ObjectTypeList( BuildToken& token );
76 
79 
81  FcObjectType* get_ptr();
82 
84  const FcObjectType* get_ptr() const;
85 
87  int get_nItems() const;
88 
90  void destroy();
91 
94  static Item create();
95 };
96 
98 {
99  private:
100  FcObjectType* m_ptr;
101  int m_iItem;
102  int m_nItems;
103 
105  explicit BuildToken(){}
106 
109 
111  BuildToken& operator=( const BuildToken& other ){ return *this; }
112 
114  void init();
115 
117 
120  void incrementCount();
121 
124 
127  void allocate();
128 
130 
133  void write( const char* object, Type_t type );
134 
135  public:
136  friend class ObjectTypeList;
137  friend class ObjectTypeList::Item;
138 
139 
140 
141 };
142 
144 {
145  private:
147  const char* m_object;
149  bool m_isLast;
150 
151  public:
155 
157  ~Item();
158 
160  Item operator()( const char* object, Type_t type );
161 
165 };
166 
167 
168 
169 
172 
184 {
185  public:
186  class Item;
187  class BuildToken;
188 
189  private:
190  FcConstant* m_ptr;
191  int m_nItems;
192 
194 
196  ConstantList();
197 
198  public:
201 
204 
206  FcConstant* get_ptr();
207 
209  const FcConstant* get_ptr() const;
210 
212  int get_nItems() const;
213 
215  void destroy();
216 
219  static Item create();
220 
221 };
222 
224 {
225  private:
226  FcConstant* m_ptr;
227  int m_iItem;
228  int m_nItems;
229 
231  explicit BuildToken(){}
232 
235 
237  BuildToken& operator=( const BuildToken& other ){ return *this; }
238 
240  void init();
241 
243 
246  void incrementCount();
247 
250 
253  void allocate();
254 
257 
260  void write( const Char8_t* name, const char* object, int value );
261 
262  public:
263  friend class ConstantList;
264  friend class ConstantList::Item;
265 };
266 
268 {
269  private:
271  const Char8_t* m_name;
272  const char* m_object;
273  int m_value;
274  bool m_isLast;
275 
276  public:
279  Item( ConstantList::BuildToken& token );
280 
282  ~Item();
283 
285  Item operator()( const Char8_t* name, const char* object, int value );
286 
290 };
291 
292 
293 
294 namespace name {
295 
297 
301 bool registerObjectTypes( const ObjectTypeList& list );
302 
304 
307 bool unregisterObjectTypes( const ObjectTypeList& list );
308 
310 
313 RefPtr<ObjectType> getObjectType( const char* object );
314 
316 
320 bool registerConstants( const ConstantList& list );
321 
323 
327 bool unregisterConstants( const ConstantList& list );
328 
330 
334 
336 
340 bool constant( Char8_t* string, int* result );
341 
342 
343 
344 }
345 }
346 
347 
348 
349 
350 
351 
352 
353 
354 
355 
356 
357 
358 
359 
360 #endif // NAME_H_
void init()
initializes fields to zero
void write(const Char8_t *name, const char *object, int value)
writes data and increments counter, returns true if this is the last item
bool unregisterConstants(const ConstantList &list)
Unregister symbolic constants.
utility class for building a static list of ObjectTypes, replaces static allocation of a list of FcOb...
Definition: name.h:183
BuildToken(const BuildToken &other)
cannot be copied
Definition: name.h:234
BuildToken & operator=(const BuildToken &other)
cannot be copied
Definition: name.h:237
bool constant(Char8_t *string, int *result)
Get the value for a symbolic constant.
FcObjectType * m_ptr
array of objects
Definition: name.h:62
void allocate()
allocates the object type buffer given the current value of m_nItems
void incrementCount()
increments the item count
ConstantList::BuildToken & m_token
Definition: name.h:270
void init()
initializes fields to zero
int m_nItems
number of items
Definition: name.h:102
FcConstant * m_ptr
Definition: name.h:187
unsigned char Char8_t
Definition: common.h:65
static Item create()
creates a new Object type list, and returns an item which points to it
void write(const char *object, Type_t type)
writes data and increments counter
BuildToken()
can only be created by ObjectTypeList
Definition: name.h:105
ObjectTypeList::BuildToken & operator()()
finalizes the initialization by signaling the list to allocate data, the data is filled by ~Item() ...
int m_nItems
number of items
Definition: name.h:66
bool registerConstants(const ConstantList &list)
Register symbolic constants.
FcConstant * m_ptr
array of objects
Definition: name.h:226
const Char8_t * m_name
Definition: name.h:271
void destroy()
destroy underlying data
void incrementCount()
increments the item count
int m_iItem
index of the current item to write
Definition: name.h:101
ConstantList()
private constructor, use ObjectTypeList::create() instead
BuildToken & operator=(const BuildToken &other)
cannot be copied
Definition: name.h:111
FcConstant * get_ptr()
return a c-array of constants
ConstantList::BuildToken & operator()()
finalizes the initialization by signaling the list to allocate data, the data is filled by ~Item() ...
FcObjectType * get_ptr()
return the c-array of objects
static Item create()
creates a new Object type list, and returns an item which points to it
utility class for building a static list of ObjectTypes, replaces static allocation of a list of FcOb...
Definition: name.h:58
static BuildToken sm_seed
Definition: name.h:193
void destroy()
destroy underlying data
void allocate()
allocates the object type buffer given the current value of m_nItems
static BuildToken sm_seed
Definition: name.h:68
bool registerObjectTypes(const ObjectTypeList &list)
Register object types.
bool unregisterObjectTypes(const ObjectTypeList &list)
Unregister object types.
BinaryKey other(const BinaryKey &key)
Definition: BinaryKey.h:44
int m_nItems
number of items
Definition: name.h:228
BuildToken()
can only be created by ObjectTypeList
Definition: name.h:231
~Item()
writes the item data to the list
Item(ConstantList::BuildToken &token)
initializes the item as an empty last item and increments the number of items in the list ...
~Item()
writes the item data to the list
FcObjectType * m_ptr
array of objects
Definition: name.h:100
RefPtr< ObjectType > getObjectType(const char *object)
Lookup an object type.
int get_nItems() const
return the number of objects
ObjectTypeList::BuildToken & m_token
Definition: name.h:146
BuildToken(const BuildToken &other)
cannot be copied
Definition: name.h:108
ObjectTypeList()
private constructor, use ObjectTypeList::create() instead
Item(ObjectTypeList::BuildToken &token)
initializes the item as an empty last item and increments the number of items in the list ...
int m_iItem
index of the current item to write
Definition: name.h:227
RefPtr< Constant > getConstant(Char8_t *string)
Lookup symbolic constant.
int get_nItems() const
return the number of constants
object which acts like a c-pointer, but when dereferenced returns a delegate object which adds method...
Definition: CPtr.h:33