00001 //=================================================================================================// 00002 // filename: RmMFCShaderKeywordLoader.h // 00003 // // 00004 // author: Toshiaki Tsuji // 00005 // ATI Research, Inc. // 00006 // 3D Application Research Group // 00007 // // 00008 // description: Text Editor Configuration Loader 00009 // // 00010 //=================================================================================================// 00011 // $File: //depot/3darg/Tools/RenderMonkey/sdk/Include/MFCUtilities/RmMFCShaderKeywordLoader.h $ 00012 // $Revision: #2 $ $Author: tsuji $ 00013 //=================================================================================================// 00014 // (C) 2002 ATI Research, Inc. All rights reserved. // 00015 //=================================================================================================// 00016 00017 #ifndef RM_MFC_SHADER_KEYWORD_LOADER_H 00018 #define RM_MFC_SHADER_KEYWORD_LOADER_H 00019 00020 #include "RmMFCShaderSyntaxParser.h" 00021 00023 // 00024 // File Format 00025 // 00026 // - File consist of 00027 // 00028 // Keyword category definition(s) 00029 // Color for this category 00030 // List of words 00031 // : 00032 // 00033 // Keyword operator definition(s) 00034 // Color for this category 00035 // List of operators 00036 // : 00037 // 00038 // Example : 00039 // 00040 // Keywords : "Instructions" 00041 // { 00042 // Color : ( 0, 0, 255 ) 00043 // Word : "abs" 00044 // "add" 00045 // "call" 00046 // } // End of Keywords Instruction 00047 // 00048 00049 //================================================================================================= 00050 // 00051 // Forward Declaration 00052 // 00053 //================================================================================================= 00054 class RmMFCShaderEditorTextCtrl; 00055 00056 //..............................................................................................................// 00057 //..............................................................................................................// 00058 //..............................................................................................................// 00059 // Syntax Definition Loader 00060 //..............................................................................................................// 00061 //..............................................................................................................// 00062 //..............................................................................................................// 00063 class RMMFCUTIL_API RmMFCShaderKeywordLoader 00064 { 00065 public : 00066 RmMFCShaderKeywordLoader (); 00067 virtual ~RmMFCShaderKeywordLoader (); 00068 00069 // Load KeywordList from file into SyntaxParser 00070 bool Load( const RM_TCHAR* szFileName, 00071 RmMFCShaderSyntaxParser *pSyntaxParser ); 00072 00073 private : 00074 RmShaderCharType m_charTypeTable[65536]; 00075 00076 TCHAR *m_pBuffer; // Contents of file in memory 00077 int m_bufferOffset; 00078 int m_bufferSize; 00079 00080 // Create/Destroy Buffer 00081 void CreateBuffer( FILE *pFile ); 00082 void DestroyBuffer(); 00083 00084 // Skip white spaces and return first non-white space character 00085 // White space include comments 00086 void SkipWhiteSpace(); 00087 00088 // Move Offset 00089 void MoveOffset( int howMuchToMove ); 00090 void AdvanceOffset() { MoveOffset(1); }; 00091 00092 // Get Next Char returns EOF if end reached 00093 int GetNextChar( bool bAdvanceOffset = true ); 00094 00095 // Get Next Word - Return true on success 00096 // Return false if failed ( encountered invalid word ) 00097 bool GetNextWord( CString &str, bool bAdvanceOffset = true ); 00098 00099 // Checks if next word is given str 00100 bool IsNextWord( const TCHAR* szWordStr, bool bAdvanceOffset = true ); 00101 00102 // Get Next Operator - Return true on success 00103 // Return false if failed ( encountered invalid operator ) 00104 bool GetNextOperator( CString &str, bool bAdvanceOffset = true ); 00105 00106 // Checks if next operator is given str 00107 bool IsNextOperator( const TCHAR* szOpStr, bool bAdvanceOffset = true ); 00108 00109 // Get Next Integer - Return true on success 00110 // Return false if failed ( encountered invalid word ) 00111 // This is not very generic, number can not contain sign, period. 00112 // Just plain decimal positive integer. For this Syntax Definition 00113 // Loader, this will suffice. 00114 bool GetNextInteger( int &number, bool bAdvanceOffset = true ); 00115 00116 // Returns true if bufferOffset==m_bufferSize; 00117 bool IsEndReached() const; 00118 00119 // Parse Keyword section 00120 bool ParseKeywordSection(); 00121 00122 // Parse Color section 00123 bool ParseColorSection(); 00124 00125 // Read Color Value 00126 bool ReadColorValue( COLORREF &color ); 00127 00128 // Read String Value 00129 bool ReadStringValue( CString &str ); 00130 00131 // Read Integer Value 00132 bool ReadIntValue( int &result ); 00133 00134 // Add Keywords using given string 00135 bool AddKeyworsFromString( RmMFCShaderSyntaxParser::KeywordCategory *pKeywordCategory, 00136 COLORREF color, 00137 CString &str ); 00138 00139 private : 00140 RmMFCShaderSyntaxParser *m_pSyntaxParser; 00141 00142 COLORREF m_commentColor; 00143 COLORREF m_foregroundColor; 00144 COLORREF m_backgroundColor; 00145 COLORREF m_highlightColor; 00146 }; // End of RmMFCShaderKeywordLoader 00147 00148 #endif // __RM_SHADER_EDITOR_KeywordLoader__
1.3.6