Begin converting URL struct into modern C++ class
This commit is contained in:
17
dlib/dlib.cc
17
dlib/dlib.cc
@ -538,6 +538,23 @@ const char *dStr_printable(Dstr *in, int maxlen)
|
||||
return out->str;
|
||||
}
|
||||
|
||||
extern "C++"
|
||||
{
|
||||
#include <Alepha/AutoRAII.h>
|
||||
}
|
||||
|
||||
std::string
|
||||
dStr_printable_std(const std::string &in, const int maxlen)
|
||||
{
|
||||
const auto wrapped= Alepha::AutoRAII
|
||||
{
|
||||
[&]{ return dStr_new( in.c_str() ); },
|
||||
[]( auto d ) { dStr_free( d, true ); }
|
||||
};
|
||||
|
||||
return dStr_printable( wrapped, maxlen );
|
||||
}
|
||||
|
||||
/*
|
||||
*- dList ---------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -124,6 +124,13 @@ void dStr_sprintfa (Dstr *ds, const char *format, ...);
|
||||
int dStr_cmp(Dstr *ds1, Dstr *ds2);
|
||||
char *dStr_memmem(Dstr *haystack, Dstr *needle);
|
||||
const char *dStr_printable(Dstr *in, int maxlen);
|
||||
#ifdef __cplusplus
|
||||
extern "C++"
|
||||
{
|
||||
#include <string>
|
||||
}
|
||||
std::string dStr_printable_std(const std::string &in, int maxlen);
|
||||
#endif
|
||||
|
||||
/*
|
||||
*-- dList --------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user