summaryrefslogtreecommitdiff
path: root/inc/Message_Msg.hxx
blob: 2f9553f502dda635a896515b285bc0e202d4f89a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _Message_Msg_HeaderFile
#define _Message_Msg_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _TCollection_ExtendedString_HeaderFile
#include <TCollection_ExtendedString.hxx>
#endif
#ifndef _TColStd_SequenceOfInteger_HeaderFile
#include <TColStd_SequenceOfInteger.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
#ifndef _Handle_TCollection_HAsciiString_HeaderFile
#include <Handle_TCollection_HAsciiString.hxx>
#endif
#ifndef _Handle_TCollection_HExtendedString_HeaderFile
#include <Handle_TCollection_HExtendedString.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class TCollection_ExtendedString;
class TCollection_AsciiString;
class TCollection_HAsciiString;
class TCollection_HExtendedString;


//! This class provides a tool for constructing the parametrized message <br>
//!          basing on resources loaded by Message_MsgFile tool. <br>
//! <br>
//!          A Message is created from a keyword: this keyword identifies the <br>
//!          message in a message file that should be previously loaded by call <br>
//!          to Message_MsgFile::LoadFile(). <br>
//! <br>
//!          The text of the message can contain placeholders for the parameters <br>
//!          which are to be filled by the proper values when the message <br>
//!          is prepared. Most of the format specifiers used in C can be used, <br>
//!          for instance, %s for string, %d for integer etc. In addition, <br>
//!          specifier %f is supported for double numbers (for compatibility <br>
//!          with previous versions). <br>
//! <br>
//!          User fills the parameter fields in the text of the message by <br>
//!          calling corresponding methods Arg() or operators "<<". <br>
//! <br>
//!          The resulting message, filled with all parameters, can be obtained <br>
//!          by method Get(). If some parameters were not filled, the text <br>
//!          UNKNOWN is placed instead. <br>
class Message_Msg  {
public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! Empty constructor <br>
  Standard_EXPORT   Message_Msg();
  //! Copy constructor <br>
  Standard_EXPORT   Message_Msg(const Message_Msg& theMsg);
  //! Create a message using a corresponding entry in Message_MsgFile <br>
  Standard_EXPORT   Message_Msg(const Standard_CString theKey);
  //! Create a message using a corresponding entry in Message_MsgFile <br>
  Standard_EXPORT   Message_Msg(const TCollection_ExtendedString& theKey);
  //! Set a message body text -- can be used as alternative to <br>
//!           using messages from resource file <br>
  Standard_EXPORT     void Set(const Standard_CString theMsg) ;
  //! Set a message body text -- can be used as alternative to <br>
//!           using messages from resource file <br>
  Standard_EXPORT     void Set(const TCollection_ExtendedString& theMsg) ;
  //! Set a value for %..s conversion <br>
  Standard_EXPORT     Message_Msg& Arg(const Standard_CString theString) ;
    Message_Msg& operator <<(const Standard_CString theString) 
{
  return Arg(theString);
}
  //! Set a value for %..s conversion <br>
        Message_Msg& Arg(const TCollection_AsciiString& theString) ;
      Message_Msg& operator <<(const TCollection_AsciiString& theString) 
{
  return Arg(theString);
}
  //! Set a value for %..s conversion <br>
        Message_Msg& Arg(const Handle(TCollection_HAsciiString)& theString) ;
      Message_Msg& operator <<(const Handle(TCollection_HAsciiString)& theString) 
{
  return Arg(theString);
}
  //! Set a value for %..s conversion <br>
  Standard_EXPORT     Message_Msg& Arg(const TCollection_ExtendedString& theString) ;
    Message_Msg& operator <<(const TCollection_ExtendedString& theString) 
{
  return Arg(theString);
}
  //! Set a value for %..s conversion <br>
        Message_Msg& Arg(const Handle(TCollection_HExtendedString)& theString) ;
      Message_Msg& operator <<(const Handle(TCollection_HExtendedString)& theString) 
{
  return Arg(theString);
}
  //! Set a value for %..d, %..i, %..o, %..u, %..x or %..X conversion <br>
  Standard_EXPORT     Message_Msg& Arg(const Standard_Integer theInt) ;
    Message_Msg& operator <<(const Standard_Integer theInt) 
{
  return Arg(theInt);
}
  //! Set a value for %..f, %..e, %..E, %..g or %..G conversion <br>
  Standard_EXPORT     Message_Msg& Arg(const Standard_Real theReal) ;
    Message_Msg& operator <<(const Standard_Real theReal) 
{
  return Arg(theReal);
}
  //! Returns the original message text <br>
       const TCollection_ExtendedString& Original() const;
  //! Returns current state of the message text with <br>
//!           parameters to the moment <br>
       const TCollection_ExtendedString& Value() const;
  //! Tells if Value differs from Original <br>
        Standard_Boolean IsEdited() const;
  //! Return the resulting message string with all parameters <br>
//!           filled. If some parameters were not yet filled by calls <br>
//!           to methods Arg (or <<), these parameters are filled by <br>
//!           the word UNKNOWN <br>
  Standard_EXPORT    const TCollection_ExtendedString& Get() ;
operator const TCollection_ExtendedString& () { return Get(); }





protected:





private:

  
  Standard_EXPORT     Standard_Integer getFormat(const Standard_Integer theType,TCollection_AsciiString& theFormat) ;
  
  Standard_EXPORT     void replaceText(const Standard_Integer theFirst,const Standard_Integer theNb,const TCollection_ExtendedString& theStr) ;


TCollection_ExtendedString myOriginal;
TCollection_ExtendedString myMessageBody;
TColStd_SequenceOfInteger mySeqOfFormats;


};


#include <Message_Msg.lxx>



// other Inline functions and methods (like "C++: function call" methods)


#endif