| Face Engine SDK 5.33.0 A face detection, recognition and tracking engine.

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ISettingsProvider.h
Go to the documentation of this file.
1
8 #pragma once
9
10 #include <cstring>
11 #include <fsdk/FSDKError.h>
12 #include <fsdk/IObject.h>
13 #include <fsdk/Types.h>
14 #include <string>
15
16 namespace fsdk {
17
18 #ifndef DOXYGEN_SHOULD_SKIP_THIS
19 DECLARE_SMARTPTR(ISettingsProvider);
20 #endif
21
32 struct FSDK_API ISettingsProvider : IRefCounted {
33
37 enum class Error : uint32_t {
38 Ok,
39 IOError,
40 Memory,
41 Internal,
42 InvalidPi,
43 InvalidTag,
44 InvalidCdata,
45 FileNotFound,
46 InvalidPcdata,
47 InvalidDocType,
48 InvalidSettings,
49 InvalidComment,
50 InvalidAttribute,
51 InvalidEndElement,
52 AppendInvalidRoot,
53 NoDocumentElement,
55 EndElementMismatch,
56 InvalidStartElement,
58 MemoryAllocationFailed,
59 };
60
66 virtual const char* getDefaultPath() const noexcept = 0;
67
72 virtual void setDefaultPath(const char* path) noexcept = 0;
73
80 virtual Result<Error> load(const char* path) noexcept = 0;
81
89 virtual Result<Error> loadFromString(const char* content) noexcept = 0;
90
96 virtual bool save(const char* path) const noexcept = 0;
97
102 virtual void clear() noexcept = 0;
103
108 virtual bool isEmpty() const noexcept = 0;
109
113 struct FSDK_API Value {
114
118 union Data {
119 struct Int1 {
120 int m_value;
121 } m_int1;
122
123 struct Int2 {
124 int m_value[2];
125 } m_int2;
126
127 struct Int3 {
128 int m_value[3];
129 } m_int3;
130
131 struct Int4 {
132 int m_value[4];
133 } m_int4;
134
135 struct ULong {
136 std::uint64_t m_value;
137 } m_uLong;
138
139 struct Float1 {
140 float m_value;
141 } m_float1;
142
143 struct Float2 {
144 float m_value[2];
145 } m_float2;
146
147 struct Float3 {
148 float m_value[3];
149 } m_float3;
150
151 struct Float4 {
152 float m_value[4];
153 } m_float4;
154
155 struct String {
156 char* m_value;
157 } m_string;
158 } m_data;
159
163 enum Type {
164 Undefined,
165 Int1,
166 Int2,
167 Int3,
168 Int4,
169 ULong,
170 Float1,
171 Float2,
172 Float3,
173 Float4,
174 String
175 } m_type;
176
181 Value() noexcept;
182
187 Value(int x) noexcept;
188
193 Value(std::uint64_t x) noexcept;
194
200 Value(int x, int y) noexcept;
201
208 Value(int x, int y, int z) noexcept;
209
217 Value(int x, int y, int z, int w) noexcept;
218
223 Value(float x) noexcept;
224
230 Value(float x, float y) noexcept;
237 Value(float x, float y, float z) noexcept;
238
246 Value(float x, float y, float z, float w) noexcept;
247
253 Value(const char* string) noexcept;
254
259 Value(const Rect& rect) noexcept;
260
265 Value(const Size& size) noexcept;
266
271 Value(const Point2f& point) noexcept;
272
277 Value(bool x) noexcept;
278
283 operator bool() const noexcept;
284
290 bool is(Type type) const noexcept;
291
292
297 bool setString(const char* string) noexcept;
298
305 bool getString(char* string) const noexcept;
306
307
312 void setRect(const Rect& rect) noexcept;
313
321 bool getRect(Rect* rect) const noexcept;
322
323
328 void setSize(const Size& size) noexcept;
329
337 bool getSize(Size* size) const noexcept;
338
339
344 void setPoint2i(const Point2i& point) noexcept;
345
353 bool getPoint2i(Point2i* point) const noexcept;
354
355
360 void setPoint2f(const Point2f& point) noexcept;
361
369 bool getPoint2f(Point2f* point) const noexcept;
370
375 void setBool(bool x) noexcept;
376
384 bool getBool(bool* x) const noexcept;
385
386
391 void setInt(int x) noexcept;
392
399 bool getInt(int* x) const noexcept;
400
405 void setULong(std::uint64_t x) noexcept;
406
413 bool getULong(std::uint64_t* x) const noexcept;
414
415
421 void setInt(int x, int y) noexcept;
422
431 bool getInt(int* x, int* y) const noexcept;
432
433
440 void setInt(int x, int y, int z) noexcept;
441
451 bool getInt(int* x, int* y, int* z) const noexcept;
452
453
461 void setInt(int x, int y, int z, int w) noexcept;
462
473 bool getInt(int* x, int* y, int* z, int* w) const noexcept;
474
475
480 void setFloat(float x) noexcept;
481
488 bool getFloat(float* x) const noexcept;
489
490
496 void setFloat(float x, float y) noexcept;
497
506 bool getFloat(float* x, float* y) const noexcept;
507
508
515 void setFloat(float x, float y, float z) noexcept;
516
526 bool getFloat(float* x, float* y, float* z) const noexcept;
527
528
536 void setFloat(float x, float y, float z, float w) noexcept;
537
548 bool getFloat(float* x, float* y, float* z, float* w) const noexcept;
549
550
557 float asFloat(float defaultValue = 0.f) const noexcept;
558
559
567 Point2f asPoint2f(const Point2f& defaultValue = Point2f()) const noexcept;
568
569
577 bool asBool(bool defaultValue = false) const noexcept;
578
579
586 int asInt(int defaultValue = 0) const noexcept;
587
594 std::uint64_t asULong(std::uint64_t defaultValue = 0) const noexcept;
595
596
604 Size asSize(const Size& defaultValue = Size()) const noexcept;
605
606
614 Point2i asPoint2i(const Point2i& defaultValue = Point2i()) const noexcept;
615
616
624 Rect asRect(const Rect& defaultValue = Rect()) const noexcept;
625
626
634 const char* asString(const char* defaultValue = "") const noexcept;
635
636 inline Value(const Value& other) = delete;
637 Value(Value&& other);
638
639 inline Value& operator=(const Value& other) = delete;
640 Value& operator=(Value&& other);
641
642 void swap(Value& first, Value& second);
643
644 ~Value();
645 };
646
648 struct FSDK_API Key {
649
651 Key() noexcept;
652
658 Key(const char* section, const char* parameter) noexcept;
659
664 const char* getSection() const noexcept;
665
670 const char* getParameter() const noexcept;
671
676 void setSection(const char* section) noexcept;
677
682 void setParameter(const char* parameter) noexcept;
683
689 bool operator<(const ISettingsProvider::Key& other) const noexcept;
690
691 protected:
692 static const unsigned int m_bufferLength = 128;
693 char m_section[m_bufferLength];
694 char m_parameter[m_bufferLength];
695 };
696
698 struct FSDK_API Desc {
699
701 Desc() noexcept;
702
707 Desc(const char* desc) noexcept;
708
713 const char* getDesc() const noexcept;
714
719 void setDesc(const char* desc) noexcept;
720
721 protected:
722 static const unsigned int m_bufferLength = 256;
723 char m_desc[m_bufferLength];
724 };
725
727 struct FSDK_API Entry {
728
729 Value m_value;
730 Desc m_desc;
731
733 Entry() noexcept = default;
734
735 Entry(Entry&& right);
736
737 Entry& operator=(Entry&& right);
738
739 void swap(Entry& first, Entry& second);
745 Entry(const Desc& desc, Value&& value) noexcept;
746
751 void setDesc(const Desc& desc) noexcept;
752
757 void setValue(Value&& value) noexcept;
758
763 const Desc& getDesc() const noexcept;
764
769 const Value& getValue() const noexcept;
770 };
771
779 virtual void setDesc(const Key& key, const Desc& desc) noexcept = 0;
780
789 void setDesc(const char* section, const char* parameter, const Desc& desc) noexcept;
790
798 virtual void setValue(const Key& key, Value&& value) noexcept = 0;
799
808 void setValue(const char* section, const char* parameter, Value&& value) noexcept;
809
817 virtual void setEntry(const Key& key, Entry&& entry) noexcept = 0;
818
827 void setEntry(const Key& key, const Desc& desc, Value&& value) noexcept;
828
838 void setEntry(const char* section, const char* parameter, const Desc& desc, Value&& value) noexcept;
839
847 virtual const Entry& getEntry(const Key& key) const noexcept = 0;
848
856 Desc getDesc(const Key& key) const noexcept;
857
866 Desc getDesc(const char* section, const char* parameter) const noexcept;
867
875 const Value& getValue(const Key& key) const noexcept;
876
885 const Value& getValue(const char* section, const char* parameter) const noexcept;
886 };
887
893 FSDK_API fsdk::ResultValue<fsdk::FSDKError, fsdk::ISettingsProviderPtr>
894 createSettingsProvider(const char* path) noexcept;
895
902 FSDK_API ResultValue<FSDKError, ISettingsProviderPtr>
903 createSettingsProviderFromString(const char* content) noexcept;
904
908 template <>
909 struct ErrorTraits<ISettingsProvider::Error> {
910
911 static bool isOk(ISettingsProvider::Error error) noexcept {
912 return error == ISettingsProvider::Error::Ok;
913 }
914
915 static const char* toString(ISettingsProvider::Error error) noexcept {
916 switch(error) {
917 case ISettingsProvider::Error::Ok:
918 return "Ok";
919 case ISettingsProvider::Error::Memory:
920 return "Could not allocate memory";
921 case ISettingsProvider::Error::IOError:
922 return "Error reading from file";
923 case ISettingsProvider::Error::Internal:
924 return "Internal error";
925 case ISettingsProvider::Error::InvalidPi:
926 return "Error during document declaration/processing instruction parsing";
927 case ISettingsProvider::Error::InvalidTag:
928 return "Parser could not determine tag type";
929 case ISettingsProvider::Error::InvalidCdata:
930 return "Error during CDATA section parsing";
931 case ISettingsProvider::Error::FileNotFound:
932 return "File was not found";
933 case ISettingsProvider::Error::InvalidPcdata:
934 return "Error during PCDATA section parsing";
935 case ISettingsProvider::Error::InvalidComment:
936 return "Error during comment parsing";
937 case ISettingsProvider::Error::InvalidDocType:
938 return "Error during document type declaration parsing";
939 case ISettingsProvider::Error::InvalidSettings:
940 return "Settings sections is invalid or absent";
941 case ISettingsProvider::Error::InvalidAttribute:
942 return "Error during element attribute parsing";
943 case ISettingsProvider::Error::InvalidEndElement:
944 return "Error during end element tag parsing";
945 case ISettingsProvider::Error::AppendInvalidRoot:
946 return "Root type is not node_element or node_document";
947 case ISettingsProvider::Error::NoDocumentElement:
948 return "Document without element nodes";
949 case ISettingsProvider::Error::EndElementMismatch:
950 return "Mismatch of start-end tags";
951 case ISettingsProvider::Error::InvalidStartElement:
952 return "Error during start element tag parsing";
953 default:
954 return "Unknown error";
955 }
956 }
957 };
958
960 } // namespace fsdk
fsdk::ISettingsProvider::Error::Memory
Could not allocate memory.
fsdk::ISettingsProvider::Value::Float2
2D floating point.
Definition: ISettingsProvider.h:171
fsdk::ISettingsProvider::Value::Float1
floating point.
Definition: ISettingsProvider.h:170
fsdk::ISettingsProvider::Error
Error
Config parsing error codes.
Definition: ISettingsProvider.h:37
fsdk::ISettingsProvider::Value::Float3
3D floating point.
Definition: ISettingsProvider.h:172
FSDK_API
#define FSDK_API
Dummy.
Definition: Def.h:27
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:56
fsdk::ISettingsProvider::Error::AppendInvalidRoot
(exclusive to xml_node::append_buffer)
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:27
Types.h
Common data types and structures.
fsdk::ISettingsProvider::Key
Configuration parameter key.
Definition: ISettingsProvider.h:648
fsdk::ISettingsProvider::Value::Data::Int2
Definition: ISettingsProvider.h:123
IObject.h
Object system types and interfaces.
fsdk::ISettingsProvider::Value::Data::Int4
Definition: ISettingsProvider.h:131
FSDKError.h
Common SDK error codes.
fsdk::createSettingsProviderFromString
FSDK_API ResultValue< FSDKError, ISettingsProviderPtr > createSettingsProviderFromString(const char *content) noexcept
Creates a settings provider from the xml-formatted string.
fsdk::FSDKError::Internal
Internal error.
fsdk::ErrorTraits
Definition: Result.h:8
fsdk::ISettingsProvider::Error::InvalidTag
Parser could not determine tag type.
fsdk::ISettingsProvider::Value::Float4
4D floating point.
Definition: ISettingsProvider.h:173
fsdk::ISettingsProvider::Value::Type
Type
Value type.
Definition: ISettingsProvider.h:163
fsdk::ISettingsProvider::Entry::m_desc
Desc m_desc
Parameter description.
Definition: ISettingsProvider.h:730
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:37
fsdk::ISettingsProvider::Value::Data::Float4
Definition: ISettingsProvider.h:151
fsdk::ISettingsProvider::Value::Data
Value data.
Definition: ISettingsProvider.h:118
fsdk::ISettingsProvider::Value::Data::Float2
Definition: ISettingsProvider.h:143
fsdk::ISettingsProvider::Error::EndElementMismatch
tag was not closed or there was an excessive closing tag)
fsdk::ISettingsProvider::Error::InvalidPi
Parsing error occurred while parsing document declaration/processing instruction. ...
fsdk::ISettingsProvider::Value::ULong
std::uint64_t.
Definition: ISettingsProvider.h:169
fsdk::ISettingsProvider::Error::InvalidDocType
Parsing error occurred while parsing document type declaration.
fsdk::FSDKError::Ok
Ok.
fsdk::ISettingsProvider::Error::InvalidComment
Parsing error occurred while parsing comment.
fsdk::ISettingsProvider::Value::Data::Int1
Definition: ISettingsProvider.h:119
fsdk::ISettingsProvider::Desc
Configuration parameter description.
Definition: ISettingsProvider.h:698
fsdk::ISettingsProvider::Value::Data::Int3
Definition: ISettingsProvider.h:127
fsdk::ISettingsProvider::Error::Ok
No error.
fsdk::operator<
bool operator<(Version lhs, Version rhs) noexcept
Check if one version is less than another.
Definition: Version.h:36
fsdk::ISettingsProvider::Value::Int1
Integer.
Definition: ISettingsProvider.h:165
fsdk::ISettingsProvider::Error::FileNotFound
File was not found during load_file()
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
fsdk::ISettingsProvider::Value::Data::Float3
Definition: ISettingsProvider.h:147
fsdk::ISettingsProvider::Value::Data::Float1
Definition: ISettingsProvider.h:139
fsdk::ISettingsProvider::Value::Int4
4D integer.
Definition: ISettingsProvider.h:168
fsdk::ISettingsProvider::Value::Data::ULong
Definition: ISettingsProvider.h:135
fsdk::ISettingsProvider::Error::NoDocumentElement
Parsing resulted in a document without element nodes.
fsdk::ISettingsProvider::Error::InvalidEndElement
Parsing error occurred while parsing end element tag.
fsdk::ISettingsProvider::Error::InvalidSettings
Settings section is invalid or absent.
fsdk::ISettingsProvider::Error::Internal
Internal error occurred.
fsdk::ISettingsProvider::Value::Int2
2D integer.
Definition: ISettingsProvider.h:166
fsdk::ISettingsProvider::Error::InvalidPcdata
Parsing error occurred while parsing PCDATA section.
fsdk::toString
const char * toString(Image::MemoryResidence residence)
Returns a string representation of a MemoryResidence type.
fsdk::BaseRect< int >
fsdk::ISettingsProvider::Entry
Configuration parameter entry.
Definition: ISettingsProvider.h:727
fsdk::FSDKError
FSDKError
Common SDK error codes.
Definition: FSDKError.h:17
fsdk::ISettingsProvider::Value
Configuration parameter value.
Definition: ISettingsProvider.h:113
fsdk::ISettingsProvider::Error::InvalidStartElement
Parsing error occurred while parsing start element tag.
fsdk::ISettingsProvider::Error::IOError
Error reading from file/stream.
fsdk::createSettingsProvider
FSDK_API ResultValue< FSDKError, ISettingsProviderPtr > createSettingsProvider(const char *path) noexcept
Create a settings provider.
fsdk::ISettingsProvider::Value::Int3
3D integer.
Definition: ISettingsProvider.h:167
fsdk::ISettingsProvider::Entry::m_value
Value m_value
Parameter value.
Definition: ISettingsProvider.h:729
fsdk::ISettingsProvider::Value::Undefined
Unkown value type.
Definition: ISettingsProvider.h:164
fsdk::Vector2< int >
fsdk::ISettingsProvider::Value::Data::String
Definition: ISettingsProvider.h:155
fsdk::ISettingsProvider::Error::InvalidAttribute
Parsing error occurred while parsing element attribute.
fsdk::ISettingsProvider::Error::InvalidCdata
Parsing error occurred while parsing CDATA section.
fsdk::ISettingsProvider
SDK settings provider interface.
Definition: ISettingsProvider.h:32