Coconut Framework  beta
Classes | Typedefs | Functions
CNFixedString.h File Reference

Define CNFixedString class. More...

#include "CNType.h"
#include "CNMemoryProfile.h"
#include <stdint.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  CNFixedString
 Persistent string. There are only one object for each context of string. More...
 

Typedefs

typedef CNBoolean(* CNVisitFixedStringPoolFuncRef )(const struct CNFixedString *str, void *userdata)
 

Functions

void CNSetupFixedStringPool (void)
 Initialize pool for CNFixedString. More...
 
struct CNFixedStringCNAllocateFixedString (size_t len, const unsigned char *str)
 Allocate CNFixedString object. More...
 
static size_t CNLengthOfFixedString (const struct CNFixedString *src)
 Get length of CNFixedString. More...
 
static const unsigned char * CNContentOfFixedString (const struct CNFixedString *src)
 Get content of CNFixedString. More...
 
static uint64_t CNUniqueIdOfFixedString (const struct CNFixedString *src)
 Get hash value of CNFixedString. More...
 
static CNBoolean CNIsSameFixedString (const struct CNFixedString *s0, const struct CNFixedString *s1)
 Check 2 string has same context or not. More...
 
CNBoolean CNForeachFixedStringInFixedStringPool (CNVisitFixedStringPoolFuncRef visitfunc, void *userdata)
 Get all fixed string in fixed string pool. More...
 
struct CNFixedStringCNSearchFixedStringById (uint64_t src)
 Search fixed-string in pool by the id. More...
 
struct CNFixedStringCNSearchFixedStringByUTF8String (size_t srclen, const unsigned char *srcstr)
 Search fixed-string in pool by the string. More...
 
void CNPrintFixedString (FILE *outfp, const struct CNFixedString *src)
 Print fixed-string. More...
 
struct CNMemoryProfile CNProfileOfFixedStringPool (void)
 Get memory usage information. More...
 

Detailed Description

Define CNFixedString class.

Copyright
Copyright (C) 2012 Steel Wheels Project

Typedef Documentation

typedef CNBoolean(* CNVisitFixedStringPoolFuncRef)(const struct CNFixedString *str, void *userdata)

Function to visit fixed-string pool and get fixed-string from it

Function Documentation

void CNSetupFixedStringPool ( void  )

Initialize pool for CNFixedString.

Note
You have to call this method before using CNFixedString
struct CNFixedString* CNAllocateFixedString ( size_t  len,
const unsigned char *  str 
)

Allocate CNFixedString object.

Returns
Allocated string
Parameters
lenLength of source string
strSource string
static size_t CNLengthOfFixedString ( const struct CNFixedString src)
inlinestatic

Get length of CNFixedString.

Returns
Length of string
Parameters
srcSource string

References CNFixedString::length.

Referenced by CNPutFixedStringToText().

static const unsigned char* CNContentOfFixedString ( const struct CNFixedString src)
inlinestatic

Get content of CNFixedString.

Returns
Content of string
Parameters
srcSource string

References CNFixedString::content.

Referenced by CNPutFixedStringToText().

static uint64_t CNUniqueIdOfFixedString ( const struct CNFixedString src)
inlinestatic

Get hash value of CNFixedString.

Returns
Hash value of string
Parameters
srcSource string

References CNFixedString::uniqId.

static CNBoolean CNIsSameFixedString ( const struct CNFixedString s0,
const struct CNFixedString s1 
)
inlinestatic

Check 2 string has same context or not.

Return values
TRUEThey have same contexts.
FALSEThey have different contexts
Parameters
s0Source string 0
s1Source string 1
CNBoolean CNForeachFixedStringInFixedStringPool ( CNVisitFixedStringPoolFuncRef  visitfunc,
void *  userdata 
)

Get all fixed string in fixed string pool.

Return values
TRUEEvery elements are visited
FALSEEvery elements are NOT visited
Parameters
visitfuncFunction to visit each fixed string
userdataData pointer to be used in the visit function
struct CNFixedString* CNSearchFixedStringById ( uint64_t  src)

Search fixed-string in pool by the id.

Return values
strThe string which has the id
NULLThere are no string which has the id
Parameters
srcSource fixed-string id
struct CNFixedString* CNSearchFixedStringByUTF8String ( size_t  srclen,
const unsigned char *  srcstr 
)

Search fixed-string in pool by the string.

Return values
strThe string which has the id
NULLThere are no string which has the id
Parameters
srclenLength of source string
srcstrSource UTF8 string
void CNPrintFixedString ( FILE *  outfp,
const struct CNFixedString src 
)

Print fixed-string.

Parameters
outfpOutput file stream
srcSource fixed-string
struct CNMemoryProfile CNProfileOfFixedStringPool ( void  )

Get memory usage information.

Returns
Profile of memory