Coconut Framework  beta
CNFixedString.h
Go to the documentation of this file.
1 
8 #ifndef CNFIXEDSTRING_H
9 #define CNFIXEDSTRING_H
10 
11 #include "CNType.h"
12 #include "CNMemoryProfile.h"
13 #include <stdint.h>
14 #include <string.h>
15 #include <stdio.h>
16 
21 struct CNFixedString {
23  size_t length ;
25  uint64_t uniqId ;
27  const unsigned char * content ;
28 } ;
29 
31 typedef CNBoolean (*CNVisitFixedStringPoolFuncRef)(const struct CNFixedString * str, void * userdata) ;
32 
38 void
40 
47 struct CNFixedString *
48 CNAllocateFixedString(size_t len, const unsigned char * str) ;
49 
55 static inline size_t
57 {
58  return src->length ;
59 }
60 
66 static inline const unsigned char *
68 {
69  return src->content ;
70 }
71 
77 static inline uint64_t
79 {
80  return src->uniqId ;
81 }
82 
90 static inline CNBoolean
91 CNIsSameFixedString(const struct CNFixedString * s0, const struct CNFixedString * s1)
92 {
93  return s0 == s1 ;
94 }
95 
103 CNBoolean
105 
112 const struct CNFixedString *
113 CNSearchFixedStringById(uint64_t src) ;
114 
122 const struct CNFixedString *
123 CNSearchFixedStringByUTF8String(size_t srclen, const unsigned char * srcstr) ;
124 
130 void
131 CNPrintFixedString(FILE * outfp, const struct CNFixedString * src) ;
132 
137 struct CNMemoryProfile
139 
140 #endif /* CNFIXEDSTRING_H */
141 
struct CNFixedString * CNSearchFixedStringById(uint64_t src)
Search fixed-string in pool by the id.
Information to present memory profile.
Definition: CNMemoryProfile.h:16
Persistent string. There are only one object for each context of string.
Definition: CNFixedString.h:21
struct CNFixedString * CNSearchFixedStringByUTF8String(size_t srclen, const unsigned char *srcstr)
Search fixed-string in pool by the string.
struct CNMemoryProfile CNProfileOfFixedStringPool(void)
Get memory usage information.
uint64_t uniqId
Definition: CNFixedString.h:25
static size_t CNLengthOfFixedString(const struct CNFixedString *src)
Get length of CNFixedString.
Definition: CNFixedString.h:56
Define CNMemoryProfile data structure.
static const unsigned char * CNContentOfFixedString(const struct CNFixedString *src)
Get content of CNFixedString.
Definition: CNFixedString.h:67
void CNSetupFixedStringPool(void)
Initialize pool for CNFixedString.
CNBoolean CNForeachFixedStringInFixedStringPool(CNVisitFixedStringPoolFuncRef visitfunc, void *userdata)
Get all fixed string in fixed string pool.
void CNPrintFixedString(FILE *outfp, const struct CNFixedString *src)
Print fixed-string.
struct CNFixedString * CNAllocateFixedString(size_t len, const unsigned char *str)
Allocate CNFixedString object.
const unsigned char * content
Definition: CNFixedString.h:27
Define primitive data types.
CNBoolean(* CNVisitFixedStringPoolFuncRef)(const struct CNFixedString *str, void *userdata)
Definition: CNFixedString.h:31
static CNBoolean CNIsSameFixedString(const struct CNFixedString *s0, const struct CNFixedString *s1)
Check 2 string has same context or not.
Definition: CNFixedString.h:91
size_t length
Definition: CNFixedString.h:23
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
static uint64_t CNUniqueIdOfFixedString(const struct CNFixedString *src)
Get hash value of CNFixedString.
Definition: CNFixedString.h:78