This file contains excerps from the sources, which are linked.
1. Definition of String
=>source: src_emC/emC/Base/types_def_common.h[tag=StringJc] /**This is the defintion of a reference to a String and a value and state information. * It is similar as the defintion of AddrVal_emC or the macro STRUCT_AddrVal_emC * but the address is a union because of different capabilities. It is written in the same kind. * * First element is a pointer with different types in the union. * * Second element is the length and flags, see in header emC/Base/StringBase_emC.h */ typedef struct StringJc_T { union CharSeqTypes_T { char const* str; #ifndef DEF_NO_StringUSAGE struct StringBuilderJc_t* bu; #ifdef DEF_CharSeqJcCapabilities struct ObjectJc_T const* obj; #ifdef __cplusplus class CharSequenceJc* csq; #endif #endif #endif } addr; VALTYPE_AddrVal_emC val; //Note: Use same type as in STRUCT_AddrVal_emC } StringJc;
2. Build operations as const
=>source: src_emC/emC/Base/types_def_common.h[tag=StringJc_Common] /**StringJc object containing null-values. */ extern_C StringJc const null_StringJc; /**StringJc object containing an empty String, ref to "", lenght = 0 */ extern_C StringJc const empty_StringJc; /**Initializer-Macro for constant StringJc, initialize the StringJc-reference to a zero-terminated text. * The length of the text * is not stored inside StringJc, the length bits are setted to kIs_0_terminated_StringJc * (it is the value of ,,mLength_StringJc,,), to detect this constellation. * @param TEXT should be a text-literal only. If it references a char-array, * a problem with persistence may existing. */ #define INIZ_z_StringJc(TEXT) { TEXT, kIs_0_terminated_StringJc} #define CONST_z_StringJc(TEXT) INIZ_z_StringJc(TEXT) /**Initializer-Macro for StringJc, initialize the StringJc-reference to a string literal. * The length of the literal is calculated via sizeof("text"). * @param TEXT should only be a text-literal. * If it references a char-array, the size is faulty * and problem with persistence may existing. */ #define INIZ_text_StringJc(TEXT) { TEXT, (int)(sizeof(TEXT)-1) } /**Initializer-Macro for constant StringJc, initialize the StringJc-reference to a text with known length. * Using this macro instead ,,CONST_StringJc(...),, saves calculation time to calculate the ,,strlen(),,. * @param TEXT should be a text-literal only. If it references a char-array, * a problem with persistence may existing. * @param LEN The length as number. Do not use methods like strlen(...) * to determine the length, because this is a const-initializing-macro. * In C++, methods are syntaxtically able to use, but it produces more machine code * and the definition cannot store in a const segment. In C it is an error. */ #define INIZ_StringJc(TEXT, LEN) { {TEXT}, LEN } #define CONST_StringJc(TEXT, LEN) INIZ_StringJc(TEXT, LEN) #define NULL_StringJc { {null}, 0}