summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx/safe_strings.hh
blob: 61f7f9b58f9a94ee1e428a27c9504d6656b78424 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

#ifndef EOLIAN_CXX_BIN_SAFE_STRINGS_HH
#define EOLIAN_CXX_BIN_SAFE_STRINGS_HH

#include <string>

extern "C"
{
#include <Eina.h>
}

/// @brief Safely convert an const char* to std::string.
inline std::string
safe_str(const char* str)
{
   return (str != NULL) ? str : "";
}

/// @brief Safely convert an Eina_Stringshare to std::string.
inline std::string
safe_strshare(Eina_Stringshare* strsh)
{
   std::string ret = strsh != NULL ? strsh : "";
   eina_stringshare_del(strsh);
   return ret;
}

#endif // EOLIAN_CXX_BIN_SAFE_STRINGS_HH