NCBI C++ ToolKit
edit_error.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: edit_error.hpp 93572 2021-04-30 13:48:31Z 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  * objtools/edit message class
30  *
31  */
32 
33 #ifndef _OBJTOOLS_EDIT_ERROR_HPP_
34 #define _OBJTOOLS_EDIT_ERROR_HPP_
35 
37 
39 BEGIN_SCOPE(objects) // namespace ncbi::objects::
40 
41 // ============================================================================
43 // ============================================================================
44 {
45 public:
46  CObjEditMessage(const string& text,
47  EDiagSev severity)
48  : m_Text(text), m_Severity(severity) {}
49 
50 
51  virtual CObjEditMessage *Clone(void) const {
52  return new CObjEditMessage(m_Text, m_Severity);
53  }
54 
55  virtual string
56  Compose(void) const
57  {
58  return x_GetSeverityString() + ": " + GetText();
59  }
60 
61  virtual void Write(
62  CNcbiOstream& out ) const
63  {
64  out << " " <<
65  x_GetSeverityString()
66  << ":" << endl;
67  out << "Problem: " <<
68  GetText() << endl;
69  out << endl;
70  };
71 
72  virtual void Dump(
73  CNcbiOstream& out) const
74  {
75  Write(out);
76  };
77 
78  // dump the XML on one line since some tools assume that
79  virtual void WriteAsXML(
80  CNcbiOstream& out ) const
81  {
82  out << "<message severity=\"" << NStr::XmlEncode(x_GetSeverityString()) << "\" "
83  << "problem=\"" << NStr::XmlEncode(GetText()) << "\" ";
84  out << "</message>" << endl;
85  };
86 
87  virtual void DumpAsXML(
88  CNcbiOstream& out) const
89  {
90  WriteAsXML(out);
91  };
92 
93  virtual string GetText(void) const { return m_Text; }
94  virtual EDiagSev GetSeverity(void) const { return m_Severity; }
95  virtual int GetCode(void) const { return 0; }
96  virtual int GetSubCode(void) const { return 0; }
97 
98 private:
99 
100  string x_GetSeverityString(void) const
101  {
102  return CNcbiDiag::SeverityName(GetSeverity());
103  }
104  string m_Text;
106 };
107 
110 
111 #endif // _OBJTOOLS_EDIT_ERROR_HPP_
virtual EDiagSev GetSeverity(void) const
Definition: edit_error.hpp:94
CObjEditMessage(const string &text, EDiagSev severity)
Definition: edit_error.hpp:46
virtual string Compose(void) const
Definition: edit_error.hpp:56
virtual int GetCode(void) const
Definition: edit_error.hpp:95
virtual void DumpAsXML(CNcbiOstream &out) const
Definition: edit_error.hpp:87
virtual int GetSubCode(void) const
Definition: edit_error.hpp:96
EDiagSev m_Severity
Definition: edit_error.hpp:105
virtual string GetText(void) const
Definition: edit_error.hpp:93
virtual CObjEditMessage * Clone(void) const
Definition: edit_error.hpp:51
virtual void Write(CNcbiOstream &out) const
Definition: edit_error.hpp:61
virtual void Dump(CNcbiOstream &out) const
Definition: edit_error.hpp:72
string x_GetSeverityString(void) const
Definition: edit_error.hpp:100
virtual void WriteAsXML(CNcbiOstream &out) const
Definition: edit_error.hpp:79
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
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:55
#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 XmlEncode(const CTempString str, TXmlEncode flags=eXmlEnc_Contents)
Encode a string for XML.
Definition: ncbistr.cpp:4027
#define NCBI_XOBJUTIL_EXPORT
Definition: ncbi_export.h:1339
static void text(MDB_val *v)
Definition: mdb_dump.c:62
Modified on Fri Sep 20 14:58:05 2024 by modify_doxy.py rev. 669887