b311480e |
1 | -- Created on: 2001-01-18 |
2 | -- Created by: OCC Team |
973c2be1 |
3 | -- Copyright (c) 2001-2014 OPEN CASCADE SAS |
b311480e |
4 | -- |
973c2be1 |
5 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
6 | -- |
973c2be1 |
7 | -- This library is free software; you can redistribute it and / or modify it |
8 | -- under the terms of the GNU Lesser General Public version 2.1 as published |
9 | -- by the Free Software Foundation, with special exception defined in the file |
10 | -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | -- distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | -- |
973c2be1 |
13 | -- Alternatively, this file may be used under the terms of Open CASCADE |
14 | -- commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | class Msg from Message |
17 | |
18 | ---Purpose: This class provides a tool for constructing the parametrized message |
19 | -- basing on resources loaded by Message_MsgFile tool. |
20 | -- |
21 | -- A Message is created from a keyword: this keyword identifies the |
22 | -- message in a message file that should be previously loaded by call |
23 | -- to Message_MsgFile::LoadFile(). |
24 | -- |
25 | -- The text of the message can contain placeholders for the parameters |
26 | -- which are to be filled by the proper values when the message |
27 | -- is prepared. Most of the format specifiers used in C can be used, |
28 | -- for instance, %s for string, %d for integer etc. In addition, |
29 | -- specifier %f is supported for double numbers (for compatibility |
30 | -- with previous versions). |
31 | -- |
32 | -- User fills the parameter fields in the text of the message by |
33 | -- calling corresponding methods Arg() or operators "<<". |
34 | -- |
35 | -- The resulting message, filled with all parameters, can be obtained |
36 | -- by method Get(). If some parameters were not filled, the text |
37 | -- UNKNOWN is placed instead. |
38 | |
39 | uses |
40 | |
41 | AsciiString from TCollection, |
42 | HAsciiString from TCollection, |
43 | ExtendedString from TCollection, |
44 | HExtendedString from TCollection, |
45 | SequenceOfInteger from TColStd |
46 | |
47 | is |
48 | |
49 | Create returns Msg from Message; |
50 | ---Purpose : Empty constructor |
51 | |
52 | Create (theMsg: Msg from Message) returns Msg from Message; |
53 | ---Purpose : Copy constructor |
54 | |
55 | Create (theKey: CString) returns Msg from Message; |
56 | ---Purpose : Create a message using a corresponding entry in Message_MsgFile |
57 | |
58 | Create (theKey: ExtendedString from TCollection) returns Msg from Message; |
59 | ---Purpose : Create a message using a corresponding entry in Message_MsgFile |
60 | |
61 | Set (me: in out; theMsg: CString); |
62 | ---Purpose : Set a message body text -- can be used as alternative to |
63 | -- using messages from resource file |
64 | |
65 | Set (me: in out; theMsg: ExtendedString from TCollection); |
66 | ---Purpose : Set a message body text -- can be used as alternative to |
67 | -- using messages from resource file |
68 | |
69 | -- Adding arguments |
70 | |
71 | Arg (me: in out; theString : CString) |
72 | returns Msg from Message; |
73 | ---C++: return & |
74 | ---C++: alias operator << |
75 | ---Purpose : Set a value for %..s conversion |
76 | |
77 | Arg (me: in out; theString : AsciiString from TCollection) |
78 | returns Msg from Message; |
79 | ---C++: return & |
80 | ---C++: inline |
81 | ---C++: alias operator << |
82 | ---Purpose : Set a value for %..s conversion |
83 | |
84 | Arg (me: in out; theString : HAsciiString from TCollection) |
85 | returns Msg from Message; |
86 | ---C++: return & |
87 | ---C++: inline |
88 | ---C++: alias operator << |
89 | ---Purpose : Set a value for %..s conversion |
90 | |
91 | Arg (me: in out; theString : ExtendedString from TCollection) |
92 | returns Msg from Message; |
93 | ---C++: return & |
94 | ---C++: alias operator << |
95 | ---Purpose : Set a value for %..s conversion |
96 | |
97 | Arg (me: in out; theString : HExtendedString from TCollection) |
98 | returns Msg from Message; |
99 | ---C++: return & |
100 | ---C++: inline |
101 | ---C++: alias operator << |
102 | ---Purpose : Set a value for %..s conversion |
103 | |
104 | Arg (me: in out; theInt : Integer) |
105 | returns Msg from Message; |
106 | ---C++: return & |
107 | ---C++: alias operator << |
108 | ---Purpose : Set a value for %..d, %..i, %..o, %..u, %..x or %..X conversion |
109 | |
110 | Arg (me: in out; theReal : Real) |
111 | returns Msg from Message; |
112 | ---C++: return & |
113 | ---C++: alias operator << |
114 | ---Purpose : Set a value for %..f, %..e, %..E, %..g or %..G conversion |
115 | |
116 | Original (me) returns ExtendedString from TCollection; |
117 | ---C++: inline |
118 | ---C++: return const & |
119 | ---Purpose : Returns the original message text |
120 | |
121 | Value (me) returns ExtendedString from TCollection; |
122 | ---C++: inline |
123 | ---C++: return const & |
124 | ---Purpose : Returns current state of the message text with |
125 | -- parameters to the moment |
126 | |
127 | IsEdited (me) returns Boolean; |
128 | ---C++: inline |
129 | ---Purpose : Tells if Value differs from Original |
130 | |
131 | Get (me: in out) |
132 | returns ExtendedString from TCollection; |
133 | ---C++: return const & |
134 | ---C++: alias "operator const TCollection_ExtendedString& () { return Get(); }" |
135 | ---Purpose : Return the resulting message string with all parameters |
136 | -- filled. If some parameters were not yet filled by calls |
137 | -- to methods Arg (or <<), these parameters are filled by |
138 | -- the word UNKNOWN |
139 | |
140 | -- Private methods |
141 | |
142 | getFormat (me: in out; theType : Integer; |
143 | theFormat : in out AsciiString from TCollection) |
144 | returns Integer is private; |
145 | |
146 | replaceText (me: in out; theFirst : Integer; |
147 | theNb : Integer; |
148 | theStr : ExtendedString from TCollection) is private; |
149 | |
150 | fields |
151 | |
152 | myOriginal : ExtendedString from TCollection; |
153 | myMessageBody : ExtendedString from TCollection; |
154 | mySeqOfFormats : SequenceOfInteger from TColStd; |
155 | |
156 | end Msg; |