Browse Source

utils.cc - add to_cxx() for idenitylist, is_c_str_empty()

LIB-11
heck 4 years ago
parent
commit
8ac42950d5
  1. 22
      src/utils.cc
  2. 7
      src/utils.hh

22
src/utils.cc

@ -17,6 +17,28 @@ using namespace pEp;
namespace pEp {
namespace Utils {
std::vector<::pEp_identity *> to_cxx(const ::identity_list &idl)
{
vector<pEp_identity *> ret{};
for (const ::identity_list *curr = &idl; curr != nullptr; curr = curr->next) {
if(curr->ident) {
ret.push_back(curr->ident);
}
}
return ret;
}
bool is_c_str_empty(const char *str)
{
if (str == nullptr) {
return true;
}
string tmp{ str };
if (tmp.empty()) {
return true;
}
return false;
}
string to_string(const ::pEp_identity *const ident, bool full, int indent)
{

7
src/utils.hh

@ -10,9 +10,16 @@
#include <pEp/identity_list.h>
#include <pEp/group.h>
#include <exception>
#include <vector>
namespace pEp {
namespace Utils {
// C-types to C++ types
std::vector<::pEp_identity *> to_cxx(const ::identity_list &idl);
// C-types helpers
bool is_c_str_empty(const char *str);
// pEpEngine datatypes to string
std::string to_string(const ::pEp_identity *const ident, bool full = true, int indent = 0);
std::string to_string(const ::identity_list *const idl, bool full = true, int indent = 0);

Loading…
Cancel
Save