1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

text: naming & doc fixes

This commit is contained in:
tg(x) 2011-05-28 19:39:42 +02:00
parent 7ca1dd5198
commit 1468356da4
4 changed files with 54 additions and 52 deletions

View file

@ -88,9 +88,9 @@ typedef enum
typedef struct
{
/// Length of the data pointed to by ptr
size_t length;
size_t length;
/// pointer to the data
const char *ptr;
const char *ptr;
} psycString;
typedef struct

View file

@ -330,7 +330,7 @@ void psyc_setParseBuffer (psycParseState *state, psycString buffer)
* @see psycString
*/
static inline
void psyc_setParseBuffer2 (psycParseState *state, char *buffer, size_t length)
void psyc_setParseBuffer2 (psycParseState *state, const char *buffer, size_t length)
{
psycString buf = {length, buffer};
psyc_setParseBuffer(state, buf);
@ -358,7 +358,7 @@ void psyc_setParseListBuffer (psycParseListState *state, psycString buffer)
}
static inline
void psyc_setParseListBuffer2 (psycParseListState *state, char *buffer, size_t length)
void psyc_setParseListBuffer2 (psycParseListState *state, const char *buffer, size_t length)
{
psycString buf = {length, buffer};
psyc_setParseListBuffer(state, buf);

View file

@ -26,7 +26,7 @@ typedef enum
/// Text template parsing & rendering complete.
PSYC_TEXT_COMPLETE = 0,
/// Text template parsing & rendering is incomplete, because the buffer was too small.
/// Another call is required to this function with a new buffer.
/// Another call is required to this function after setting a new buffer.
PSYC_TEXT_INCOMPLETE = 1,
} psycTextRC;
@ -48,8 +48,8 @@ typedef struct
{
size_t cursor; ///< current position in the template
size_t written; ///< number of bytes written to buffer
psycString template; ///< template to parse
psycString buffer; ///< buffer for writing to
psycString tmpl; ///< input buffer with text template to parse
psycString buffer; ///< output buffer for rendered text
psycString open;
psycString close;
} psycTextState;
@ -70,32 +70,32 @@ typedef psycTextValueRC (*psycTextCB)(const char *name, size_t len, psycString *
* Initializes the PSYC text state struct.
*
* @param state Pointer to the PSYC text state struct that should be initialized.
* @param template Text template to be parsed.
* @param tlen Length of template.
* @param buffer Buffer where the rendered text is going to be written.
* @param blen Length of buffer.
* @param tmpl Input buffer with text template to be parsed.
* @param tmplen Length of input buffer.
* @param buffer Output buffer where the rendered text is going to be written.
* @param buflen Length of output buffer.
*/
static inline
void psyc_initTextState (psycTextState *state,
char *template, size_t tlen,
char *buffer, size_t blen)
const char *tmpl, size_t tmplen,
char *buffer, size_t buflen)
{
state->cursor = 0;
state->written = 0;
state->template = (psycString) {tlen, template};
state->buffer = (psycString) {blen, buffer};
state->open = (psycString) {1, "["};
state->close = (psycString) {1, "]"};
state->cursor = 0;
state->written = 0;
state->tmpl = (psycString) {tmplen, tmpl};
state->buffer = (psycString) {buflen, buffer};
state->open = (psycString) {1, "["};
state->close = (psycString) {1, "]"};
}
/**
* Initializes the PSYC text state struct with custom open & closing braces.
* Initializes the PSYC text state struct with custom opening & closing braces.
*
* @param state Pointer to the PSYC text state struct that should be initialized.
* @param template Text template to be parsed.
* @param tlen Length of template.
* @param buffer Buffer where the rendered text is going to be written.
* @param blen Length of buffer.
* @param tmpl Input buffer with text template to be parsed.
* @param tmplen Length of input buffer.
* @param buffer Output buffer where the rendered text is going to be written.
* @param buflen Length of output buffer.
* @param open Opening brace.
* @param openlen Length of opening brace.
* @param close Closing brace.
@ -103,19 +103,21 @@ void psyc_initTextState (psycTextState *state,
*/
static inline
void psyc_initTextState2 (psycTextState *state,
char *template, size_t tlen,
char *buffer, size_t blen,
char *open, size_t openlen,
char *close, size_t closelen)
const char *tmpl, size_t tmplen,
char *buffer, size_t buflen,
const char *open, size_t openlen,
const char *close, size_t closelen)
{
state->template = (psycString) {tlen, template};
state->buffer = (psycString) {blen, buffer};
state->open = (psycString) {openlen, open};
state->close = (psycString) {closelen, close};
state->cursor = 0;
state->written = 0;
state->tmpl = (psycString) {tmplen, tmpl};
state->buffer = (psycString) {buflen, buffer};
state->open = (psycString) {openlen, open};
state->close = (psycString) {closelen, close};
}
/**
* Sets a new buffer in the PSYC text state struct.
* Sets a new output buffer in the PSYC text state struct.
*/
static inline
void psyc_setTextBuffer (psycTextState *state, psycString buffer)
@ -149,10 +151,10 @@ size_t psyc_getTextBytesWritten (psycTextState *state)
* string between these braces. Should the callback return
* PSYC_TEXT_VALUE_NOT_FOUND, the original template text is copied as is.
*
* Before calling this function psyc_initTextState or psyc_initTextState should
* be called to initialze the state struct. By default PSYC's "[" and "]" are
* used but you can provide any other brace strings such as "${" and "}" or
* "<!--" and "-->".
* Before calling this function psyc_initTextState should be called to initialize
* the state struct. By default PSYC's "[" and "]" are used but you can provide
* any other brace strings such as "${" and "}" or "<!--" and "-->" if you use
* the psyc_initTextState2 variant.
*
* @see http://about.psyc.eu/psyctext
**/