NCBI C++ ToolKit
flatfile_message.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: flatfile_message.cpp 96570 2022-04-15 16:27:44Z stakhovv $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Justin Foley
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 
37 
39  const string& module,
40  EDiagSev severity,
41  int code,
42  int subcode,
43  const string& text,
44  int lineNum) :
45  CObjtoolsMessage(text, severity),
46  m_Module(module),
47  m_Code(code),
48  m_Subcode(subcode),
49  m_LineNum(lineNum)
50 {
51 }
52 
53 
55 
56 
58 {
59  return new CFlatFileMessage(
60  m_Module,
61  m_Severity,
62  m_Code,
63  m_Subcode,
64  m_Text,
65  m_LineNum);
66 }
67 
68 
70 {
71  Dump(out);
72 }
73 
74 
76 {
77 
78  const auto severity = GetSeverity();
79 
80  switch (severity) {
81  case eDiag_Critical:
82  out << "REJECT: ";
83  break;
84  case eDiag_Fatal:
85  out << "FATAL ERROR: ";
86  break;
87  case eDiag_Info:
88  out << "NOTE: ";
89  break;
90  default: {
91  string sevName = CNcbiDiag::SeverityName(severity);
92  out << NStr::ToUpper(sevName) << ": ";
93  break;
94  }
95  }
96 
97  if (! m_Module.empty()) {
98  out << m_Module << " ";
99  }
100  out << GetText() << "\n";
101 }
102 
103 
105 {
106  DumpAsXML(out);
107 }
108 
109 
111 
112 
113 const string& CFlatFileMessage::GetModule() const
114 {
115  return m_Module;
116 }
117 
118 
120 {
121  return m_Code;
122 }
123 
124 
126 {
127  return m_Subcode;
128 }
129 
130 
132 {
133  return m_LineNum;
134 }
135 
136 
int GetCode(void) const override
const string & GetModule() const
void Dump(CNcbiOstream &out) const override
void WriteAsXML(CNcbiOstream &out) const override
CFlatFileMessage * Clone(void) const override
int GetSubCode(void) const override
void DumpAsXML(CNcbiOstream &out) const override
CFlatFileMessage(const string &module, EDiagSev severity, int code, int subcode, const string &text, int lineNum=-1)
int GetLineNum(void) const
void Write(CNcbiOstream &out) const override
virtual ~CFlatFileMessage()
virtual EDiagSev GetSeverity(void) const
Definition: message.cpp:96
virtual string GetText(void) const
Definition: message.cpp:90
EDiagSev m_Severity
Definition: message.hpp:92
std::ofstream out("events_result.xml")
main entry point for tests
static const char * SeverityName(EDiagSev sev)
Get a common symbolic name for the severity levels.
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Info
Informational message.
Definition: ncbidiag.hpp:651
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
Definition: ncbidiag.hpp:655
@ eDiag_Critical
Critical error message.
Definition: ncbidiag.hpp:654
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
static void text(MDB_val *v)
Definition: mdb_dump.c:62
Definition: inftrees.h:24
Modified on Sat Dec 02 09:22:27 2023 by modify_doxy.py rev. 669887