ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
SimpleSelector Struct Reference

The SimpleSelector type. More...

#include <SimpleSelector.h>

Inheritance diagram for SimpleSelector:

Public Member Functions

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

Data Fields

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

Protected Attributes

SimpleSelectorInterface * interface
 The interface.
 

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)
Definition Box.c:123
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 291 of file Selector.c.

291 {
292
293 Array *selectors = $$(Array, arrayWithCapacity, 4);
294 assert(selectors);
295
296 if (rules) {
297
298 const char *c = rules;
299 while (*c) {
300 const size_t size = strcspn(c, ",");
301 if (size) {
302 char *rule = calloc(1, size + 1);
303 assert(rule);
304
305 strncpy(rule, c, size);
306
307 Selector *selector = $(alloc(Selector), initWithRule, rule);
308 assert(selector);
309
310 $(selectors, addObject, selector);
311
312 release(selector);
313 free(rule);
314 }
315 c += size;
316 c += strspn(c, ", \t\n");
317 }
318 }
319
320 return (Array *) selectors;
321}
static SDL_Size size(const Image *self)
Definition Image.c:181
static Selector * initWithRule(Selector *self, const char *rule)
Definition Selector.c:190
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: