12 #ifndef WITHOUT_PROCESSING_BLOCK
22 #include <unordered_map>
24 #include <pbio/DllHandle.h>
25 #include <pbio/RawImage.h>
26 #include <pbio/DynamicTemplateIndex.h>
31 typedef LightSmartPtr<import::DllHandle>::tPtr DHPtr;
33 inline void tdvCheckException(
const DHPtr& dll_handle, ContextEH*& out_exception) {
36 auto err = Error(dll_handle->TDVException_getErrorCode(out_exception), dll_handle->TDVException_getMessage(out_exception));
37 dll_handle->TDVException_deleteException(out_exception);
38 out_exception =
nullptr;
58 template<
bool isConst=false>
59 class ContextArrayIterator
65 charsList(
size_t length,
char** ptr) : length_(length), ptr_(ptr) {}
67 return (index<length_) ? *(ptr_+index) :
nullptr;
76 std::shared_ptr<charsList> keys_;
78 void charsList_deleter(charsList* ptr) {
79 for(
size_t indx=0; indx < ptr->length_; ++indx)
80 base_.dll_handle->TDVContext_freePtr(ptr->ptr_[indx]);
81 base_.dll_handle->TDVContext_freePtr(ptr->ptr_);
85 typedef std::ptrdiff_t difference_type;
86 typedef std::forward_iterator_tag iterator_category;
88 typedef typename std::conditional<isConst, const value_type*, value_type*>::type pointer;
89 typedef typename std::conditional<isConst, const value_type&, value_type&>::type reference;
90 typedef const value_type& const_reference;
92 ContextArrayIterator(
const Context& ctx,
long long index);
93 ContextArrayIterator(
const Context& ctx,
const std::string& key);
95 ContextArrayIterator(
const ContextArrayIterator& iter);
96 ContextArrayIterator& operator=(
const ContextArrayIterator& iter) =
delete;
97 ContextArrayIterator(ContextArrayIterator&& iter);
98 ContextArrayIterator& operator=(ContextArrayIterator&& iter) =
delete;
100 ~ContextArrayIterator() {
105 bool operator==(
const ContextArrayIterator& other)
const {
106 return ((this->base_ == other.base_) && (this->curr_ == other.curr_));
109 bool operator!=(
const ContextArrayIterator& other)
const {
110 return (!(this->base_ == other.base_) || !(this->curr_ == other.curr_));
113 ContextArrayIterator& operator++();
114 ContextArrayIterator operator++(
int);
116 reference operator*() {
120 pointer operator->() {
124 std::string key()
const {
125 if (keys_ && index_ < length_)
126 return std::string(keys_->operator[](index_));
127 return std::string();
144 Context(
const DHPtr& dll_handle) : dll_handle(dll_handle), weak_(
false), eh_(
nullptr) {
145 handle_ = dll_handle->TDVContext_create(&eh_);
146 tdvCheckException(dll_handle, eh_);
149 Context(
const DHPtr& dll_handle, HContext* handle,
bool weak =
true) : dll_handle(dll_handle), weak_(weak), eh_(
nullptr) {
154 handle_ = dll_handle->TDVContext_clone(handle, &eh_);
155 tdvCheckException(dll_handle, eh_);
159 Context(
const DHPtr& dll_handle,
const uint8_t* data, uint64_t dataSize) :
160 dll_handle(dll_handle),
164 handle_ = dll_handle->TDVContext_createFromEncodedImage(data, dataSize, &eh_);
165 tdvCheckException(dll_handle, eh_);
168 Context(
const DHPtr& dll_handle, uint8_t* data, int32_t width, int32_t height, Format format, int32_t baseAngle) :
169 dll_handle(dll_handle),
173 handle_ = dll_handle->TDVContext_createFromFrame(data, width, height, static_cast<int32_t>(format), baseAngle, &eh_);
174 tdvCheckException(dll_handle, eh_);
177 Context(
const DHPtr& dll_handle,
const char* path) :
178 dll_handle(dll_handle),
182 handle_ = dll_handle->TDVContext_createFromJsonFile(path, &eh_);
183 tdvCheckException(dll_handle, eh_);
189 mutable ContextEH* eh_;
198 dll_handle->TDVContext_destroy(handle_, &eh_);
199 if (eh_ && std::uncaught_exception())
200 std::cerr <<
Error(dll_handle->TDVException_getErrorCode(eh_), dll_handle->TDVException_getMessage(eh_)).what();
202 tdvCheckException(dll_handle, eh_);
206 Context(
const Context& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
207 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
208 tdvCheckException(dll_handle, eh_);
215 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
217 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
218 tdvCheckException(dll_handle, eh_);
219 std::swap(handle_, copy);
220 dll_handle->TDVContext_destroy(copy, &eh_);
222 tdvCheckException(dll_handle, eh_);
227 Context(
Context&& other) : dll_handle(other.dll_handle), weak_(
false), eh_(
nullptr) {
230 handle_ = dll_handle->TDVContext_clone(other.handle_, &eh_);
231 tdvCheckException(dll_handle, eh_);
235 handle_ = other.handle_;
236 other.handle_ =
nullptr;
245 dll_handle->TDVContext_copy(other.handle_, handle_, &eh_);
246 tdvCheckException(dll_handle, eh_);
252 HContext* copy = dll_handle->TDVContext_clone(other.handle_, &eh_);
253 tdvCheckException(dll_handle, eh_);
254 std::swap(handle_, copy);
255 dll_handle->TDVContext_destroy(copy, &eh_);
256 tdvCheckException(dll_handle, eh_);
260 handle_ = other.handle_;
261 other.handle_ =
nullptr;
279 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
281 setValue(std::forward<T>(value));
285 bool operator==(
const Context& other)
const
286 {
return this->handle_ == other.handle_;}
297 size_t lenght = dll_handle->TDVContext_getLength(handle_, &eh_);
298 tdvCheckException(dll_handle, eh_);
302 ContextArrayIterator<> begin(){
303 return ContextArrayIterator<>(*
this, 0);
306 ContextArrayIterator<> end(){
307 return ContextArrayIterator<>(*
this, -1);
310 ContextArrayIterator<true> begin()
const {
311 return ContextArrayIterator<true>(*
this, 0);
314 ContextArrayIterator<true> end()
const {
315 return ContextArrayIterator<true>(*
this, -1);
318 ContextArrayIterator<true> cbegin()
const {
319 return ContextArrayIterator<true>(*
this, 0);
322 ContextArrayIterator<true> cend()
const {
323 return ContextArrayIterator<true>(*
this, -1);
347 const Ref
operator[](
const std::string& key)
const;
351 Ref at(
const char* key);
352 Ref at(
const std::string& key);
353 Ref at(
const int index);
355 const Ref at(
const char* key)
const;
356 const Ref at(
const std::string& key)
const;
357 const Ref at(
const int index)
const;
370 bool result = dll_handle->TDVContext_contains(handle_, key.data(), &eh_);
371 tdvCheckException(dll_handle, eh_);
387 bool result = dll_handle->TDVContext_compare(handle_, other.handle_, &eh_);
388 tdvCheckException(dll_handle, eh_);
402 size_t length =
size();
404 auto keys = dll_handle->TDVContext_getKeys(handle_, length, &eh_);
405 tdvCheckException(dll_handle, eh_);
407 std::vector<std::string> result(length);
408 for (
size_t i = 0; i < length; ++i)
409 result.emplace_back(keys[i]);
414 ContextArrayIterator<> find(
const std::string& key) {
415 return ContextArrayIterator<>(*
this, key);
418 ContextArrayIterator<true> find(
const std::string& key)
const {
419 return ContextArrayIterator<true>(*
this, key);
423 typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type push_back(T&& data) {
425 elem.setValue(std::forward<T>(data));
427 push_back(std::move(elem));
439 dll_handle->TDVContext_pushBack(handle_, data.handle_,
true, &eh_);
440 tdvCheckException(dll_handle, eh_);
443 void push_back(
Context&& data) {
444 dll_handle->TDVContext_pushBack(handle_, data.handle_, weak_, &eh_);
445 tdvCheckException(dll_handle, eh_);
457 double ret = dll_handle->TDVContext_getDouble(handle_, &eh_);
458 tdvCheckException(dll_handle, eh_);
471 long ret = dll_handle->TDVContext_getLong(handle_, &eh_);
472 tdvCheckException(dll_handle, eh_);
485 bool ret = dll_handle->TDVContext_getBool(handle_, &eh_);
486 tdvCheckException(dll_handle, eh_);
499 unsigned long str_size = dll_handle->TDVContext_getStrSize(handle_, &eh_);
500 tdvCheckException(dll_handle, eh_);
502 ret.resize(str_size);
503 dll_handle->TDVContext_getStr(handle_, &ret[0], &eh_);
504 tdvCheckException(dll_handle, eh_);
517 unsigned char* ret = dll_handle->TDVContext_getDataPtr(handle_, &eh_);
518 tdvCheckException(dll_handle, eh_);
523 void* index = dll_handle->TDVContext_getDynamicTemplateIndex(handle_, &eh_);
524 tdvCheckException(dll_handle, eh_);
525 return pbio::DynamicTemplateIndex::Ptr::make(dll_handle, index,
true);
529 void* templ = dll_handle->TDVContext_getContextTemplate(handle_, &eh_);
530 tdvCheckException(dll_handle, eh_);
531 return pbio::ContextTemplate::Ptr::make(dll_handle, templ);
543 dll_handle->TDVContext_putStr(handle_, str, &eh_);
544 tdvCheckException(dll_handle, eh_);
556 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
557 tdvCheckException(dll_handle, eh_);
569 dll_handle->TDVContext_putLong(handle_, val, &eh_);
570 tdvCheckException(dll_handle, eh_);
582 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
583 tdvCheckException(dll_handle, eh_);
595 dll_handle->TDVContext_putBool(handle_, val, &eh_);
596 tdvCheckException(dll_handle, eh_);
610 unsigned char* ret{
nullptr};
612 ret = dll_handle->TDVContext_allocDataPtr(handle_, copy_sz, &eh_);
614 ret = dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), static_cast<uint64_t>(copy_sz), &eh_);
615 tdvCheckException(dll_handle, eh_);
619 unsigned char*
setDataPtr(
const void* ptr,
int copy_sz) {
620 unsigned char* ret = dll_handle->TDVContext_putConstDataPtr(handle_, static_cast<const unsigned char*>(ptr), copy_sz, &eh_);
621 tdvCheckException(dll_handle, eh_);
627 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
628 tdvCheckException(dll_handle, eh_);
632 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
633 tdvCheckException(dll_handle, eh_);
645 bool value = dll_handle->TDVContext_isNone(handle_, &eh_);
646 tdvCheckException(dll_handle, eh_);
659 bool value = dll_handle->TDVContext_isArray(handle_, &eh_);
660 tdvCheckException(dll_handle, eh_);
673 bool value = dll_handle->TDVContext_isObject(handle_, &eh_);
674 tdvCheckException(dll_handle, eh_);
687 bool val = dll_handle->TDVContext_isBool(handle_, &eh_);
688 tdvCheckException(dll_handle, eh_);
701 bool val = dll_handle->TDVContext_isLong(handle_, &eh_);
702 tdvCheckException(dll_handle, eh_);
715 bool val = dll_handle->TDVContext_isDouble(handle_, &eh_);
716 tdvCheckException(dll_handle, eh_);
729 bool val = dll_handle->TDVContext_isString(handle_, &eh_);
730 tdvCheckException(dll_handle, eh_);
743 bool val = dll_handle->TDVContext_isDataPtr(handle_, &eh_);
744 tdvCheckException(dll_handle, eh_);
748 bool isDynamicTemplateIndex()
const {
749 bool val = dll_handle->TDVContext_isDynamicTemplateIndex(handle_, &eh_);
750 tdvCheckException(dll_handle, eh_);
754 bool isContextTemplate()
const {
755 bool val = dll_handle->TDVContext_isContextTemplate(handle_, &eh_);
756 tdvCheckException(dll_handle, eh_);
760 HContext* getHandle() {
return handle_;}
761 const HContext* getHandle()
const {
return handle_;}
770 dll_handle->TDVContext_clear(handle_, &eh_);
771 tdvCheckException(dll_handle,eh_);
783 dll_handle->TDVContext_erase(handle_, str, &eh_);
784 tdvCheckException(dll_handle,eh_);
795 void erase(
const std::string& str) {
808 dll_handle->TDVContext_reserve(handle_, size, &eh_);
809 tdvCheckException(dll_handle,eh_);
822 dll_handle->TDVContext_saveToJsonFile(handle_, path.c_str(), &eh_);
823 tdvCheckException(dll_handle,eh_);
836 dll_handle->TDVContext_saveToJsonFile(handle_, path, &eh_);
837 tdvCheckException(dll_handle,eh_);
842 void setValue(
const char* str) {
843 dll_handle->TDVContext_putStr(handle_, str, &eh_);
844 tdvCheckException(dll_handle, eh_);
846 void setValue(
const std::string& str) {
847 dll_handle->TDVContext_putStr(handle_, str.c_str(), &eh_);
848 tdvCheckException(dll_handle, eh_);
851 template<typename T, typename = typename std::enable_if<std::is_enum<T>::value || std::is_integral<T>::value>::type>
852 void setValue(T val) {
853 dll_handle->TDVContext_putLong(handle_, val, &eh_);
854 tdvCheckException(dll_handle, eh_);
857 void setValue(
double val) {
858 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
859 tdvCheckException(dll_handle, eh_);
861 void setValue(
float val) {
862 dll_handle->TDVContext_putDouble(handle_, val, &eh_);
863 tdvCheckException(dll_handle, eh_);
865 void setValue(
bool val) {
866 dll_handle->TDVContext_putBool(handle_, val, &eh_);
867 tdvCheckException(dll_handle, eh_);
869 void setValue(
void* ptr,
int copy_sz = 0) {
870 dll_handle->TDVContext_putDataPtr(handle_, static_cast<unsigned char*>(ptr), copy_sz, &eh_);
871 tdvCheckException(dll_handle, eh_);
874 dll_handle->TDVContext_putDynamicTemplateIndex(handle_, templateIndex->_impl, &eh_);
875 tdvCheckException(dll_handle, eh_);
878 dll_handle->TDVContext_putContextTemplate(handle_, templ->_impl, &eh_);
879 tdvCheckException(dll_handle, eh_);
886 ContextRef(
const DHPtr &dll_handle, HContext* handle) :
Context(dll_handle ,handle,
true) {}
890 template <typename T, typename = typename std::enable_if<!std::is_base_of<Context, typename std::decay<T>::type>::value>::type>
891 void operator=(T&& value) {
892 setValue(std::forward<T>(value));
896 template<
bool isConst>
897 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
long long index) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
899 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
900 tdvCheckException(base_.dll_handle, base_.eh_);
901 index_ = (index > -1) ? std::min<size_t>(static_cast<size_t>(index), length_) : length_;
902 if(index_ < length_) {
905 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
906 tdvCheckException(base_.dll_handle, base_.eh_);
907 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
908 curr_ =
new Context(base_[keys_->operator[](index)]);
911 curr_ =
new Context(base_[index]);
915 template<
bool isConst>
916 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const Context& ctx,
const std::string& key) : base_(ctx), curr_(nullptr), isObj_(ctx.isObject())
918 length_ = base_.dll_handle->TDVContext_getLength(base_.handle_, &(base_.eh_));
919 tdvCheckException(base_.dll_handle, base_.eh_);
921 if(isObj_ && length_) {
922 auto keys = base_.dll_handle->TDVContext_getKeys(base_.handle_, length_, &(base_.eh_));
923 tdvCheckException(base_.dll_handle, base_.eh_);
924 keys_ = std::shared_ptr<charsList>(
new charsList(length_, keys), std::bind(&ContextArrayIterator::charsList_deleter,
this, std::placeholders::_1));
927 if(!key.compare(keys_->operator[](i))) {
929 curr_ =
new Context(base_[key]);
932 }
while((++i)<length_);
936 template<
bool isConst>
937 Context::ContextArrayIterator<isConst>::ContextArrayIterator(
const ContextArrayIterator& iter) :
938 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_ ? new
Context(*(iter.curr_)) : nullptr), isObj_(iter.isObj_), keys_(iter.keys_)
941 template<
bool isConst>
942 Context::ContextArrayIterator<isConst>::ContextArrayIterator(ContextArrayIterator&& iter) :
943 base_(iter.base_), length_(iter.length_), index_(iter.index_), curr_(iter.curr_), isObj_(iter.isObj_), keys_(std::move(iter.keys_)) {
944 iter.curr_ =
nullptr;
947 template<
bool isConst>
948 Context::ContextArrayIterator<isConst>& Context::ContextArrayIterator<isConst>::operator++() {
951 index_ = std::min<size_t>(index_+1, length_);
953 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
955 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
959 template<
bool isConst>
960 Context::ContextArrayIterator<isConst> Context::ContextArrayIterator<isConst>::operator++(
int) {
961 ContextArrayIterator tmp = *
this;
962 index_ = std::min<size_t>(index_+1, length_);
964 curr_ = (index_ < length_) ?
new Context(base_[keys_->operator[](index_)]) :
nullptr;
966 curr_ = (index_ < length_) ?
new Context(base_[index_]) :
nullptr;
970 inline Context::operator ContextRef()
972 return ContextRef(dll_handle, handle_);
976 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key.c_str(), &eh_);
977 tdvCheckException(dll_handle, eh_);
978 return Ref(dll_handle, handle);
982 HContext* handle = dll_handle->TDVContext_getOrInsertByKey(handle_, key, &eh_);
983 tdvCheckException(dll_handle, eh_);
984 return Ref(dll_handle, handle);
988 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
989 tdvCheckException(dll_handle, eh_);
990 return Ref(dll_handle, handle);
994 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
995 tdvCheckException(dll_handle, eh_);
996 return Ref(dll_handle, handle);
1000 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1001 tdvCheckException(dll_handle, eh_);
1002 return Ref(dll_handle, handle);
1006 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1007 tdvCheckException(dll_handle, eh_);
1008 return Ref(dll_handle, handle);
1011 inline Context::Ref Context::at(
const char* key) {
1012 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1013 tdvCheckException(dll_handle, eh_);
1014 return Ref(dll_handle, handle);
1017 inline Context::Ref Context::at(
const std::string& key) {
1018 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1019 tdvCheckException(dll_handle, eh_);
1020 return Ref(dll_handle, handle);
1023 inline Context::Ref Context::at(
const int index) {
1024 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1025 tdvCheckException(dll_handle, eh_);
1026 return Ref(dll_handle, handle);
1029 inline const Context::Ref Context::at(
const char* key)
const {
1030 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key, &eh_);
1031 tdvCheckException(dll_handle, eh_);
1032 return Ref(dll_handle, handle);
1035 inline const Context::Ref Context::at(
const std::string& key)
const {
1036 HContext* handle = dll_handle->TDVContext_getByKey(handle_, key.c_str(), &eh_);
1037 tdvCheckException(dll_handle, eh_);
1038 return Ref(dll_handle, handle);
1041 inline const Context::Ref Context::at(
const int index)
const {
1042 HContext* handle = dll_handle->TDVContext_getByIndex(handle_, index, &eh_);
1043 tdvCheckException(dll_handle, eh_);
1044 return Ref(dll_handle, handle);
1048 namespace context_utils {
1054 ctx[
"format"] =
"NDARRAY";
1055 ctx[
"color_space"] = color_mode.at(raw_image.format);
1057 size_t copy_sz = raw_image.
height * raw_image.
width * channels *
sizeof(uint8_t);
1058 if (raw_image.with_crop)
1060 unsigned char* buff{
nullptr};
1061 buff = ctx[
"blob"].setDataPtr(buff, copy_sz);
1062 size_t shift = (raw_image.crop_info_offset_y*raw_image.crop_info_data_image_width + raw_image.crop_info_offset_x)*channels*
sizeof(uint8_t);
1063 size_t stride = raw_image.
width*channels*
sizeof(uint8_t);
1064 unsigned char* ptr = buff;
1065 for(
int row=0; row<raw_image.
height; ++row)
1067 std::memcpy(ptr, raw_image.
data+shift, stride);
1068 shift += raw_image.crop_info_data_image_width*channels*
sizeof(uint8_t);
1073 ctx[
"blob"].setDataPtr(raw_image.
data, copy_sz);
1074 ctx[
"dtype"] =
"uint8_t";
1075 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
height));
1076 ctx[
"shape"].push_back(static_cast<int64_t>(raw_image.
width));
1077 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1082 ctx[
"format"] =
"NDARRAY";
1083 ctx[
"color_space"] = color_mode.at(format);
1085 size_t copy_sz = copy ? height * width * channels *
sizeof(uint8_t) : 0;
1086 ctx[
"blob"].setDataPtr(data, copy_sz);
1087 ctx[
"dtype"] =
"uint8_t";
1088 ctx[
"shape"].push_back(static_cast<int64_t>(height));
1089 ctx[
"shape"].push_back(static_cast<int64_t>(width));
1090 ctx[
"shape"].push_back(static_cast<int64_t>(channels));
1096 #endif // WITHOUT_PROCESSING_BLOCK
bool isString() const
checks whether the container is a long type string
Definition: Context.h:728
Interface object for creating other interface objects.
Definition: FacerecService.h:64
RGB, 24 bit per pixel, 8 bit per channel.
Definition: IRawImage.h:60
bool isDataPtr() const
checks whether the container is a pointer to the data
Definition: Context.h:742
Interface object that stores a captured face sample.
Definition: RawSample.h:49
void saveToJsonFile(std::string &path)
saves the contents of the container to a json file
Definition: Context.h:820
void erase(const char *str)
deletes the contents of the container-Context stored by key.
Definition: Context.h:782
void setString(const char *str)
adds a value of type string to the container
Definition: Context.h:542
void erase(const std::string &str)
deletes the contents of the container-Context stored by key.
Definition: Context.h:795
void saveToJsonFile(const char *path)
saves the contents of the container to a json file
Definition: Context.h:834
void reserve(const size_t size)
allocates memory for num elements in the array.
Definition: Context.h:807
Grayscale, 8 bit per pixel.
Definition: IRawImage.h:53
void setDouble(double val)
adds a value of type double to the container
Definition: Context.h:581
std::vector< std::string > getKeys()
returns a list of keys in the container-Context
Definition: Context.h:401
void setString(const std::string &str)
adds a value of type std::string to the container
Definition: Context.h:555
unsigned char * getDataPtr() const
returns a pointer to data from the container
Definition: Context.h:516
bool isDouble() const
checks whether the container is a long type double
Definition: Context.h:714
void push_back(const Context &data)
adds a object to the container.
Definition: Context.h:438
bool compare(const Context &other) const
compares two Context objects
Definition: Context.h:386
bool isBool() const
checks whether the container is a bool type value
Definition: Context.h:686
void clear()
clears the contents of the container-Context.
Definition: Context.h:769
BGR, 24 bit per pixel, 8 bit per channel.
Definition: IRawImage.h:67
size_t size() const
Get the size of the container.
Definition: Context.h:296
bool contains(const std::string &key) const
checks the existence of an element by a specific key
Definition: Context.h:369
bool isNone() const
checks if there are no elements in the container
Definition: Context.h:644
The class of exceptions thrown when errors occur.
Definition: Error.h:26
Context & operator=(T &&value)
adds a value to the container
Definition: Context.h:280
bool isLong() const
проверяет является ли контейнер значением типа long.
Definition: Context.h:700
void clear()
clears the contents of the container-Context.
Definition: Context.mm:166
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Alias for the type of a smart pointer to DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
long getLong() const
returns a long value from the container
Definition: Context.h:470
bool isObject() const
checks whether the container is an object
Definition: Context.h:672
Definition: Context.h:883
double getDouble() const
returns a double value from the container
Definition: Context.h:456
void setLong(long val)
adds a value of type long to the container
Definition: Context.h:568
bool getBool() const
returns a bool value from the container
Definition: Context.h:484
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:52
unsigned char * setDataPtr(void *ptr, int copy_sz=0)
adds a pointer to the data in the container
Definition: Context.h:609
LightSmartPtr< ContextTemplate >::tPtr Ptr
Alias for the type of a smart pointer to ContextTemplate.
Definition: ContextTemplate.h:47
std::string getString() const
returns a std::string value from the container
Definition: Context.h:498
void setBool(bool val)
adds a value of type bool to the container
Definition: Context.h:594
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:67
bool isArray() const
checks whether the container is an array
Definition: Context.h:658
int height
Image height.
Definition: RawImage.h:117
const unsigned char * data
Pointer to the image data buffer. All pixels must be stored continuously, row by row, without gaps at the end of each row.
Definition: RawImage.h:118
Format
Format of image data.
Definition: IRawImage.h:46
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:113
int width
Image width.
Definition: RawImage.h:116
Ref operator[](const std::string &key)
indexing by key.
Definition: Context.h:975