1 #line 2 "src/Glb/Core.cpp"
6 #include <Wt/WModelIndex.h>
7 #include <Wt/WDateTime.h>
8 #include <Wt/WLocalDateTime.h>
10 #include "../3rd/guid.hpp"
15 std::vector<std::string> &
16 split(
const std::string & s,
char delim, std::vector<std::string> & elems )
18 std::stringstream ss( s );
20 while( std::getline( ss, item, delim ) )
22 elems.push_back( item );
28 std::vector<std::string>
30 split(
const std::string & s,
char delim )
32 std::vector<std::string> elems;
42 rtrim( std::string & s,
const char* t )
44 s.erase( s.find_last_not_of(t) + 1 );
51 ltrim( std::string & s,
const char* t )
53 s.erase( 0, s.find_first_not_of(t) );
60 trim( std::string & s,
const char* t )
67 toupper(
const std::string & s )
69 std::string retVal = s;
71 std::transform( retVal.begin(), retVal.end(), retVal.begin(), ::
toupper );
78 tolower(
const std::string & s )
80 std::string retVal = s;
82 std::transform( retVal.begin(), retVal.end(), retVal.begin(), ::
tolower );
95 iterate( Wt::Json::Array & _jary, Wt::WModelIndex _parent )
102 if( !view()-> isExpanded( _parent ) )
110 bool expanded =
false;
111 for(
int row=0; row< view()-> model()-> rowCount( _parent ); row++ )
112 expanded |=
iterate( _jary, view()-> model()-> index( row, 0, _parent ) );
128 auto accountGuid =
Wt::asString( _parent.data( Wt::ItemDataRole::User ) );
129 if( accountGuid !=
"" )
130 _jary.push_back( accountGuid );
148 toJson( Wt::WTreeView * _view )
150 Wt::Json::Object jobj;
153 jobj[
"selected"] = Wt::WString( selectedAccount() );
155 for(
int col=0; col< 7; col++ )
156 jobj[ Wt::WString(
"cw{1}").arg( col ).toUTF8() ] = Wt::WString( view()-> columnWidth( col ).cssText() );
158 Wt::Json::Array jary;
160 jobj[
"expanded"] = jary;
170 hexDump(
const std::string &
string,
int start,
int end )-> std::string
172 std::stringstream rv;
175 for(
unsigned int i=0; i<
string.length(); i += 16 )
181 sprintf( buffer,
"%04x: ", i );
182 adrLine = std::string(buffer);
184 for(
int j=0; j<16; j++ )
186 if( i+j <
string.length() )
188 sprintf( buffer,
"%02x ", (
string.at(i+j) & 0xff) );
189 hexLine += std::string(buffer);
191 if( std::isprint(
string.at(i+j) ) )
193 sprintf( buffer,
"%c",
string.at(i+j) );
194 ascLine += std::string(buffer);
209 bool showline =
false;
210 if( start == -1 && end == -1 )
214 if( (start > -1 && i >= start)
215 && (end > -1 && i <= end)
242 retVal.push_back( c );
static std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
static bool iterate(Wt::Json::Array &_jary, Wt::WModelIndex _parent)
#define GCW_DATE_FORMAT_STORAGE
std::string toupper(const std::string &s)
auto currentDateTime() -> Wt::WDateTime
Current Date/Time.
std::string tolower(const std::string &s)
std::vector< std::string > split(const std::string &value, char delim)
std::string & trim(std::string &s, const char *t=trim_ws)
std::string & ltrim(std::string &s, const char *t=trim_ws)
std::string hexDump(const std::string &data, int start=-1, int end=-1)
std::string & rtrim(std::string &s, const char *t=trim_ws)
Wt::Json::Object toJson(Wt::WTreeView *_view)
auto newGuid() -> std::string
Generate new GUID string value.
auto currentDateTimeStorageString() -> std::string
std::string asString(Status _status)
Get Status as String.