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