ONE - On-device Neural Engine
Loading...
Searching...
No Matches
pepper Namespace Reference

Namespaces

namespace  details
 

Data Structures

class  KVStoreInterface
 
class  KVStoreInterface< KVStoreTrait::Queryable >
 
struct  ProcessEnvironment
 

Enumerations

enum class  KVStoreTrait { Queryable }
 

Functions

template<typename T >
std::vector< T > csv_to_vector (const std::string &str)
 
template<typename T >
bool is_one_of (const T &item, const std::vector< T > &items)
 
template<>
std::vector< std::string > csv_to_vector (const std::string &str)
 
template<>
std::vector< int32_t > csv_to_vector (const std::string &str)
 
template<>
bool is_one_of (const std::string &item, const std::vector< std::string > &items)
 
template<typename T >
safe_strcast (const char *s, const T &v)
 Cast a C-string as a value of type T.
 
template<>
int safe_strcast< int > (const char *s, const int &v)
 
template<>
int safe_strcast< int > (const char *s, const int &v)
 

Enumeration Type Documentation

◆ KVStoreTrait

enum class pepper::KVStoreTrait
strong
Enumerator
Queryable 

Definition at line 28 of file env.h.

29{
31};

Function Documentation

◆ csv_to_vector() [1/3]

template<typename T >
std::vector< T > pepper::csv_to_vector ( const std::string &  str)

◆ csv_to_vector() [2/3]

template<>
std::vector< std::string > pepper::csv_to_vector ( const std::string &  str)

Definition at line 26 of file pepper-csv2vec.cpp.

27{
28 std::vector<std::string> ret;
29 std::istringstream is(str);
30 for (std::string item; std::getline(is, item, ',');)
31 {
32 ret.push_back(item);
33 }
34 return ret;
35}

◆ csv_to_vector() [3/3]

template<>
std::vector< int32_t > pepper::csv_to_vector ( const std::string &  str)

Definition at line 39 of file pepper-csv2vec.cpp.

40{
41 std::vector<int32_t> ret;
42 std::istringstream is(str);
43 for (int32_t i; is >> i;)
44 {
45 assert(i != ',');
46 ret.push_back(i);
47 if (is.peek() == ',')
48 is.ignore();
49 }
50 return ret;
51}

◆ is_one_of() [1/2]

template<>
bool pepper::is_one_of ( const std::string &  item,
const std::vector< std::string > &  items 
)

Definition at line 53 of file pepper-csv2vec.cpp.

54{
55 return std::find(items.begin(), items.end(), item) != items.end();
56}

◆ is_one_of() [2/2]

template<typename T >
bool pepper::is_one_of ( const T &  item,
const std::vector< T > &  items 
)

◆ safe_strcast()

template<typename T >
T pepper::safe_strcast ( const char *  s,
const T &  v 
)

Cast a C-string as a value of type T.

safe_strcast(s, v) returns v if s is nullptr.

◆ safe_strcast< int >() [1/2]

template<>
int pepper::safe_strcast< int > ( const char *  s,
const int &  v 
)

Definition at line 24 of file strcast.cpp.

25{
26 return (s == nullptr) ? v : std::stoi(s);
27}

Referenced by hermes::EnvConfig< EnvFormat::BooleanNumber >::EnvConfig().

◆ safe_strcast< int >() [2/2]

template<>
int pepper::safe_strcast< int > ( const char *  s,
const int &  v 
)

Definition at line 24 of file strcast.cpp.

25{
26 return (s == nullptr) ? v : std::stoi(s);
27}

Referenced by hermes::EnvConfig< EnvFormat::BooleanNumber >::EnvConfig().