ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
Public Member Functions | Data Fields | Protected Attributes
SimpleSelector Struct Reference

The SimpleSelector type. More...

#include <SimpleSelector.h>

Inheritance diagram for SimpleSelector:

Public Member Functions

Class * _SimpleSelector (void)
 The SimpleSelector archetype. More...
 
SimpleSelectorinitWithPattern (SimpleSelector *self, const char *pattern)
 Initializes this SimpleSelector. More...
 
Array * parse (const char *sequence)
 

Data Fields

Object object
 The superclass. More...
 
char * pattern
 The pattern, as provided by the user. More...
 
SimpleSelectorType type
 The SimpleSelectorType. More...
 

Protected Attributes

SimpleSelectorInterface * interface
 The interface. More...
 

Detailed Description

The SimpleSelector type.

Definition at line 55 of file SimpleSelector.h.

Member Function Documentation

◆ _SimpleSelector()

Class * _SimpleSelector ( void  )

The SimpleSelector archetype.

Returns
The SimpleSelector Class.

Definition at line 200 of file SimpleSelector.c.

200 {
201 static Class *clazz;
202 static Once once;
203
204 do_once(&once, {
205 clazz = _initialize(&(const ClassDef) {
206 .name = "SimpleSelector",
207 .superclass = _Object(),
208 .instanceSize = sizeof(SimpleSelector),
209 .interfaceOffset = offsetof(SimpleSelector, interface),
210 .interfaceSize = sizeof(SimpleSelectorInterface),
212 });
213 });
214
215 return clazz;
216}
static void initialize(Class *clazz)
The SimpleSelector type.
SimpleSelectorInterface * interface
The interface.

◆ initWithPattern()

SimpleSelector * initWithPattern ( SimpleSelector self,
const char *  pattern 
)

Initializes this SimpleSelector.

Parameters
selfThe SimpleSelector.
patternThe pattern.
Returns
The initialized SimpleSelector, or NULL on error.

Definition at line 96 of file SimpleSelector.c.

96 {
97
98 self = (SimpleSelector *) super(Object, self, init);
99 if (self) {
100
101 self->pattern = strtrim(pattern);
102 assert(self->pattern);
103
104 assert(strlen(self->pattern));
105 }
106
107 return self;
108}
static View * init(View *self)
Definition: Box.c:67
char * pattern
The pattern, as provided by the user.

◆ parse()

Array * parse ( const char *  sequence)
Parameters
sequenceA C-string specifying a sequence of SimpleSelectors.
Returns
The parsed SimpleSelectors.

Definition at line 274 of file Selector.c.

274 {
275
276 MutableArray *selectors = $$(MutableArray, arrayWithCapacity, 4);
277 assert(selectors);
278
279 if (rules) {
280
281 const char *c = rules;
282 while (*c) {
283 const size_t size = strcspn(c, ",");
284 if (size) {
285 char *rule = calloc(1, size + 1);
286 assert(rule);
287
288 strncpy(rule, c, size);
289
290 Selector *selector = $(alloc(Selector), initWithRule, rule);
291 assert(selector);
292
293 $(selectors, addObject, selector);
294
295 release(selector);
296 free(rule);
297 }
298 c += size;
299 c += strspn(c, ", \t\n");
300 }
301 }
302
303 return (Array *) selectors;
304}
static SDL_Size size(const Image *self)
Definition: Image.c:181
static Selector * initWithRule(Selector *self, const char *rule)
Definition: Selector.c:188
Selectors are comprised of one or more SelectorSequences.
Definition: Selector.h:49

Field Documentation

◆ interface

SimpleSelectorInterface* SimpleSelector::interface
protected

The interface.

Definition at line 66 of file SimpleSelector.h.

◆ object

Object SimpleSelector::object

The superclass.

Definition at line 60 of file SimpleSelector.h.

◆ pattern

char* SimpleSelector::pattern

The pattern, as provided by the user.

Definition at line 71 of file SimpleSelector.h.

◆ type

SimpleSelectorType SimpleSelector::type

The SimpleSelectorType.

Definition at line 76 of file SimpleSelector.h.


The documentation for this struct was generated from the following files: