OnixS CME Drop Copy Handler C++ library  5.7.1
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
12 // part of this source code or associated reference material to any other location for further
13 // reproduction or redistribution, and any amendments to this copyright notice, are expressly
14 // 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/CME/DropCopy/Export.h"
24 
25 namespace OnixS { namespace CME { namespace DropCopy {
26 
27 /// List of known warnings.
28 struct ONIXS_CME_DROP_COPY_EXPORT KnownWarnings
29 {
30  /// List of known warnings.
31  enum Enum
32  {
33  /// General-purpose warning.
35 
36  /// Indicates failure in the user-space code.
37  /// When the Handler catches exception from the
38  /// user-space code, warning of given code reported.
39  ListenerFailure
40  };
41 
42  /// Returns constant from its text presentation.
43  static Enum deserialize(const char* value);
44 
45  /// Returns description of a particular warning.
46  static const char* toString(Enum value);
47 };
48 
49 /// Code of warning.
51 
52 /// Warning.
53 class ONIXS_CME_DROP_COPY_EXPORT Warning
54 {
55 public:
56  /// Initializes instance with just a code.
57  Warning(const std::string& source, WarningCode code);
58 
59  /// Initializes instance with code and description.
60  Warning(const std::string& source, WarningCode code, const std::string& description);
61 
62  /// Initializes as clone of another warning.
63  Warning(const Warning& other);
64 
65  /// Cleans internal resources.
66  ~Warning();
67 
68  /// Code of warning.
69  WarningCode code() const;
70 
71  /// Human readable description.
72  const char* description() const;
73 
74  /// Origin of the warning.
75  const char* source() const;
76 
77  /// String presentation of an warning.
78  std::string toString() const;
79 
80  /// Appends presentation of an warning to the string.
81  void toString(std::string&) const;
82 
83  /// Copies warning attributes from another instance.
84  Warning& operator=(const Warning& other);
85 
86 private:
87  enum Traits
88  {
89  SourceMaxLength = 128,
90  DescriptionMaxLength = 1024
91  };
92 
93  WarningCode code_;
94  char source_[SourceMaxLength];
95  char description_[DescriptionMaxLength];
96 };
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 }}}
121 
122 namespace std {
123 // Outputs message into standard stream.
124 ONIXS_CME_DROP_COPY_EXPORT std::ostream&
125 operator<<(std::ostream&, const OnixS::CME::DropCopy::Warning&);
126 }
const char * description() const
Human readable description.
Definition: Warning.h:103
STL namespace.
const char * source() const
Origin of the warning.
Definition: Warning.h:108
std::string toString() const
String presentation of an warning.
Definition: Warning.h:113
Enum
List of known warnings.
Definition: Warning.h:31
WarningCode code() const
Code of warning.
Definition: Warning.h:98
KnownWarnings::Enum WarningCode
Code of warning.
Definition: Warning.h:50
List of known warnings.
Definition: Warning.h:28