MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / MsgPrint

Function MsgPrint

src/common/classes/MsgPrint.cpp:235–317  ·  view source on GitHub ↗

Prints the whole chain of arguments, according to format and in the specified stream.

Source from the content-addressed store, hash-verified

233
234// Prints the whole chain of arguments, according to format and in the specified stream.
235int MsgPrint(BaseStream& out_stream, const char* format, const SafeArg& arg, bool userFormatting)
236{
237 int out_bytes = 0;
238 for (const char* iter = format; true; ++iter)
239 {
240 switch (*iter)
241 {
242 case 0:
243 return out_bytes;
244
245 case '@':
246 switch (iter[1])
247 {
248 case 0:
249 if (userFormatting)
250 out_bytes += out_stream.write("@", 1);
251 else
252 out_bytes += out_stream.write("@(EOF)", 6);
253 return out_bytes;
254 case '@':
255 out_bytes += out_stream.write(iter, 1);
256 break;
257 default:
258 {
259 const int pos = iter[1] - '0';
260 if (pos > 0 && static_cast<FB_SIZE_T>(pos) <= arg.m_count)
261 out_bytes += MsgPrintHelper(out_stream, arg.m_arguments[pos - 1]);
262 else
263 {
264 if (userFormatting)
265 {
266 out_bytes += out_stream.write("@", 1);
267 out_bytes += out_stream.write(iter + 1, 1);
268 }
269 else if (pos >= 0 && pos <= 9)
270 {
271 // Show the missing or out of range param number.
272 out_bytes += MsgPrint(out_stream,
273 "<Missing arg #@1 - possibly status vector overflow>",
274 SafeArg() << pos);
275 }
276 else // Something not a number following @, invalid.
277 out_bytes += out_stream.write("(error)", 7);
278 }
279 }
280 }
281 ++iter;
282 break;
283
284 case '\\':
285 switch (iter[1])
286 {
287 case 0:
288 out_bytes += out_stream.write("\\(EOF)", 6);
289 return out_bytes;
290 case 'n':
291 out_bytes += out_stream.write("\n", 1);
292 break;

Callers 4

setErrorMethod · 0.85
MsgPrintErrFunction · 0.85
fb_msg_formatFunction · 0.85
safe_interpretFunction · 0.85

Calls 3

MsgPrintHelperFunction · 0.85
SafeArgClass · 0.70
writeMethod · 0.45

Tested by

no test coverage detected