OnixS BME SENAF Handler C++ library  2.2.1
API documentation
Warning.h
Go to the documentation of this file.
1 /*
2  * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited [OnixS] and is protected by
5  * copyright law and international copyright treaties.
6  *
7  * Access to and use of the software is governed by the terms of the applicable
8  * ONIXS Software Services Agreement (the Agreement) and Customer end user
9  * license agreements granting a non-assignable, non-transferable and
10  * non-exclusive license to use the software for it's own data processing
11  * purposes under the terms defined in the Agreement.
12  *
13  * Except as otherwise granted within the terms of the Agreement, copying or
14  * reproduction of any part of this source code or associated reference material
15  * to any other location for further reproduction or redistribution, and any
16  * amendments to this copyright notice, are expressly prohibited.
17  *
18  * Any reproduction or redistribution for sale or hiring of the Software not in
19  * accordance with the terms of the Agreement is a violation of copyright law.
20  */
21 
22 #pragma once
23 
24 #include <OnixS/Senaf/MarketData/Export.h>
25 
26 #include <iosfwd>
27 #include <string>
28 
29 namespace OnixS { namespace Senaf { namespace MarketData {
30 
31 /// List of known warnings.
32 struct ONIXS_BME_SENAF_EXPORT KnownWarnings
33 {
34  /// List of known warnings.
35  enum Enum
36  {
37  /// General-purpose warning.
39  };
40 
41  /// Returns constant from its text presentation.
42  static Enum deserialize(const char* value);
43 
44  /// Returns description of a particular warning.
45  static const char* toString(Enum value);
46 };
47 
48 /// Code of warning.
50 
51 /// Warning.
52 class ONIXS_BME_SENAF_EXPORT Warning
53 {
54 public:
55  /// Initializes instance with just a code.
56  Warning(const std::string& source, WarningCode code);
57 
58  /// Initializes instance with code and description.
59  Warning(const std::string& source, WarningCode code, const std::string& description);
60 
61  /// Initializes as clone of another warning.
62  Warning(const Warning& other);
63 
64  /// Cleans internal resources.
65  ~Warning();
66 
67  /// Code of warning.
68  WarningCode code() const;
69 
70  /// Human readable description.
71  const char* description() const;
72 
73  /// Origin of the warning.
74  const char* source() const;
75 
76  /// String presentation of an warning.
77  std::string toString() const;
78 
79  /// Appends presentation of an warning to the string.
80  void toString(std::string&) const;
81 
82  /// Copies warning attributes from another instance.
83  Warning& operator=(const Warning& other);
84 
85 private:
86  enum Traits
87  {
88  SourceMaxLength = 128,
89  DescriptionMaxLength = 1024
90  };
91 
92  WarningCode code_;
93  char source_[SourceMaxLength];
94  char description_[DescriptionMaxLength];
95 };
96 
97 /// Make it printable to formatted C++ I/O streams.
98 ONIXS_BME_SENAF_EXPORT std::ostream& operator<<(std::ostream&, const Warning&);
99 
100 inline WarningCode Warning::code() const
101 {
102  return code_;
103 }
104 
105 inline const char* Warning::description() const
106 {
107  return description_;
108 }
109 
110 inline const char* Warning::source() const
111 {
112  return source_;
113 }
114 
115 inline std::string Warning::toString() const
116 {
117  std::string str;
118  toString(str);
119  return str;
120 }
121 
122 }}} // namespace OnixS::Senaf::MarketData
KnownWarnings::Enum WarningCode
Code of warning.
Definition: Warning.h:49
const char * source() const
Origin of the warning.
Definition: Warning.h:110
Enum
List of known warnings.
Definition: Warning.h:35
WarningCode code() const
Code of warning.
Definition: Warning.h:100
std::string toString() const
String presentation of an warning.
Definition: Warning.h:115
List of known warnings.
Definition: Warning.h:32
std::ostream & operator<<(std::ostream &, const Error &)
Make it printable to formatted C++ I/O streams.
const char * description() const
Human readable description.
Definition: Warning.h:105