Coconut Framework  beta
CNTextElement.h
Go to the documentation of this file.
1 
8 #ifndef CNTEXTELEMENT_H
9 #define CNTEXTELEMENT_H
10 
11 #include "CNObject.h"
12 #include <stdio.h>
13 
15 typedef enum {
16  CNTextSectionElement,
17  CNTextLineElement
19 
24 {
29 } ;
30 
33 {
37  void (*printFunc)(FILE * outfp, unsigned int level, const struct CNTextElement * src) ;
38 } ;
39 
48 static inline struct CNTextElement *
49 CNAllocateTextElement(CNTextElementKind kind, size_t objsize, const struct CNTextElementMethods * methods, struct CNResource * resource)
50 {
51  struct CNTextElement * newelm = (struct CNTextElement *) CNAllocateObject(objsize, &(methods->superClass), resource) ;
52  if(newelm){
53  newelm->elementKind = kind ;
54  }
55  return newelm ;
56 }
57 
63 static inline struct CNObject *
65 {
66  return &(src->superClass) ;
67 }
68 
73 static inline void
75 {
76  CNRetainObject(&(dst->superClass)) ;
77 }
78 
83 static inline void
85 {
86  CNReleaseObject(&(dst->superClass)) ;
87 }
88 
95 static inline void
96 CNPrintTextElement(FILE * outfp, unsigned int level, const struct CNTextElement * src)
97 {
98  const struct CNObject * obj = &(src->superClass) ;
99  const struct CNTextElementMethods * methods = (const struct CNTextElementMethods *) CNMethodsOfObject(obj) ;
100  (*(methods->printFunc))(outfp, level, src) ;
101 }
102 
103 #endif /* CNTEXTELEMENT_H */
104 
CNTextElementKind elementKind
Definition: CNTextElement.h:28
static void CNPrintTextElement(FILE *outfp, unsigned int level, const struct CNTextElement *src)
Print text element.
Definition: CNTextElement.h:96
void(* printFunc)(FILE *outfp, unsigned int level, const struct CNTextElement *src)
Definition: CNTextElement.h:37
static struct CNTextElement * CNAllocateTextElement(CNTextElementKind kind, size_t objsize, const struct CNTextElementMethods *methods, struct CNResource *resource)
Allocate text element.
Definition: CNTextElement.h:49
Element of CNText.
Definition: CNTextElement.h:23
struct CNObjectMethods superClass
Definition: CNTextElement.h:35
Root object.
Definition: CNObject.h:38
Definition: CNTextElement.h:32
struct CNObject superClass
Definition: CNTextElement.h:26
Define CNObject data structure.
Methods for CNObject.
Definition: CNObject.h:29
void CNReleaseObject(struct CNObject *dst)
Release the object.
static void CNReleaseTextElement(struct CNTextElement *dst)
Release the reference count.
Definition: CNTextElement.h:84
static struct CNObject * CNObjectOfTextElement(struct CNTextElement *src)
Get super class of text element.
Definition: CNTextElement.h:64
static void CNRetainObject(struct CNObject *dst)
Retain the object.
Definition: CNObject.h:75
static void CNRetainTextElement(struct CNTextElement *dst)
Retain the reference count.
Definition: CNTextElement.h:74
static struct CNObject * CNAllocateObject(size_t size, const struct CNObjectMethods *methods, struct CNResource *resource)
Allocate object.
Definition: CNObject.h:59
static struct CNObjectMethods * CNMethodsOfObject(const struct CNObject *src)
Get methods for the object.
Definition: CNObject.h:106
CNTextElementKind
Type of element of text.
Definition: CNTextElement.h:15