Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATStringTableCore.cpp Source File

CATStringTableCore.cpp

Go to the documentation of this file.
00001 /// \file CATStringTableCore.cpp
00002 /// \brief Core String table for CAT library
00003 /// \ingroup CAT
00004 ///
00005 /// Copyright (c) 2007-2008 by Michael Ellison.
00006 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00007 ///
00008 // $Author: mikeellison $
00009 // $Date: 2008-01-23 06:02:38 -0600 (Wed, 23 Jan 2008) $
00010 // $Revision:   $
00011 // $NoKeywords: $
00012 
00013 #include "CATStringTableCore.h"
00014 
00015 
00016 struct CATStringEntry
00017 {
00018     CATResult       resultCode;
00019     const CATWChar* resultString;
00020 };
00021 
00022 /// \todo
00023 /// Switch this to use a std::map when we're loading it in from a file
00024 ///
00025 /// Temporary table of resultCode->String mapp entries
00026 const CATStringEntry kCATStringEntries[] = 
00027 {
00028     {CAT_SUCCESS,                       L"Success"},
00029     
00030     {CAT_STATUS,                        L"Status"},
00031     {CAT_STAT_FILE_AT_EOF,              L"The file is at EOF"},
00032     {CAT_STAT_MULTIPLE_PROCS,           L"Multiple matching processes found."},
00033     {CAT_STAT_PATH_NO_FILE,             L"No filename present."},
00034     {CAT_STAT_PATH_NO_DIRECTORY,        L"No directory present."},
00035     {CAT_STAT_PATH_IS_DIRECTORY,        L"The path is a directory."},
00036     {CAT_STAT_PATH_IS_FILE,             L"The path is a file."},
00037     {CAT_STAT_PROMPT_OK,                L"OK"},
00038     {CAT_STAT_PROMPT_YES,               L"Yes"},
00039     {CAT_STAT_PROMPT_NO,                L"No"},
00040     {CAT_STAT_PROMPT_CANCEL,            L"Cancel"},
00041     {CAT_STAT_IN_PROGRESS,              L"Progress"},
00042     {CAT_STAT_IMAGE_ALREADY_LOADED,     L"Image already loaded."},
00043     {CAT_STAT_CONTROL_IMAGE_SIZE_MISMATCH, L"Image size mismatch in control."},
00044     {CAT_STAT_SKIN_WINDOW_ALREADY_OPEN, L"Window already open."},
00045 
00046 
00047     {CAT_STR_EMPTY,                     L""},
00048     {CAT_STR_USAGE,                     L"Usage:"},
00049     {CAT_STR_HELPDESC,                  L"Display Help."},    
00050 
00051     {CAT_ERROR,                         L"Error"},
00052     {CAT_ERR_NOT_IMPLEMENTED,           L"Feature not yet implemented."},
00053     {CAT_ERR_FILE_NOT_FOUND,            L"File not found."},
00054     {CAT_ERR_UNABLE_TO_OPEN_PROCESS,    L"Unable to open process."},
00055     {CAT_ERR_REMOTE_ALLOC_RAM,          L"Unable to allocate memory in remote process."},
00056     {CAT_ERR_REMOTE_WRITE,              L"Unable to write to remote process."},
00057     {CAT_ERR_REMOTE_CREATE_THREAD,      L"Unable to create a thread in the remote process."},
00058     {CAT_ERR_REMOTE_THREAD_TIMEOUT,     L"Remote thread timed out."},
00059     {CAT_ERR_REMOTE_THREAD_INVALID_EXIT,L"Remote thread exited with an error."},
00060     {CAT_ERR_PROCESS_CREATE,            L"Error creating process"},
00061     {CAT_ERR_INVALID_PARAM,             L"Invalid parameter"},
00062     {CAT_ERR_OUT_OF_MEMORY,             L"Out of memory"},
00063     {CAT_ERR_FILE_OPEN,                 L"Error opening file."},
00064     {CAT_ERR_FILE_READ,                 L"Error reading from file"},
00065     {CAT_ERR_FILE_HAS_OPEN_SUBSTREAMS,  L"Attempting to close a file with open substreams."},
00066     {CAT_ERR_FILE_NOT_OPEN,             L"The file has not been opened."},
00067     {CAT_ERR_FILE_UNSUPPORTED_MODE,     L"The requested open mode is not supported."},
00068     {CAT_ERR_FILE_WRITE,                L"Error writing to file."},
00069     {CAT_ERR_FILE_GET_POSITION,         L"Error retrieving file position."},
00070     {CAT_ERR_FILE_SEEK,                 L"Error seeking within file."},
00071     {CAT_ERR_FILE_SET_POSITION,         L"Error setting the file position."},
00072     {CAT_ERR_OPENING_SUBSTREAM,         L"Opening a substream is not a valid operation."},
00073     {CAT_ERR_CLOSING_SUBSTREAM,         L"Closing a substream is not a valid operation."},
00074     {CAT_ERR_SUBSTREAM_NO_PARENT,       L"Substream has no parent."},
00075     {CAT_ERR_WRITE_PAST_SPECIFIED_END,  L"A write request was made past the end of a substream."},
00076     {CAT_ERR_SEEK_PAST_SPECIFIED_END,   L"A seek request was made past the end of a substream."},
00077     {CAT_ERR_STRINGTABLE_NOT_FOUND,     L"Stringtable was not found for removal."},
00078     {CAT_ERR_CMD_TABLE_INVALID,         L"Invalid command table for command line parsing."},
00079     {CAT_ERR_CMD_INVALID_SWITCH,        L"Invalid switch on command line."},
00080     {CAT_ERR_CMD_NO_STRINGTABLE,        L"No string table."},
00081     {CAT_ERR_PARSE_CALLBACK_ABORT,      L"Callback during cmd line parsing aborted."},
00082     {CAT_ERR_ENUM_PROCS,                L"An error occurred enumerating processes."},
00083     {CAT_ERR_NO_MATCHING_PROC,          L"No matching process found."},
00084     {CAT_ERR_READING_TARGET_EXEC,       L"Error reading target executable."},
00085     {CAT_ERR_EXE_NOT_PE_FORMAT,         L"Target is not in Portable Executable format."},
00086     {CAT_ERR_CMDREQ_GROUP,              L"Required command-line group not found."},
00087     {CAT_ERR_CMDREQ_EXCLUSIVE_GROUP,    L"Multiple options set in exclusive group on command line."},
00088     {CAT_ERR_CMDREQ_OP,                 L"Required operand not found on command line."},
00089     {CAT_ERR_CMDREQ_SWITCH,             L"Required switch not found on command line."},
00090     {CAT_ERR_CMD_SWITCH_NO_ARG,         L"A switch on the command line is missing a required argument."},
00091     {CAT_ERR_UNPATCH_TIMEOUT,           L"Timed out waiting for target process patch."},
00092     {CAT_ERR_HOOK_PROTECT_FAILED,       L"Setting memory protections failed when hooking function."},
00093     {CAT_ERR_HOOK_NOT_FOUND,            L"Hook target function not found."},
00094     {CAT_ERR_HOOK_NOT_ENOUGH_BYTES,     L"Not enough bytes for push/jmp in hook."},
00095     {CAT_ERR_INTERCEPT_NO_DSOUND,       L"Could not find DirectSound DLL."},
00096     {CAT_ERR_XML_CREATE_FAILED,         L"Could not create XML object."},
00097     {CAT_ERR_XML_INVALID_ATTRIBUTE,     L"Invalid attribute in XML."},
00098     {CAT_ERR_XML_PARSER_INVALID_PATH,   L"Invalid XML path."},
00099     {CAT_ERR_XML_PARSER_OUT_OF_MEMORY,  L"XML Parser out of memory."},
00100     {CAT_ERR_XML_INVALID_XML,           L"Invalid XML file."},
00101     {CAT_ERR_IMAGE_NULL,                L"Null image."},
00102     {CAT_ERR_IMAGE_INVALID_SUB_POSITION,L"Invalid sub-image position."},
00103     {CAT_ERR_IMAGE_INVALID_SIZE,        L"Invalid image size."},
00104     {CAT_ERR_IMAGE_MUST_INITIALIZE,     L"Must initialize image first."},
00105     {CAT_ERR_IMAGE_FILL_OUT_OF_BOUNDS,  L"Image fill request is out of bounds."},
00106     {CAT_ERR_IMAGE_OPERATION_INVALID_ON_ROOT, L"The image operation is invalid on root image."},
00107     {CAT_ERR_IMAGE_EMPTY,               L"The image is empty."},
00108     {CAT_ERR_IMAGE_OUT_OF_RANGE,        L"Out of range of image size."},
00109     {CAT_ERR_IMAGE_OVERLAY_OUT_OF_BOUNDS, L"Image overlay out of range."},
00110     {CAT_ERR_PNG_ERROR_CREATING_READ,   L"Error creating read struct for .png image."},
00111     {CAT_ERR_PNG_UNSUPPORTED_FORMAT,    L"Unsupported PNG format - 3 or 4 channel only."},
00112     {CAT_ERR_IMAGE_UNKNOWN_FORMAT,      L"Unsupported image format."},
00113     {CAT_ERR_PNG_CORRUPT,               L".PNG image file is corrupt."},
00114     {CAT_ERR_PNG_ERROR_CREATING_WRITE,  L"Error creating write struct for .png image."},
00115     {CAT_ERR_PNG_WARNING,               L"Warning received from .png library."},
00116     {CAT_ERR_MUTEX_INVALID_HANDLE,      L"Invalid mutex handle."},
00117     {CAT_ERR_MUTEX_TIMEOUT,             L"Mutex timed out."},
00118     {CAT_ERR_MUTEX_WAIT_ERROR,          L"Error waiting on mutex."},
00119     {CAT_ERR_SIGNAL_INVALID_HANDLE,     L"Invalid handle for signal."},
00120     {CAT_ERR_SIGNAL_TIMEOUT,            L"Signal timed out."},
00121     {CAT_ERR_SIGNAL_WAIT_ERROR,         L"Error waiting for signal."},
00122     {CAT_ERR_FILE_ALREADY_EXISTS,       L"File already exists."},
00123     {CAT_ERR_PATH_EMPTY,                L"The path is empty."},
00124     {CAT_ERR_FILE_DOES_NOT_EXIST,       L"The file does not exist."},
00125     {CAT_ERR_FILE_IS_DIRECTORY,         L"The path is a directory."},
00126     {CAT_ERR_DIR_DOES_NOT_EXIST,        L"The directory does not exist."},
00127     {CAT_ERR_DIR_IS_FILE,               L"The path is a file."},
00128     {CAT_ERR_NULL_PARAM,                L"Null parameter."},
00129     {CAT_ERR_FILESYSTEM_CREATE_DIR,     L"Filesystem is unable to create the directory."},
00130     {CAT_ERR_PATH_DOES_NOT_EXIST,       L"The path does not exist."},
00131     {CAT_ERR_FIND_NO_MATCHES,           L"No matches found."},
00132     {CAT_ERR_FIND_CALL_FINDFIRST,       L"Must call FindFirst before FindNext."},
00133     {CAT_ERR_FIND_END,                  L"No more matches."},
00134     {CAT_ERR_SKIN_XPIN_MISUSE,          L"XPos must be positive, XPin must be negative, and Width may not be used for scaled skin controls."},
00135     {CAT_ERR_SKIN_YPIN_MISUSE,          L"YPos must be positive, YPin must be negative, and Width may not be used for scaled skin controls."},
00136     {CAT_ERR_QUEUE_EMPTY,               L"Queue is empty."},
00137     {CAT_ERR_FILE_CORRUPTED,            L"File is corrupted."},
00138     {CAT_ERR_FILE_ACCESS_DENIED,        L"Access denied to file."},
00139     {CAT_ERR_EXECUTE_FAILED,            L"Failed to execute file."},
00140     {CAT_ERR_WINDOW_CLASSREG_FAILED,    L"Window class registration failed."},
00141     {CAT_ERR_WINDOW_CREATE_FAILED,      L"Window creation failed."},
00142     {CAT_ERR_STACK_EMPTY,               L"Stack is empty."},
00143     {CAT_ERR_NO_HELP_AVAILABLE,         L"No help available."},
00144     {CAT_ERR_FILEOPEN_CANCELLED,        L"File Open dialog was cancelled."},
00145     {CAT_ERR_FILESAVE_CANCELLED,        L"File Save dialog was cancelled."},
00146     {CAT_ERR_COMBO_MENU_NOT_FOUND,      L"Combo control is missing a menu."},
00147     {CAT_ERR_COMBO_EDIT_NOT_FOUND,      L"Combo control is missing an edit box."},
00148     {CAT_ERR_CONTROL_NO_IMAGE,          L"No image found for control."},    
00149     {CAT_ERR_GUIFACTORY_UNKNOWN_TYPE,   L"GUIFactory - control type not found!"},
00150     {CAT_ERR_LIST_ITEM_NOT_FOUND,       L"Item not found in list."},
00151     {CAT_ERR_LIST_OUT_OF_RANGE,         L"Item out of range in list."},
00152     {CAT_ERR_SKIN_WINDOW_NOT_FOUND,     L"Window skin not found."},
00153     {CAT_ERR_SKIN_WINDOW_NOT_OPEN,      L"Window not open."},
00154     {CAT_ERR_INVALID_TAB,               L"Invalid tab index."},
00155     {CAT_ERR_CONTROL_NOT_FOUND,         L"Control not found."},
00156     {CAT_ERR_CMD_NOT_FOUND,             L"Command not found."},
00157     {CAT_ERR_TREE_ITEM_NOT_FOUND,       L"Tree item not found."},
00158     {CAT_ERR_TREE_INSERT_ERROR,         L"Error inserting item into tree."},
00159     {CAT_ERR_TREE_REMOVE_ERROR,         L"Error removing item from tree."},
00160     {CAT_ERR_TREE_SET_ITEM_ERROR,       L"Error setting tree item."},
00161     {CAT_ERR_IMAGELIST_FAILED,          L"Imagelist failed."},
00162     {CAT_ERR_PREFS_NO_FILESYSTEM,       L"No filesystem for prefs."},
00163     {CAT_ERR_STREAM_INVALID,            L"Stream invalid."},
00164     {CAT_ERR_NOT_INITIALIZED,           L"Object is not initialized."},
00165     {CAT_ERR_CORE_LAST,                 0}
00166 };
00167 
00168 CATStringTableCore::CATStringTableCore()
00169 : CATStringTable()
00170 {
00171 }
00172 
00173 CATStringTableCore::~CATStringTableCore()
00174 {
00175 }
00176 
00177 const CATWChar* CATStringTableCore::GetString(CATResult     stringId,
00178                                               CATLangId     languageId) const
00179 {
00180     // Check subtables
00181     const CATWChar* stringVal = CATStringTable::GetString(stringId,languageId);    
00182     if (stringVal)
00183         return stringVal;
00184 
00185     // Not in subtables, scan local table. We're currently ignoring language id here.
00186     CATStringEntry* entry = (CATStringEntry*)&kCATStringEntries;
00187     while (entry->resultCode != CAT_ERR_CORE_LAST)
00188     {
00189         if (stringId == entry->resultCode)
00190         {
00191             return entry->resultString;
00192         }
00193         ++entry;
00194     }
00195     
00196     // Just plain not found.
00197     return 0;
00198 }

Generated on Mon Feb 11 04:09:49 2008 for Game Accessibility Suite by doxygen 1.5.4