|
||||
File indexing completed on 2025-01-18 10:04:16
0001 // Created on: 2001-04-26 0002 // Created by: OCC Team 0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _Message_MsgFile_HeaderFile 0017 #define _Message_MsgFile_HeaderFile 0018 0019 #include <Standard.hxx> 0020 #include <Standard_DefineAlloc.hxx> 0021 #include <Standard_Handle.hxx> 0022 0023 #include <Standard_Boolean.hxx> 0024 class TCollection_AsciiString; 0025 class TCollection_ExtendedString; 0026 0027 //! A tool providing facility to load definitions of message strings from 0028 //! resource file(s). 0029 //! 0030 //! The message file is an ASCII file which defines a set of messages. 0031 //! Each message is identified by its keyword (string). 0032 //! 0033 //! All lines in the file starting with the exclamation sign 0034 //! (perhaps preceding by spaces and/or tabs) are ignored as comments. 0035 //! 0036 //! Each line in the file starting with the dot character "." 0037 //! (perhaps preceding by spaces and/or tabs) defines the keyword. 0038 //! The keyword is a string starting from the next symbol after dot 0039 //! and ending at the symbol preceding ending newline character "\n". 0040 //! 0041 //! All the lines in the file after the keyword and before next 0042 //! keyword (and which are not comments) define the message for that 0043 //! keyword. If the message consists of several lines, the message 0044 //! string will contain newline symbols "\n" between parts (but not 0045 //! at the end). 0046 //! 0047 //! The experimental support of Unicode message files is provided. 0048 //! These are distinguished by two bytes FF.FE or FE.FF at the beginning. 0049 //! 0050 //! The loaded messages are stored in static data map; all methods of that 0051 //! class are also static. 0052 class Message_MsgFile 0053 { 0054 public: 0055 0056 DEFINE_STANDARD_ALLOC 0057 0058 //! Load message file <theFileName> from directory <theDirName> 0059 //! or its sub-directory 0060 Standard_EXPORT static Standard_Boolean Load (const Standard_CString theDirName, const Standard_CString theFileName); 0061 0062 //! Load the messages from the given file, additive to any previously 0063 //! loaded messages. Messages with same keywords, if already present, 0064 //! are replaced with the new ones. 0065 Standard_EXPORT static Standard_Boolean LoadFile (const Standard_CString theFName); 0066 0067 //! Loads the messages from the file with name (without extension) given by environment variable. 0068 //! Extension of the file name is given separately. If its not defined, it is taken: 0069 //! - by default from environment CSF_LANGUAGE, 0070 //! - if not defined either, as "us". 0071 //! @name theEnvName environment variable name 0072 //! @name theFileName file name without language suffix 0073 //! @name theLangExt language file name extension 0074 //! @return TRUE on success 0075 Standard_EXPORT static Standard_Boolean LoadFromEnv (const Standard_CString theEnvName, 0076 const Standard_CString theFileName, 0077 const Standard_CString theLangExt = ""); 0078 0079 //! Loads the messages from the given text buffer. 0080 //! @param theContent string containing the messages 0081 //! @param theLength length of the buffer; 0082 //! when -1 specified - theContent will be considered as NULL-terminated string 0083 Standard_EXPORT static Standard_Boolean LoadFromString (const Standard_CString theContent, 0084 const Standard_Integer theLength = -1); 0085 0086 //! Adds new message to the map. Parameter <key> gives 0087 //! the key of the message, <text> defines the message itself. 0088 //! If there already was defined the message identified by the 0089 //! same keyword, it is replaced with the new one. 0090 Standard_EXPORT static Standard_Boolean AddMsg (const TCollection_AsciiString& key, const TCollection_ExtendedString& text); 0091 0092 //! Returns True if message with specified keyword is registered 0093 Standard_EXPORT static Standard_Boolean HasMsg (const TCollection_AsciiString& key); 0094 0095 Standard_EXPORT static const TCollection_ExtendedString& Msg (const Standard_CString key); 0096 0097 //! Gives the text for the message identified by the keyword <key>. 0098 //! If there are no messages with such keyword defined, the error message is returned. 0099 //! In that case reference to static string is returned, it can be changed with next call(s) to Msg(). 0100 //! Note: The error message is constructed like 'Unknown message: <key>', and can 0101 //! itself be customized by defining message with key Message_Msg_BadKeyword. 0102 Standard_EXPORT static const TCollection_ExtendedString& Msg (const TCollection_AsciiString& key); 0103 0104 }; 0105 0106 #endif // _Message_MsgFile_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |