|
|
• Files |
Strings The TString class is one of the first classes I ever wrote in C++. It's development went hand-in-hand with the application that eventually became the console shell applet Terminus. Besides holding onto a string of characters, the TString class was always about parsing commands. Originally written to hold the 8-bit characters of the early Mac, eventually I wrote the conversion routines necessary to make it a full unicode implementation. The modern TString class manages an array of full unicode characters at runtime, UTF-32 from 0 to 0x1fffff code points. When it needs to render text on Mac it does the required conversion to UTF-16. When it needs to store characters it converts to and from UTF-8. All parsing, substitutions, and text editing are performed on full UTF-32 characters. There are a few escape sequences used even in UTF-32. I ignore them at the moment. In practice I'm seldom receiving anything that doesn't fit in UTF-16. If it ever becomes a problem I'll figure out how to handle it. TString has parsing routines that can identify and parse all the various scalar types, accommodate quoted tokens or pathname, find patterns, make substitutions, and manage insertions and deletions in a variety of ways. There's definitely a kitchen sink aspect to it but it's also incredibly helpful. The arithmetic operator+ is overridden to allow for concatenation of strings. Certain global helper functions, for example ulong2str will take a scalar as input and produce the corresponding TString as output. TScroll is a subclass of TString that encapsulates its own memory, up to 255 characters long (with room for the null terminator to round it out to 256). The advantage to TScroll is that it does not allocate memory, ever. As such it can be relied upon for certain kinds of exception processing. TLocalizer is a class that contains a string for every language supported on the Guildhall desktop. When a UI element needs to be drawn, the class will yield the correct language based upon what the user has selected. Currently that's just a choice of English and Français. I wish I could have gotten to Deutsch and Español but Apple was too quick to screw up macOS for me to get there. Maybe when I get Guildhall running on Windows again I can get to those. I explicitly chose to avoid the typical Xcode way to handle translations because I only wanted to do the work once, not once per platform. But I can easily add the Xcode option if I need to by putting a message ID for resource-driven strings into this class. TAlignment is a simple class that encapsulates an enumeration representing the various possible alignments of text, for example left-aligned, right-aligned, top-left-aligned, or justified. TCharacterSet is a bit of an anachronism. It was very useful in the original transition to unicode, translating from both the macOS and Windows extended character sets. It still has utility as a filtering mechanism for certain kinds of token processing. Constructible Classes
|