Wtx ~ Wt Extension Library
WtxLib
Namespaces | Classes | Typedefs | Functions | Variables
Wtx Namespace Reference

witty extension library More...

Namespaces

 Core
 functions and features
 
 Crm
 Contact Relationships Management.
 
 Dbo
 database access objects
 
 Eml
 Email Management.
 
 Lib
 library functions and resources
 
 Sys
 System Namespace.
 

Classes

struct  CharConv
 
class  ClientFolder
 Client Folder. More...
 
class  FormModel
 
class  MessageBox
 
class  PopupMessage
 
class  PopupQuestion
 
class  PopupYesNo
 
class  TableView
 Table View. More...
 
class  TableViewDef
 Table View Definition. More...
 
class  Template
 
class  TemplateFormView
 Template Form View. More...
 

Typedefs

typedef struct Wtx::CharConv CharConv_t
 

Functions

std::string json_number_to_string (const std::string &key, const std::string &data)
 Convert a number to a string. More...
 
std::string makeFileName (const std::string &value)
 Make File Name. More...
 
bool fileExists (const std::string &fileName)
 Check if a File or Folder exists.
 
int system_command (const std::string &cmd, bool show=false)
 Execute a system command. More...
 
std::vector< std::string > fileList (const std::string &folder)
 File Listing. More...
 
std::vector< std::string > findFiles (const std::string &folder, const std::string &match)
 Find File. More...
 
int stoi (const std::string &value)
 Convert a String to an Integer.
 
std::string itos (int value)
 Convert an Integer to a String.
 
double stof (const std::string &value)
 Convert a String to Float.
 
std::string ftos (double value, int decimals=2)
 Convert a Float to String with decimal precision.
 
std::string ftos (double value, const std::string &suffix, int decimals=2)
 
std::string ftos (const std::string &prefix, double value, int decimals=2)
 
std::string ftom (double value, int decimals=2)
 
std::string ftom (const std::string &prefix, double value, int decimals=2)
 
bool ends_with (const std::string &value, const std::string &ending)
 Check if a string ends with another string.
 
std::string append (const std::string &s, const std::string &append, const std::string &separator)
 Append a string to string. More...
 
std::string prepend (const std::string &s, int length=0, char pad= '0')
 Prepend some number of characters in front of another string. More...
 
std::string ucase (const std::string &value)
 Upper Case a string. More...
 
std::string lcase (const std::string &value)
 Lower Case a string. More...
 
int roundUp (float value)
 Round a number up. More...
 
int roundDown (float value)
 Round a number down. More...
 
float roundCurrency (float value)
 Round a number for Currency. More...
 
std::string replace (const std::string &string, const std::string &before, const std::string &after)
 Replace a String. More...
 
void ltrim (std::string &s)
 
void rtrim (std::string &s)
 
void trim (std::string &s)
 
std::string ltrim_copy (std::string s)
 
std::string rtrim_copy (std::string s)
 
std::string trim_copy (std::string s)
 
std::vector< std::string > readCSVRow (const std::string &row)
 
bool feq (double a, double b, double epsilon=0.005f, bool trace=false)
 
std::string to_string (Wt::WTemplate &templt)
 
std::string to_string (Wt::WTemplate *templt)
 
bool to_htmlfile (Wt::WTemplate &templt, const std::string &folderName, const std::string &fileName)
 
bool to_htmlfile (Wt::WTemplate *templt, const std::string &folderName, const std::string &fileName)
 
std::string hexDump (const std::string &data, int start=-1, int end=-1)
 
void mapClasses (::Wtx::Dbo::Session &session)
 
void postCreateTables (::Wtx::Dbo::Session &session)
 
bool forceUppercase ()
 
void setForceUppercase (bool value=true)
 

Variables

Wt::WLength g_dialogWidth
 Default Dialog Width. More...
 
Wt::WLength g_dialogHeight
 Default Dialog Height. More...
 
const CharConv_t g_iso8859Conv [256]
 
bool g_forceUppercase = false
 

Detailed Description

witty extension library

Function Documentation

std::string Wtx::append ( const std::string &  s,
const std::string &  append,
const std::string &  separator 
)

Append a string to string.

This will append a string to another string and place a separator if there is already data in the lead string

Definition at line 404 of file Util.cpp.

bool Wtx::feq ( double  a,
double  b,
double  epsilon = 0.005f,
bool  trace = false 
)

This compares two floating point numbers if they are equal

Definition at line 710 of file Util.cpp.

std::vector< std::string > Wtx::fileList ( const std::string &  folder)

File Listing.

This procedure will scan a folder and return a list of all the files in it.

Definition at line 201 of file Util.cpp.

std::vector< std::string > Wtx::findFiles ( const std::string &  folder,
const std::string &  match 
)

Find File.

This scans a directory folder and returns a list containing the full file-name of all the files that matche the value.

Definition at line 278 of file Util.cpp.

std::string Wtx::json_number_to_string ( const std::string &  key,
const std::string &  data 
)

Convert a number to a string.

Sometimes it happens that a json string will contain 'Number' type values where the numbers are too large for the json processor. In these cases, it is necessary to convert the Number type value to a String type value. This function will take care of that conversion.

This will result in a json string that appears as follows, where the 'webinarKey' value is an integer that will not parse properly:

{
"webinarKey": 7299805419096618000,
"times": [
{
"startTime": "2018-01-17T01:00:00Z",
"endTime": "2018-01-17T03:00:00Z"
}
],
"webinarID": "967403427",
"subject": "Mark, Mike and Mitch Present...",
"description": "Join me, Mark, to learn how you can...",
"timeZone": "America/New_York",
"organizerKey": 1234567
},

in to a 'webinarKey' value that is a 'string type' and can therefore be easily processed:

{
"webinarKey": "7299805419096618000",
"times": [
{
See also
https://regex101.com
http://en.cppreference.com/w/cpp/regex/ecmascript
https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WRegExpValidator.html

using a regex, find the 'key' value which is followed by a ':' colon. This is the first (capture). The second (capture) is a space followed by at least 8 numbers, possibly more. The (replace) function then takes the first capture, and follows that with the second capture, but places " (double quote) characters around the second capture, thus turning the value in to a String type.

Refer to the cpp source file for an explanation of the regex string.

Definition at line 17 of file Util.cpp.

std::string Wtx::lcase ( const std::string &  value)

Lower Case a string.

this procedure converts a string to all lower case

Definition at line 448 of file Util.cpp.

std::string Wtx::makeFileName ( const std::string &  value)

Make File Name.

This will take an odrinary string and remove anything that is not acceptable in a valid file-name. The intended use for this function is to take something like a person's name or a company name and remove and replace anything in those strings that might not produce a disk-compatible file-name. This includes things like ':' colons and '/' forward and back slashes and anything else that looks just plain weird.

All non-printable characters are simply discarded

The routine performs simple character-by-character substitution. In some cases the substitution is 'nothing', like in the case of '.' (period) and ',' (comma) other characters are simply replaced with suitable replacements that have similar appearance but are not likely to mess up a file-name on disk. Odd punctuation characters are removed since this function is a string-to-filename conversion, therefore absolute punctuation has less meaning in a file-name than it does in the database.

Examples
std::cout << makeFileName("LORIMARK SOLUTIONS, LLC.") << std::endl;
std::cout << makeFileName("Bridge On The River Kwai") << std::endl;
std::cout << makeFileName("He said \"no\", She said \"yes\"") << std::endl;
std::cout << makeFileName("Chicago <south> Storage_Facility") << std::endl;
std::cout << makeFileName("Boat (float) :/: or Ship Sink") << std::endl;
result:
LORIMARK SOLUTIONS LLC
Bridge On The River Kwai
He said 'no' She said 'yes'
Chicago (south) Storage_Facility
Boat (float) -- or Ship Sink

'.' period -> nothing

',' comma -> nothing

'<' less than -> open paren

'>' greater than -> close paren

':' colon -> dash ~ sometimes works, but is actually NTFS Alternate Data Streams

'"' double quote -> single quote

'/' forward slash -> dash

'\'backslash -> dash

'|' vertical bar or pipe -> nothing

'?' question mark -> nothing

'*' asterisk -> nothing

Definition at line 85 of file Util.cpp.

std::string Wtx::prepend ( const std::string &  s,
int  length = 0,
char  pad = '0' 
)

Prepend some number of characters in front of another string.

This procedure is often used to zero-pad a number, such that numbers like 23 and 2005 and 10553 will always appear as 00023 and 02005 and 10553 respectively.

Definition at line 431 of file Util.cpp.

std::string Wtx::replace ( const std::string &  string,
const std::string &  before,
const std::string &  after 
)

Replace a String.

This will replace all occurrences of a substring within another string with some other string;

Definition at line 480 of file Util.cpp.

float Wtx::roundCurrency ( float  value)

Round a number for Currency.

This will round a number up or down depending on the value of the currency. 1.3999999 becomes 1.4

Definition at line 469 of file Util.cpp.

int Wtx::roundDown ( float  value)

Round a number down.

This will round a number down

Definition at line 464 of file Util.cpp.

int Wtx::roundUp ( float  value)

Round a number up.

This will round a number up

Definition at line 455 of file Util.cpp.

int Wtx::system_command ( const std::string &  cmd,
bool  show = false 
)

Execute a system command.

This runs a command in the console and returns the result code.

Definition at line 153 of file Util.cpp.

std::string Wtx::ucase ( const std::string &  value)

Upper Case a string.

this procedure converts a string to all upper case

Definition at line 441 of file Util.cpp.

Variable Documentation

Wt::WLength Wtx::g_dialogHeight

Default Dialog Height.

Static-global default dialog height value. This can be set by the start-up application to control the size of the dialog windows.

Definition at line 59 of file TableViewDef.h.

Wt::WLength Wtx::g_dialogWidth

Default Dialog Width.

Static-global default dialog width value. This can be set by the start-up application to control the size of the dialog windows.

Definition at line 58 of file TableViewDef.h.