Data Structures | Macros | Functions
Error handling and debug helpers

Utility methods to works with errors or exceptional situations. More...

Data Structures

struct  InferenceEngine::DescriptionBuffer
 A description buffer wrapping StatusCode and ResponseDesc. More...
 

Macros

#define TO_STATUS(x)
 Converts C++ exceptioned function call into a c-style one. More...
 
#define TO_STATUS_NO_RESP(x)
 Converts C++ exceptioned function call into a status code. Does not work with a ResponseDesc object. More...
 
#define NO_EXCEPT_CALL_RETURN_STATUS(x)
 Returns a status code of a called function, handles exeptions and converts to a status code. More...
 
#define PARAMETER_MISMATCH_str   std::string("[PARAMETER_MISMATCH] ")
 Defines the parameter mismatch message.
 
#define NETWORK_NOT_LOADED_str   std::string("[NETWORK_NOT_LOADED] ")
 Defines the network not loaded message.
 
#define NETWORK_NOT_READ_str   std::string("[NETWORK_NOT_READ] ")
 Defines the network not read message.
 
#define NOT_FOUND_str   std::string("[NOT_FOUND] ")
 Defines the not found message.
 
#define UNEXPECTED_str   std::string("[UNEXPECTED] ")
 Defines the unexpected message.
 
#define GENERAL_ERROR_str   std::string("[GENERAL ERROR] ")
 Defines the general error message.
 
#define RESULT_NOT_READY_str   std::string("[RESULT_NOT_READY] ")
 Defines the result not ready message.
 
#define INFER_NOT_STARTED_str   std::string("[INFER_NOT_STARTED] ")
 Defines the infer not started message.
 
#define REQUEST_BUSY_str   std::string("[REQUEST_BUSY] ")
 Defines the request busy message.
 
#define NOT_IMPLEMENTED_str   std::string("[NOT_IMPLEMENTED] ")
 Defines the not implemented message.
 
#define NOT_ALLOCATED_str   std::string("[NOT_ALLOCATED] ")
 Defines the not allocated message.
 
#define INFER_CANCELLED_str   std::string("[INFER_CANCELLED] ")
 Defines the infer cancelled message.
 

Functions

template<typename T >
std::ostream & InferenceEngine::details::operator<< (std::ostream &out, const std::vector< T > &vec)
 Serializes a std::vector to a std::ostream More...
 
void InferenceEngine::details::ltrim (std::string &s)
 trim from start (in place) More...
 
void InferenceEngine::details::rtrim (std::string &s)
 trim from end (in place) More...
 
std::string & InferenceEngine::details::trim (std::string &s)
 Trims std::string from both ends (in place) More...
 
std::vector< std::string > InferenceEngine::details::split (const std::string &src, const std::string &delimiter)
 split string into a vector of substrings More...
 
template<typename T , typename A >
std::string InferenceEngine::details::joinVec (std::vector< T, A > const &vec, std::string const &glue=std::string(","))
 create a string representation for a vector of values, without any suffixes or prefixes More...
 
template<typename T , typename A >
std::string InferenceEngine::details::dumpVec (std::vector< T, A > const &vec)
 create a string representation for a vector of values, enclosing text in a square brackets More...
 
template<typename T , typename A >
InferenceEngine::details::product (std::vector< T, A > const &vec)
 multiply vector's values More...
 
template<typename T , typename A >
bool InferenceEngine::details::equal (const std::vector< T, A > &v1, const std::vector< T, A > &v2)
 check if vectors contain same values More...
 
bool InferenceEngine::details::equal (const std::string &lhs, const std::string &rhs, bool ignoreCase=true)
 Checks whether two std::strings are equal. More...
 
bool InferenceEngine::details::endsWith (const std::string &src, const char *with)
 check string end with given substring More...
 
std::string InferenceEngine::details::tolower (const std::string &s)
 Converts all upper-case letters in a std::string to lower case. More...
 

Detailed Description

Utility methods to works with errors or exceptional situations.

Macro Definition Documentation

◆ NO_EXCEPT_CALL_RETURN_STATUS

#define NO_EXCEPT_CALL_RETURN_STATUS (   x)
Value:
try { \
return x; \
} catch (const InferenceEngine::details::InferenceEngineException& iex) { \
return InferenceEngine::DescriptionBuffer(iex.hasStatus() ? iex.getStatus() : GENERAL_ERROR, resp) \
<< iex.what(); \
} catch (const std::exception& ex) { \
return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); \
} catch (...) { \
return InferenceEngine::DescriptionBuffer(UNEXPECTED); \
}
A description buffer wrapping StatusCode and ResponseDesc.
Definition: description_buffer.hpp:24

Returns a status code of a called function, handles exeptions and converts to a status code.

◆ TO_STATUS

#define TO_STATUS (   x)
Value:
try { \
x; \
return OK; \
} catch (const InferenceEngine::details::InferenceEngineException& iex) { \
return InferenceEngine::DescriptionBuffer((iex.hasStatus() ? iex.getStatus() : GENERAL_ERROR), resp) \
<< iex.what(); \
} catch (const std::exception& ex) { \
return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); \
} catch (...) { \
return InferenceEngine::DescriptionBuffer(UNEXPECTED); \
}

Converts C++ exceptioned function call into a c-style one.

◆ TO_STATUS_NO_RESP

#define TO_STATUS_NO_RESP (   x)
Value:
try { \
x; \
return OK; \
} catch (const InferenceEngine::details::InferenceEngineException& iex) { \
return InferenceEngine::DescriptionBuffer(iex.hasStatus() ? iex.getStatus() : GENERAL_ERROR) << iex.what(); \
} catch (const std::exception& ex) { \
return InferenceEngine::DescriptionBuffer(GENERAL_ERROR) << ex.what(); \
} catch (...) { \
return InferenceEngine::DescriptionBuffer(UNEXPECTED); \
}

Converts C++ exceptioned function call into a status code. Does not work with a ResponseDesc object.

Function Documentation

◆ dumpVec()

template<typename T , typename A >
std::string InferenceEngine::details::dumpVec ( std::vector< T, A > const &  vec)

create a string representation for a vector of values, enclosing text in a square brackets

Parameters
vec- vector of values
Returns
string representation

◆ endsWith()

bool InferenceEngine::details::endsWith ( const std::string &  src,
const char *  with 
)
inline

check string end with given substring

Parameters
src- string to check
with- given substring
Returns
true if string end with given substring

◆ equal() [1/2]

bool InferenceEngine::details::equal ( const std::string &  lhs,
const std::string &  rhs,
bool  ignoreCase = true 
)
inline

Checks whether two std::strings are equal.

Parameters
lhsA first std::string to compare
rhsA second std::string to compare
ignoreCaseWhether to ignore case-sensitivity, default is true
Returns
True in case of std::strings are equal, false otherwise

◆ equal() [2/2]

template<typename T , typename A >
bool InferenceEngine::details::equal ( const std::vector< T, A > &  v1,
const std::vector< T, A > &  v2 
)

check if vectors contain same values

Parameters
v1- first vector
v2- second vector
Returns
true if vectors contain same values

◆ joinVec()

template<typename T , typename A >
std::string InferenceEngine::details::joinVec ( std::vector< T, A > const &  vec,
std::string const &  glue = std::string(",") 
)

create a string representation for a vector of values, without any suffixes or prefixes

Parameters
vecVector of values
glueA separator
Returns
A string representation

◆ ltrim()

void InferenceEngine::details::ltrim ( std::string &  s)
inline

trim from start (in place)

Parameters
s- string to trim

◆ operator<<()

template<typename T >
std::ostream& InferenceEngine::details::operator<< ( std::ostream &  out,
const std::vector< T > &  vec 
)
inline

Serializes a std::vector to a std::ostream

Parameters
outAn output stream
vecA vector to serialize
Returns
A reference to a std::stream

◆ product()

template<typename T , typename A >
T InferenceEngine::details::product ( std::vector< T, A > const &  vec)

multiply vector's values

Parameters
vec- vector with values
Returns
result of multiplication

◆ rtrim()

void InferenceEngine::details::rtrim ( std::string &  s)
inline

trim from end (in place)

Parameters
s- string to trim

◆ split()

std::vector<std::string> InferenceEngine::details::split ( const std::string &  src,
const std::string &  delimiter 
)
inline

split string into a vector of substrings

Parameters
src- string to split
delimiter- string used as a delimiter
Returns
vector of substrings

◆ tolower()

std::string InferenceEngine::details::tolower ( const std::string &  s)
inline

Converts all upper-case letters in a std::string to lower case.

Parameters
sA std::tring to convert
Returns
An output std::string in lower case

◆ trim()

std::string& InferenceEngine::details::trim ( std::string &  s)
inline

Trims std::string from both ends (in place)

Parameters
sA reference to a std::tring to trim
Returns
A reference to a trimmed std::string