Translates text resource descriptions into C files.
TextResource-Compiler | Translates text resource descriptions into C files. |
Copyright | This program is free software. |
Files | |
C-kern/ | Implementation file TextResource-Compiler. |
Helper | |
constants | |
log | |
print_version | Prints version information |
print_usage | Prints usage information. |
print_error | Prints formatted error string. |
xmlattribute_t | Name and value of an xml attribute. |
lifetime | |
xmlattribute_INIT | Static initializer. |
outconfig_fctparam_t | Holds function parameter for <outconfig_C>. |
lifetime | |
outconfig_fctparam_INIT | Initializes outconfig_fctparam_t with a name, value and format. |
outconfig_e | Types of different outputs the text resource compiler supports. |
outconfig_t | Contains control information how the generated output is to be formatted. |
textresource_language_t | A language selector for textresource_text_t. |
lifetime | |
textresource_language_INIT | Static initializer. |
textresource_parameter_t | A parameter for textresource_text_t. |
lifetime | |
textresource_parameter_FREE | Static initializer. |
textresource_textatom_t | An atomic text element string content referenced by textresource_condition_t. |
lifetime | |
textresource_textatom_INIT | Static initializer. |
textresource_textatom_INIT | Static initializer. |
textresource_textatom_INIT_FCTPARAM | Static initializer. |
textresource_condition_t | A condition which selects or deselects the contained textresource_textatom_t. |
condition | The C99-condition which is checked in the generated source code. |
lifetime | |
add | |
textresource_langref_t | A reference to a language and container for one or more textresource_condition_t. |
lifetime | |
textresource_langref_INIT | Static initializer. |
add | |
textresource_text_t | A single text resource description. |
lifetime | |
update | |
textresource_paramtype_t | |
lifetime | |
textresource_paramtype_INIT | Static initializer. |
textresource_t | Defines memory representation of parsed text resource description. |
languages | Contains list of textresource_language_t. |
textlist | Contains list of textresource_text_t. |
lifetime | |
textresource_FREE | Static initializer. |
init_textresource | Initializes textresource_t object. |
add | |
textresource_reader_t | Reads textual representation of text resource. |
helper | |
skip_spaceandcomment | Skips comments until next non space character. |
parser | |
parse_version_textresourcereader | Skips comments until “<textresource version=’4’>” is found. |
parse_outconfigC_utf8reader | Parses control information for generated output. |
parse_outconfigCtable_utf8reader | Parses control information for generated output. |
parse_header_textresourcereader | Parses all header information. |
parse_contentversion3_textresourcereader | Parses content of “<textresource version=’3’> </textresource>”. |
lifetime | |
textresource_reader_FREE | Static initializer. |
free_textresourcereader | Closes file and frees memory of textresource_t. |
init_textresourcereader | Opens file and reads header for the version information. |
textresource_writer_t | Writes programming language representation of text resource. |
lifetime | |
textresource_writer_FREE | Static initializer. |
write |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2013 Jörg Seebohn
Implementation file TextResource-Compiler.
constants | |
log | |
print_version | Prints version information |
print_usage | Prints usage information. |
print_error | Prints formatted error string. |
struct xmlattribute_t
Name and value of an xml attribute.
<entity attr_name="attr_value" ...>.
lifetime | |
xmlattribute_INIT | Static initializer. |
#define xmlattribute_INIT( name ) { (name), string_FREE }
Static initializer. Sets xmlattribute_t name to parameter value name and its value to undefined.
struct outconfig_fctparam_t
Holds function parameter for <outconfig_C>. A function parameter is describes as
<fctparam name="ERRSTR" value="(const char*)str_errorcontext(error_maincontext(), err)" format="%s"/>
where name is stgring it referenced with in a text resource description. The value is used as function call to get the parameter value. And format is the printf format description used to log the value.
lifetime | |
outconfig_fctparam_INIT | Initializes outconfig_fctparam_t with a name, value and format. |
outconfig_e | Types of different outputs the text resource compiler supports. |
struct textresource_language_t
A language selector for textresource_text_t.
lifetime | |
textresource_language_INIT | Static initializer. |
struct textresource_parameter_t
A parameter for textresource_text_t.
lifetime | |
textresource_parameter_FREE | Static initializer. |
struct textresource_textatom_t
An atomic text element string content referenced by textresource_condition_t. It describes either a parameter reference and its formatting or a simple text string.
lifetime | |
textresource_textatom_INIT | Static initializer. |
textresource_textatom_INIT | Static initializer. |
textresource_textatom_INIT_FCTPARAM | Static initializer. |
#define textresource_textatom_INIT( string ) { 0, textresource_textatom_STRING, { string } }
Static initializer. Initializes textresource_textatom_t as type textresource_textatom_STRING.
#define textresource_textatom_INIT_PARAM( parameter ) { 0, textresource_textatom_PARAMETER, { .param = { parameter, 0, 0 } } }
Static initializer. Initializes textresource_textatom_t as type textresource_textatom_PARAMETER.
#define textresource_textatom_INIT_FCTPARAM( fctparam ) { 0, textresource_textatom_FCTPARAM, { .fctparam = { fctparam } } }
Static initializer. Initializes textresource_textatom_t as type textresource_textatom_FCTPARAM.
struct textresource_condition_t
A condition which selects or deselects the contained textresource_textatom_t. The condition indicates a conditional string if it is not empty. If condition contains “else” it is the last entry of a switch
((condition1): "str1" (cond2): ... else: "strX")
Every switch ends in an else. If the user does not supply one an artifical textresource_condition_t is created with condition set to “else” and an empty atomlist.
string_t condition
The C99-condition which is checked in the generated source code. If the condition is true the text is used and all other conditional texts until after the next encountered “else” are skipped. A condition set to “else” marks the last entry of a conditional sequence.
struct textresource_langref_t
A reference to a language and container for one or more textresource_condition_t.
lifetime | |
textresource_langref_INIT | Static initializer. |
add |
struct textresource_text_t
A single text resource description. The set of all defined text resources is stored in textresource_t.
A textresource_text_t has 0 or more textresource_parameter_t stored in paramlist. It contains one or more language specific text definitions stored as textresource_langref_t in langlist. A textresource_langref_t contains one or more textresource_condition_t which define a condition under which a string has to be used or not.
struct textresource_paramtype_t
lifetime | |
textresource_paramtype_INIT | Static initializer. |
struct textresource_t
Defines memory representation of parsed text resource description.
languages | Contains list of textresource_language_t. |
textlist | Contains list of textresource_text_t. |
lifetime | |
textresource_FREE | Static initializer. |
init_textresource | Initializes textresource_t object. |
add |
slist_t languages
Contains list of textresource_language_t.
slist_t textlist
Contains list of textresource_text_t.
static int init_textresource( /*out*/textresource_t * textres, const char * read_from_filename )
Initializes textresource_t object.
struct textresource_reader_t
Reads textual representation of text resource. The content of the textfile is stored into a structure of type textresource_t.
helper | |
skip_spaceandcomment | Skips comments until next non space character. |
parser | |
parse_version_textresourcereader | Skips comments until “<textresource version=’4’>” is found. |
parse_outconfigC_utf8reader | Parses control information for generated output. |
parse_outconfigCtable_utf8reader | Parses control information for generated output. |
parse_header_textresourcereader | Parses all header information. |
parse_contentversion3_textresourcereader | Parses content of “<textresource version=’3’> </textresource>”. |
lifetime | |
textresource_reader_FREE | Static initializer. |
free_textresourcereader | Closes file and frees memory of textresource_t. |
init_textresourcereader | Opens file and reads header for the version information. |
static int parse_header_textresourcereader( textresource_reader_t * reader )
Parses all header information. First parse_version_textresourcereader is called to find the beginning of the header. Then all additional xml-header-tags are parsed.
static int free_textresourcereader( textresource_reader_t * reader )
Closes file and frees memory of textresource_t.
static int init_textresourcereader( /*out*/textresource_reader_t * reader, const char * filename )
Opens file and reads header for the version information. The parameter filename is stored in textresource_reader_t as a reference so do not delete filename as long as reader is alive.
struct textresource_writer_t
Writes programming language representation of text resource. This writer implements the C language output.
lifetime | |
textresource_writer_FREE | Static initializer. |
write |
Prints version information
static void print_version( void )
Prints usage information.
static void print_usage( void )
Prints formatted error string.
static void print_error( const char * format, ... )
Name and value of an xml attribute.
struct xmlattribute_t
Static initializer.
#define xmlattribute_INIT( name ) { (name), string_FREE }
Holds function parameter for outconfig_C.
struct outconfig_fctparam_t
Initializes outconfig_fctparam_t with a name, value and format.
#define outconfig_fctparam_INIT( name, value, format ) { arraystf_node_INIT(name.size, name.addr), value, format }
Contains control information how the generated output is to be formatted.
struct outconfig_t
A language selector for textresource_text_t.
struct textresource_language_t
A single text resource description.
struct textresource_text_t
Static initializer.
#define textresource_language_INIT( name ) { string_INIT(name->size, name->addr), 0 }
A parameter for textresource_text_t.
struct textresource_parameter_t
Static initializer.
#define textresource_parameter_FREE { arraystf_node_INIT(0,0), 0, 0, typemodifier_PLAIN }
An atomic text element string content referenced by textresource_condition_t.
struct textresource_textatom_t
A condition which selects or deselects the contained textresource_textatom_t.
struct textresource_condition_t
Static initializer.
#define textresource_textatom_INIT( string ) { 0, textresource_textatom_STRING, { string } }
Static initializer.
#define textresource_textatom_INIT_FCTPARAM( fctparam ) { 0, textresource_textatom_FCTPARAM, { .fctparam = { fctparam } } }
The C99-condition which is checked in the generated source code.
string_t condition
A reference to a language and container for one or more textresource_condition_t.
struct textresource_langref_t
Static initializer.
#define textresource_langref_INIT( language ) { slist_INIT, 0, (language) }
struct textresource_paramtype_t
Static initializer.
#define textresource_paramtype_INIT( cstr, modifier, format ) textresource_paramtype_INIT2(cstr,modifier,format,"")
Defines memory representation of parsed text resource description.
struct textresource_t
Contains list of textresource_language_t.
slist_t languages
Contains list of textresource_text_t.
slist_t textlist
Static initializer.
#define textresource_FREE { 0, 0, 0, slist_INIT, slist_INIT, outconfig_FREE }
Initializes textresource_t object.
static int init_textresource( /*out*/textresource_t * textres, const char * read_from_filename )
Reads textual representation of text resource.
struct textresource_reader_t
Skips comments until next non space character.
static int skip_spaceandcomment( textresource_reader_t * reader )
Skips comments until “textresource version=’4’” is found.
static int parse_version_textresourcereader( textresource_reader_t * reader )
Parses control information for generated output.
static int parse_outconfigC_utf8reader( textresource_reader_t * reader )
Parses control information for generated output.
static int parse_outconfigCtable_utf8reader( textresource_reader_t * reader )
Parses all header information.
static int parse_header_textresourcereader( textresource_reader_t * reader )
Parses content of “textresource version=’3’ /textresource”.
static int parse_contentversion3_textresourcereader( textresource_reader_t * reader )
Static initializer.
#define textresource_reader_FREE { textresource_FREE, utf8reader_FREE } ;
Closes file and frees memory of textresource_t.
static int free_textresourcereader( textresource_reader_t * reader )
Opens file and reads header for the version information.
static int init_textresourcereader( /*out*/textresource_reader_t * reader, const char * filename )
Writes programming language representation of text resource.
struct textresource_writer_t
Static initializer.
#define textresource_writer_FREE { 0, file_FREE }