TEXTLOADER
Classes
- vorlib::textloader
- vorlib::textloader_e (exception)
Files
- textloader.h
- textloader.cpp
If you want to load texts from file(s), for example for easier translation, you can use this class. You can load more files by that and then get text identified by their file and name. Only thing that have to be done for translating is to translate that files.
Interface
-
load && operator<<
Loads another file to memory, so it can be asked for its texts. You can do multiple loads like loader << some_file << another file.
-
clear
Removes all files (and therefore texts) from memory.
-
get_text
Returns wanted text. Gets two arguments, file identificator and text's name.
File format
The files it loads looks like this. The first line contains file identificator (should be without spaces and special characters). Next line are theese. Each starting with # is comment. Line with text starts with name of the text (again, without spaces and special chars). Then, the text continues as it is, afer a space. If you need more-line text, just continue on another line witch you start with ~. So the more-line text would look like this:
name_of_the_text first line of it
~another line
~and next one
Error handling
Like everywhere in vorlib, it is done by exception and its heirs. This heir is texloader_e and codes are below:
- 1: File not found. You provided wrong path, or it was deleted by some user.
- 2: File couldn't be closed. This should never happen on a read-only opened file, however I test it anyway.
- 3: No text after name. If you want an empty text (really unprobable, that you would wand user to see nothing), just add there one more space. It won't be seen as well.
- 4: Duplicit text name. It means that the text contains two (or more) texts with the same name,
- 5: No file name found. Provide one, so the file can be identified.
- 6: File name duplicit. You already loaded file with that name (maybe this one)
- 7: File or text does not exist. This is throwed by get_text and means you want some text that is not loaded.