Pre-resize fillparent

This commit is contained in:
2018-08-13 22:22:10 -04:00
parent 58fa6f0503
commit 353dc21750
95 changed files with 478 additions and 437 deletions
@@ -4,9 +4,9 @@
#include <stdlib.h> /* strtol */
#ifdef _MSC_VER
// disable _s warnings
/// disable _s warnings
# define _CRT_SECURE_NO_WARNINGS
// disable pragma warnings
/// disable pragma warnings
# pragma warning( disable : 4068 )
# pragma warning( disable : 4996 )
# include "MSUNIX/msunix.hpp"
@@ -86,7 +86,7 @@ size_t cString::size() const
return m_len;
}
// string format
/// string format
cString& cString::format(const char* format, ...)
{
char * buffer;
@@ -100,7 +100,7 @@ cString& cString::format(const char* format, ...)
return *this;
}
// trim leading and trailing spaces
/// trim leading and trailing spaces
cString& cString::trim()
{
const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a";
@@ -164,7 +164,7 @@ const char& cString::last_char() const
return mp_str[length() - 1];
}
// non-destructive split
/// non-destructive split
const std::vector<cString> cString::split(const char match) const
{
const char match_s[2] = { match, 0 };
@@ -185,14 +185,14 @@ const std::vector<cString> cString::split(const char* match, int max_split) cons
if (match_len >= __cString__MAX_LEN)
return rtn;
char* mi; // match index
char* pstr = mp_str; // string pointer
char* mi; /// match index
char* pstr = mp_str; /// string pointer
while ((mi = strstr(pstr, match)) && (max_split < 0 || --max_split)) {
if (mi != pstr) {
size_t lhsz = mi - pstr;
char* cslhs = (char *)malloc(lhsz + 1);
cslhs[lhsz] = '\0'; // strncpy doesn't terminate it
rtn.emplace_back(strncpy(cslhs, pstr, lhsz)); // calls cString copy ctor
cslhs[lhsz] = '\0'; /// strncpy doesn't terminate it
rtn.emplace_back(strncpy(cslhs, pstr, lhsz)); /// calls cString copy ctor
pstr += lhsz;
free(cslhs);
}
@@ -22,17 +22,17 @@ namespace UtilityEngine {
class EXPORT_FROM_MYDLL cString
{
public:
cString(); // default constructor
cString(); /// default constructor
cString(const char* s);
cString(const cString& copy); // copy constructor
cString(const cString& copy); /// copy constructor
~cString();
const char* alloc_str(size_t sz); /// smart alloc string
void clear(); /// frees the string
const char* c_str() const; /// getter
const char* copy_str(const char* copy); /// alloc & copy
const char* alloc_str(size_t sz); // smart alloc string
void clear(); // frees the string
const char* c_str() const; // getter
const char* copy_str(const char* copy); // alloc & copy
// utility methods
/// utility methods
bool have_value() const;
size_t length() const;
size_t size() const;
@@ -54,14 +54,14 @@ namespace UtilityEngine {
const bool IsInt() const;
const long int ToInt() const;
// operators
cString& operator = (const char* rhs); // assignment operator
cString& operator = (const cString& rhs); // assignment operator
/// operators
cString& operator = (const char* rhs); /// assignment operator
cString& operator = (const cString& rhs); /// assignment operator
cString& operator += (const char rhs);
cString& operator += (const char* rhs); // concatenation operator
cString& operator += (const cString& rhs); // concatenation operator
cString& operator += (const char* rhs); /// concatenation operator
cString& operator += (const cString& rhs); /// concatenation operator
bool operator == (const char* rhs) const; // comparisons
bool operator == (const char* rhs) const; /// comparisons
bool operator == (const cString& rhs) const;
bool operator != (const char* rhs) const;
bool operator != (const cString& rhs) const;
@@ -70,16 +70,16 @@ namespace UtilityEngine {
bool operator >= (const cString& rhs) const;
bool operator <= (const cString& rhs) const;
// conversion operators
operator const char* () const; // c-string type
operator std::string () const; // c++ string class
/// conversion operators
operator const char* () const; /// c-string type
operator std::string () const; /// c++ string class
private:
char* mp_str = nullptr;
size_t m_len = 0;
};/// END CLASS DEFINITION cString
// function overloads
}/// END NAMESPACE DEFINITION UtilityEngine
/// function overloads
UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs);
#endif/// END IFNDEF _CSTRING_HPP_
@@ -11,14 +11,14 @@ using UtilityEngine::cUtility;
/*static*/ cUtility* cUtility::sp_inst = nullptr;
//private:
/// private:
cUtility::cUtility()
{}
cUtility::~cUtility()
{}
//public:
/// public:
// cUtility& cUtility::operator=( const cUtility& copy )
// {
// if (this != &copy)
@@ -28,7 +28,7 @@ cUtility::~cUtility()
// return *this;
// }
///Functions
/// Functions
/*static*/ cUtility& cUtility::Inst()
{
if (sp_inst == nullptr)
@@ -124,8 +124,8 @@ void cUtility::PrintVersion( const eTypeSDL typeSDL /*= eTypeSDL::ALL*/ ) const
}
}
///Private:
///Functions
/// private:
/// Functions
void cUtility::VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const
{
fprintf(stderr, "%s with %s version: %u.%u.%u \n", runCompiled.c_str(), type.c_str(), version.major, version.minor, version.patch);
@@ -2,7 +2,7 @@
#define _CUTILITY_HPP_
/*** ANSI C Header Files ***/
#include <stdio.h> //for __FUNCTION__
#include <stdio.h> /// for __FUNCTION__
#ifndef __FUNCTION__
# define __FUNCTION__ __func__
@@ -42,7 +42,7 @@ namespace UtilityEngine {
~cUtility();
public:
///Functions
/// Functions
static cUtility& Inst();
static void Delete();
@@ -51,12 +51,12 @@ namespace UtilityEngine {
void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const;
private:
///Functions
/// Functions
void VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const;
private:
///Variables
static cUtility* sp_inst;// = nullptr
/// Variables
static cUtility* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cUtility
}/// END NAMESPACE DEFINITION UtilityEngine
#endif/// END IFNDEF _CUTILITY_HPP_