Coconut Framework  beta
CNText.h
Go to the documentation of this file.
1 
8 #ifndef CNTEXT_H
9 #define CNTEXT_H
10 
11 #include "CNObject.h"
12 #include "CNBuffer.h"
13 #include "CNPool.h"
14 #include "CNFixedString.h"
15 #include "CNString.h"
16 #include "CNForwarders.h"
17 #include <stdio.h>
18 
20 struct CNText
21 {
31  struct CNPool textPool ;
32 } ;
33 
39 struct CNText *
40 CNAllocateText(struct CNResource * resource) ;
41 
47 static inline struct CNResource *
48 CNResourceOfText(struct CNText * src)
49 {
50  return CNResourceOfObject(&(src->superClass)) ;
51 }
52 
57 static inline void
58 CNReleaseText(struct CNText * dst)
59 {
60  CNReleaseObject(&(dst->superClass)) ;
61 }
62 
69 void
70 CNPushSectionToText(struct CNText * dst, const unsigned char * beginstr, const unsigned char * endstr) ;
71 
76 void
77 CNPopSectionFromText(struct CNText * dst) ;
78 
85 static inline void
86 CNPutUTF8StringToText(struct CNText * dst, size_t srclen, const unsigned char * srcstr)
87 {
88  CNPutBytesToBuffer(&(dst->currentBuffer), srclen, srcstr) ;
89 }
90 
96 static inline void
97 CNPutFixedStringToText(struct CNText * dst, const struct CNFixedString * src)
98 {
100 }
101 
107 void
108 CNPutStringToText(struct CNText * dst, const struct CNString * src) ;
109 
115 void
116 CNPutSignedIntegerToText(struct CNText * dst, int64_t src) ;
117 
123 void
124 CNPutUnsignedIntegerToText(struct CNText * dst, uint64_t src) ;
125 
131 void
132 CNPutFloatToText(struct CNText * dst, double src) ;
133 
139 void
140 CNPutCharToText(struct CNText * dst, char src) ;
141 
150 void CNFlushText(struct CNText * dst) ;
151 
156 void
157 CNClearText(struct CNText * dst) ;
158 
164 void
165 CNPrintText(FILE * outfp, struct CNText * src) ;
166 
167 #endif /* CNTEXT_H */
struct CNTextSection * currentSection
Definition: CNText.h:27
static void CNPutFixedStringToText(struct CNText *dst, const struct CNFixedString *src)
Put fixed string to text.
Definition: CNText.h:97
Write buffer to store variable-sized continuous data.
Definition: CNBuffer.h:17
void CNPutStringToText(struct CNText *dst, const struct CNString *src)
Put string to text.
void CNPopSectionFromText(struct CNText *dst)
Move to the parent section from current section.
static void CNPutBytesToBuffer(struct CNBuffer *dst, size_t srcsize, const void *srcptr)
Write byte data into the buffer.
Definition: CNBuffer.h:127
struct CNObject superClass
Definition: CNText.h:23
Pool of variable data.
Definition: CNPool.h:22
void CNPutSignedIntegerToText(struct CNText *dst, int64_t src)
Put signed integer to text.
Definition: CNText.h:20
static struct CNResource * CNResourceOfText(struct CNText *src)
Get resource for this text.
Definition: CNText.h:48
Forward declaration of data types.
struct CNTextSection * topSection
Definition: CNText.h:25
void CNFlushText(struct CNText *dst)
Flush the context of text buffer into text data.
Persistent string. There are only one object for each context of string.
Definition: CNFixedString.h:21
static size_t CNLengthOfFixedString(const struct CNFixedString *src)
Get length of CNFixedString.
Definition: CNFixedString.h:56
struct CNText * CNAllocateText(struct CNResource *resource)
Allocate CNText object.
static void CNReleaseText(struct CNText *dst)
Release text object.
Definition: CNText.h:58
Definition: CNTextSection.h:16
Root object.
Definition: CNObject.h:38
static const unsigned char * CNContentOfFixedString(const struct CNFixedString *src)
Get content of CNFixedString.
Definition: CNFixedString.h:67
static void CNPutUTF8StringToText(struct CNText *dst, size_t srclen, const unsigned char *srcstr)
Put string to text.
Definition: CNText.h:86
void CNPrintText(FILE *outfp, struct CNText *src)
Print text.
Define CNBuffer data structure.
struct CNBuffer currentBuffer
Definition: CNText.h:29
Define CNFixedString class.
Fixed size string class.
Definition: CNString.h:27
void CNPushSectionToText(struct CNText *dst, const unsigned char *beginstr, const unsigned char *endstr)
Allocate new section as a child of section.
Define CNObject data structure.
Define CNString class.
Define CNPool data structure.
void CNClearText(struct CNText *dst)
Make clean text buffer.
void CNReleaseObject(struct CNObject *dst)
Release the object.
struct CNPool textPool
Definition: CNText.h:31
void CNPutUnsignedIntegerToText(struct CNText *dst, uint64_t src)
Put unsigned integer to text.
static struct CNResource * CNResourceOfObject(struct CNObject *src)
Get resource for the object.
Definition: CNObject.h:95
void CNPutCharToText(struct CNText *dst, char src)
Put character value to text.
void CNPutFloatToText(struct CNText *dst, double src)
Put floating point value to text.