OnixS CME Drop Copy Handler C++ library  5.6.0
API documentation
Warning.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4 // and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable OnixS Software
7 // Services Agreement (the Agreement) and Customer end user license agreements granting
8 // a non-assignable, non-transferable and non-exclusive license to use the software
9 // for it's own data processing purposes under the terms defined in the Agreement.
10 //
11 // Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12 // of this source code or associated reference material to any other location for further reproduction
13 // or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14 //
15 // Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16 // the terms of the Agreement is a violation of copyright law.
17 //
18 
19 #pragma once
20 
21 #include "OnixS/CME/DropCopy/Export.h"
23 
24 namespace OnixS { namespace CME { namespace DropCopy {
25 
26 /// List of known warnings.
27 struct ONIXS_CME_DROP_COPY_EXPORT KnownWarnings
28 {
29  /// List of known warnings.
30  enum Enum
31  {
32  /// General-purpose warning.
34 
35  /// Indicates failure in the user-space code.
36  /// When the Handler catches exception from the
37  /// user-space code, warning of given code reported.
38  ListenerFailure
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_CME_DROP_COPY_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 inline WarningCode Warning::code() const
98 {
99  return code_;
100 }
101 
102 inline const char* Warning::description() const
103 {
104  return description_;
105 }
106 
107 inline const char* Warning::source() const
108 {
109  return source_;
110 }
111 
112 inline std::string Warning::toString() const
113 {
114  std::string str;
115  toString(str);
116  return str;
117 }
118 
119 }}}
120 
121 namespace std {
122 // Outputs message into standard stream.
123 ONIXS_CME_DROP_COPY_EXPORT std::ostream& operator<<(std::ostream&, const OnixS::CME::DropCopy::Warning&);
124 }
const char * description() const
Human readable description.
Definition: Warning.h:102
STL namespace.
const char * source() const
Origin of the warning.
Definition: Warning.h:107
std::string toString() const
String presentation of an warning.
Definition: Warning.h:112
Enum
List of known warnings.
Definition: Warning.h:30
WarningCode code() const
Code of warning.
Definition: Warning.h:97
KnownWarnings::Enum WarningCode
Code of warning.
Definition: Warning.h:49
List of known warnings.
Definition: Warning.h:27