Many systems, components and applications deal with pre-defined, well known string constants. For example, parsing and manipulating text containing structure mostly requires comparisons against standard string constants.
In a complex system, composed of a large number of objects, there may also be a need to pass strings between objects, and to route processing depending on the value of some string. The implementation of the HTTP transport framework and the XML framework are examples within Symbian platform where such intense string handling is required.
To improve efficiency, Symbian platform uses the idea of the string pool.
A string pool is referenced through an
A string pool is a mechanism for storing strings in a particular way that makes the comparison of strings a very fast operation. It is particularly efficient at handling strings that can be set up at program compile time. For example, strings that identify lexical elements in a structured text. Typically, they are well known strings that are likely to be used very often in a given context.
Such strings are organised into tables, and each string within a table can be referenced by an index value, which can be symbolised by an enum. Such tables are referred to as static string tables (See
The advantages of representing string constants in such a way are:
avoiding a proliferation of duplicate strings throughout a component or an application; typically there is one string pool per thread, and one copy of a string
allowing string constants to be represented by integer values
allowing strings to be passed between objects by passing integer values, wrapped in a class (any one of the
allowing strings to be compared by comparing the integer values.
Internally, a string pool uses hash tables to reference strings.
Static string tables and string constants can be added dynamically to the string pool, for example, at run time. However, there is always a performance penalty while adding either a static or a dynamic string to the string pool as the hash tables need to be updated. This means that it is better to add static string tables at string pool initialisation time, as this is the best time to absorb the overhead.
The string pool as supplied by Symbian platform supports any strings that can be represented by a
Within the string pool, strings are of two types - case sensitive and case insensitive. This affects the way strings are compared. Case insensitivity implies that strings are folded for the purpose of comparison.
A string pool can contain up to 4,096 static string tables, and each table can represent up 26,2144 strings.
Static string tables are defined and built at compile time. They are represented by a
The following diagram illustrates a general picture. Note that the strings in any given string table are deemed to be either case sensitive or case insensitive, and this governs how comparisons are made.
As the name implies, a static string table is declared as a
The Perl script,
Following is a simple example of
The main points to note are:
the keyword fstringtable is used to define the name of the class that contains the string table declaration and the enum value symbols. The class name itself follows the keyword. For example,
Note that you can include underscore characters in the class name. For example,
the symbols
all statements starting with a # are comments and are completely ignored. However # characters can appear in a string. For example
all statements starting with a ! are comments that are inserted into the generated header file.
Running the Perl script with
The table itself is the static data member
Many systems, components and applications deal with pre-defined, well known +string constants. For example, parsing and manipulating text containing structure +mostly requires comparisons against standard string constants.
+In a complex system, composed of a large number of objects, there may also +be a need to pass strings between objects, and to route processing depending +on the value of some string. The implementation of the HTTP transport framework +and the XML framework are examples within the Symbian platform where such +intense string handling is required.
+To improve efficiency, the Symbian platform uses the idea of the string +pool.
+A string pool is referenced through an
A string pool is a mechanism for storing strings in a particular way that +makes the comparison of strings a very fast operation. It is particularly +efficient at handling strings that can be set up at program compile time. +For example, strings that identify lexical elements in a structured text. +Typically, they are well known strings that are likely to be used very often +in a given context.
+Such strings are organised into tables, and each string within a table
+can be referenced by an index value, which can be symbolised by an enum. Such
+tables are referred to as static string tables (See
The advantages of representing string constants in such a way are:
+avoiding a proliferation +of duplicate strings throughout a component or an application; typically there +is one string pool per thread, and one copy of a string
allowing string constants +to be represented by integer values
allowing strings to
+be passed between objects by passing integer values, wrapped in a class (any
+one of the
allowing strings to +be compared by comparing the integer values.
Internally, a string pool uses hash tables to reference strings.
+Static string tables and string constants can be added dynamically to the +string pool, for example, at run time. However, there is always a performance +penalty while adding either a static or a dynamic string to the string pool +as the hash tables need to be updated. This means that it is better to add +static string tables at string pool initialisation time, as this is the best +time to absorb the overhead.
+The string pool as supplied
+by the Symbian platform supports any strings that can be represented
+by a
Within the string pool, +strings are of two types - case sensitive and case insensitive. This affects +the way strings are compared. Case insensitivity implies that strings are +folded for the purpose of comparison.
A string pool can contain +up to 4,096 static string tables, and each table can represent up 26,2144 +strings.
Static string tables are defined and built at compile time.
+They are represented by a
The following diagram illustrates a general picture. Note that the strings +in any given string table are deemed to be either case sensitive or case insensitive, +and this governs how comparisons are made.
As the name implies, a static string table is declared as a
The
+Perl script,
Following is a simple example of
The main points to note are:
the keyword fstringtable is
+used to define the name of the class that contains the string table declaration
+and the enum value symbols. The class name itself follows the keyword. For
+example,
Note that you can include
+underscore characters in the class name. For example,
the symbols
all statements starting
+with a # are comments and are completely ignored. However # characters
+can appear in a string. For example
all statements starting +with a ! are comments that are inserted into the generated header file.
Running the Perl script with
The table itself is the static data member