Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Created on: 2001-01-18
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_Msg_HeaderFile
0017 #define _Message_Msg_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <TCollection_HAsciiString.hxx>
0024 #include <TCollection_HExtendedString.hxx>
0025 #include <TColStd_SequenceOfInteger.hxx>
0026 
0027 class TCollection_AsciiString;
0028 class TCollection_HAsciiString;
0029 class TCollection_HExtendedString;
0030 
0031 
0032 //! This class provides a tool for constructing the parametrized message
0033 //! basing on resources loaded by Message_MsgFile tool.
0034 //!
0035 //! A Message is created from a keyword: this keyword identifies the
0036 //! message in a message file that should be previously loaded by call
0037 //! to Message_MsgFile::LoadFile().
0038 //!
0039 //! The text of the message can contain placeholders for the parameters
0040 //! which are to be filled by the proper values when the message
0041 //! is prepared. Most of the format specifiers used in C can be used,
0042 //! for instance, %s for string, %d for integer etc. In addition,
0043 //! specifier %f is supported for double numbers (for compatibility
0044 //! with previous versions).
0045 //!
0046 //! User fills the parameter fields in the text of the message by
0047 //! calling corresponding methods Arg() or operators .
0048 //!
0049 //! The resulting message, filled with all parameters, can be obtained
0050 //! by method Get(). If some parameters were not filled, the text
0051 //! UNKNOWN is placed instead.
0052 class Message_Msg 
0053 {
0054 public:
0055 
0056   DEFINE_STANDARD_ALLOC
0057 
0058   
0059   //! Empty constructor
0060   Standard_EXPORT Message_Msg();
0061   
0062   //! Copy constructor
0063   Standard_EXPORT Message_Msg(const Message_Msg& theMsg);
0064   
0065   //! Create a message using a corresponding entry in Message_MsgFile
0066   Standard_EXPORT Message_Msg(const Standard_CString theKey);
0067   
0068   //! Create a message using a corresponding entry in Message_MsgFile
0069   Standard_EXPORT Message_Msg(const TCollection_ExtendedString& theKey);
0070   
0071   //! Set a message body text -- can be used as alternative to
0072   //! using messages from resource file
0073   Standard_EXPORT void Set (const Standard_CString theMsg);
0074   
0075   //! Set a message body text -- can be used as alternative to
0076   //! using messages from resource file
0077   Standard_EXPORT void Set (const TCollection_ExtendedString& theMsg);
0078   
0079   //! Set a value for %..s conversion
0080   Standard_EXPORT Message_Msg& Arg (const Standard_CString theString);
0081 Message_Msg& operator << (const Standard_CString theString)
0082 {
0083   return Arg(theString);
0084 }
0085   
0086   //! Set a value for %..s conversion
0087     Message_Msg& Arg (const TCollection_AsciiString& theString);
0088   Message_Msg& operator << (const TCollection_AsciiString& theString)
0089 {
0090   return Arg(theString);
0091 }
0092   
0093   //! Set a value for %..s conversion
0094     Message_Msg& Arg (const Handle(TCollection_HAsciiString)& theString);
0095   Message_Msg& operator << (const Handle(TCollection_HAsciiString)& theString)
0096 {
0097   return Arg(theString);
0098 }
0099   
0100   //! Set a value for %..s conversion
0101   Standard_EXPORT Message_Msg& Arg (const TCollection_ExtendedString& theString);
0102 Message_Msg& operator << (const TCollection_ExtendedString& theString)
0103 {
0104   return Arg(theString);
0105 }
0106   
0107   //! Set a value for %..s conversion
0108     Message_Msg& Arg (const Handle(TCollection_HExtendedString)& theString);
0109   Message_Msg& operator << (const Handle(TCollection_HExtendedString)& theString)
0110 {
0111   return Arg(theString);
0112 }
0113   
0114   //! Set a value for %..d, %..i, %..o, %..u, %..x or %..X conversion
0115   Standard_EXPORT Message_Msg& Arg (const Standard_Integer theInt);
0116 Message_Msg& operator << (const Standard_Integer theInt)
0117 {
0118   return Arg(theInt);
0119 }
0120   
0121   //! Set a value for %..f, %..e, %..E, %..g or %..G conversion
0122   Standard_EXPORT Message_Msg& Arg (const Standard_Real theReal);
0123 Message_Msg& operator << (const Standard_Real theReal)
0124 {
0125   return Arg(theReal);
0126 }
0127   
0128   //! Returns the original message text
0129     const TCollection_ExtendedString& Original() const;
0130   
0131   //! Returns current state of the message text with
0132   //! parameters to the moment
0133     const TCollection_ExtendedString& Value() const;
0134   
0135   //! Tells if Value differs from Original
0136     Standard_Boolean IsEdited() const;
0137   
0138   //! Return the resulting message string with all parameters
0139   //! filled. If some parameters were not yet filled by calls
0140   //! to methods Arg (or <<), these parameters are filled by
0141   //! the word UNKNOWN
0142   Standard_EXPORT const TCollection_ExtendedString& Get();
0143 operator const TCollection_ExtendedString& () { return Get(); }
0144 
0145 
0146 
0147 
0148 protected:
0149 
0150 
0151 
0152 
0153 
0154 private:
0155 
0156   
0157   Standard_EXPORT Standard_Integer getFormat (const Standard_Integer theType, TCollection_AsciiString& theFormat);
0158   
0159   Standard_EXPORT void replaceText (const Standard_Integer theFirst, const Standard_Integer theNb, const TCollection_ExtendedString& theStr);
0160 
0161 
0162   TCollection_ExtendedString myOriginal;
0163   TCollection_ExtendedString myMessageBody;
0164   TColStd_SequenceOfInteger mySeqOfFormats;
0165 
0166 
0167 };
0168 
0169 
0170 #include <Message_Msg.lxx>
0171 
0172 
0173 
0174 
0175 
0176 #endif // _Message_Msg_HeaderFile