NE Alpha 38

This commit is contained in:
Cr4sh 2017-01-14 03:24:56 +03:00
parent f410b0f969
commit 0e09dfe1b2
24 changed files with 8383 additions and 45 deletions

28
common/bstrlib/LICENSE Normal file
View file

@ -0,0 +1,28 @@
Copyright (c) 2014, Paul Hsieh
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of bstrlib nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

3137
common/bstrlib/bstrlib.c Normal file

File diff suppressed because it is too large Load diff

321
common/bstrlib/bstrlib.h Normal file
View file

@ -0,0 +1,321 @@
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license and the GPL. Refer to the accompanying documentation for details
* on usage and license.
*/
/*
* bstrlib.h
*
* This file is the interface for the core bstring functions.
*/
#ifndef BSTRLIB_INCLUDE
#define BSTRLIB_INCLUDE
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#if !defined (BSTRLIB_VSNP_OK) && !defined (BSTRLIB_NOVSNP)
# if defined (__TURBOC__) && !defined (__BORLANDC__)
# define BSTRLIB_NOVSNP
# endif
#endif
#define BSTR_ERR (-1)
#define BSTR_OK (0)
#define BSTR_BS_BUFF_LENGTH_GET (0)
typedef struct tagbstring * bstring;
typedef const struct tagbstring * const_bstring;
/* Version */
#define BSTR_VER_MAJOR 1
#define BSTR_VER_MINOR 0
#define BSTR_VER_UPDATE 0
/* Copy functions */
#define cstr2bstr bfromcstr
extern bstring bfromcstr (const char * str);
extern bstring bfromcstralloc (int mlen, const char * str);
extern bstring bfromcstrrangealloc (int minl, int maxl, const char* str);
extern bstring blk2bstr (const void * blk, int len);
extern char * bstr2cstr (const_bstring s, char z);
extern int bcstrfree (char * s);
extern bstring bstrcpy (const_bstring b1);
extern int bassign (bstring a, const_bstring b);
extern int bassignmidstr (bstring a, const_bstring b, int left, int len);
extern int bassigncstr (bstring a, const char * str);
extern int bassignblk (bstring a, const void * s, int len);
/* Destroy function */
extern int bdestroy (bstring b);
/* Space allocation hinting functions */
extern int balloc (bstring s, int len);
extern int ballocmin (bstring b, int len);
/* Substring extraction */
extern bstring bmidstr (const_bstring b, int left, int len);
/* Various standard manipulations */
extern int bconcat (bstring b0, const_bstring b1);
extern int bconchar (bstring b0, char c);
extern int bcatcstr (bstring b, const char * s);
extern int bcatblk (bstring b, const void * s, int len);
extern int binsert (bstring s1, int pos, const_bstring s2, unsigned char fill);
extern int binsertblk (bstring s1, int pos, const void * s2, int len, unsigned char fill);
extern int binsertch (bstring s1, int pos, int len, unsigned char fill);
extern int breplace (bstring b1, int pos, int len, const_bstring b2, unsigned char fill);
extern int bdelete (bstring s1, int pos, int len);
extern int bsetstr (bstring b0, int pos, const_bstring b1, unsigned char fill);
extern int btrunc (bstring b, int n);
/* Scan/search functions */
extern int bstricmp (const_bstring b0, const_bstring b1);
extern int bstrnicmp (const_bstring b0, const_bstring b1, int n);
extern int biseqcaseless (const_bstring b0, const_bstring b1);
extern int biseqcaselessblk (const_bstring b, const void * blk, int len);
extern int bisstemeqcaselessblk (const_bstring b0, const void * blk, int len);
extern int biseq (const_bstring b0, const_bstring b1);
extern int biseqblk (const_bstring b, const void * blk, int len);
extern int bisstemeqblk (const_bstring b0, const void * blk, int len);
extern int biseqcstr (const_bstring b, const char * s);
extern int biseqcstrcaseless (const_bstring b, const char * s);
extern int bstrcmp (const_bstring b0, const_bstring b1);
extern int bstrncmp (const_bstring b0, const_bstring b1, int n);
extern int binstr (const_bstring s1, int pos, const_bstring s2);
extern int binstrr (const_bstring s1, int pos, const_bstring s2);
extern int binstrcaseless (const_bstring s1, int pos, const_bstring s2);
extern int binstrrcaseless (const_bstring s1, int pos, const_bstring s2);
extern int bstrchrp (const_bstring b, int c, int pos);
extern int bstrrchrp (const_bstring b, int c, int pos);
#define bstrchr(b,c) bstrchrp ((b), (c), 0)
#define bstrrchr(b,c) bstrrchrp ((b), (c), blength(b)-1)
extern int binchr (const_bstring b0, int pos, const_bstring b1);
extern int binchrr (const_bstring b0, int pos, const_bstring b1);
extern int bninchr (const_bstring b0, int pos, const_bstring b1);
extern int bninchrr (const_bstring b0, int pos, const_bstring b1);
extern int bfindreplace (bstring b, const_bstring find, const_bstring repl, int pos);
extern int bfindreplacecaseless (bstring b, const_bstring find, const_bstring repl, int pos);
/* List of string container functions */
struct bstrList {
int qty, mlen;
bstring * entry;
};
extern struct bstrList * bstrListCreate (void);
extern int bstrListDestroy (struct bstrList * sl);
extern int bstrListAlloc (struct bstrList * sl, int msz);
extern int bstrListAllocMin (struct bstrList * sl, int msz);
/* String split and join functions */
extern struct bstrList * bsplit (const_bstring str, unsigned char splitChar);
extern struct bstrList * bsplits (const_bstring str, const_bstring splitStr);
extern struct bstrList * bsplitstr (const_bstring str, const_bstring splitStr);
extern bstring bjoin (const struct bstrList * bl, const_bstring sep);
extern bstring bjoinblk (const struct bstrList * bl, const void * s, int len);
extern int bsplitcb (const_bstring str, unsigned char splitChar, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
extern int bsplitscb (const_bstring str, const_bstring splitStr, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
extern int bsplitstrcb (const_bstring str, const_bstring splitStr, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
/* Miscellaneous functions */
extern int bpattern (bstring b, int len);
extern int btoupper (bstring b);
extern int btolower (bstring b);
extern int bltrimws (bstring b);
extern int brtrimws (bstring b);
extern int btrimws (bstring b);
#if !defined (BSTRLIB_NOVSNP)
extern bstring bformat (const char * fmt, ...);
extern int bformata (bstring b, const char * fmt, ...);
extern int bassignformat (bstring b, const char * fmt, ...);
extern int bvcformata (bstring b, int count, const char * fmt, va_list arglist);
#define bvformata(ret, b, fmt, lastarg) { \
bstring bstrtmp_b = (b); \
const char * bstrtmp_fmt = (fmt); \
int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
for (;;) { \
va_list bstrtmp_arglist; \
va_start (bstrtmp_arglist, lastarg); \
bstrtmp_r = bvcformata (bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, bstrtmp_arglist); \
va_end (bstrtmp_arglist); \
if (bstrtmp_r >= 0) { /* Everything went ok */ \
bstrtmp_r = BSTR_OK; \
break; \
} else if (-bstrtmp_r <= bstrtmp_sz) { /* A real error? */ \
bstrtmp_r = BSTR_ERR; \
break; \
} \
bstrtmp_sz = -bstrtmp_r; /* Doubled or target size */ \
} \
ret = bstrtmp_r; \
}
#endif
typedef int (*bNgetc) (void *parm);
typedef size_t (* bNread) (void *buff, size_t elsize, size_t nelem, void *parm);
/* Input functions */
extern bstring bgets (bNgetc getcPtr, void * parm, char terminator);
extern bstring bread (bNread readPtr, void * parm);
extern int bgetsa (bstring b, bNgetc getcPtr, void * parm, char terminator);
extern int bassigngets (bstring b, bNgetc getcPtr, void * parm, char terminator);
extern int breada (bstring b, bNread readPtr, void * parm);
/* Stream functions */
extern struct bStream * bsopen (bNread readPtr, void * parm);
extern void * bsclose (struct bStream * s);
extern int bsbufflength (struct bStream * s, int sz);
extern int bsreadln (bstring b, struct bStream * s, char terminator);
extern int bsreadlns (bstring r, struct bStream * s, const_bstring term);
extern int bsread (bstring b, struct bStream * s, int n);
extern int bsreadlna (bstring b, struct bStream * s, char terminator);
extern int bsreadlnsa (bstring r, struct bStream * s, const_bstring term);
extern int bsreada (bstring b, struct bStream * s, int n);
extern int bsunread (struct bStream * s, const_bstring b);
extern int bspeek (bstring r, const struct bStream * s);
extern int bssplitscb (struct bStream * s, const_bstring splitStr,
int (* cb) (void * parm, int ofs, const_bstring entry), void * parm);
extern int bssplitstrcb (struct bStream * s, const_bstring splitStr,
int (* cb) (void * parm, int ofs, const_bstring entry), void * parm);
extern int bseof (const struct bStream * s);
struct tagbstring {
int mlen;
int slen;
unsigned char * data;
};
/* Accessor macros */
#define blengthe(b, e) (((b) == (void *)0 || (b)->slen < 0) ? (int)(e) : ((b)->slen))
#define blength(b) (blengthe ((b), 0))
#define bdataofse(b, o, e) (((b) == (void *)0 || (b)->data == (void*)0) ? (char *)(e) : ((char *)(b)->data) + (o))
#define bdataofs(b, o) (bdataofse ((b), (o), (void *)0))
#define bdatae(b, e) (bdataofse (b, 0, e))
#define bdata(b) (bdataofs (b, 0))
#define bchare(b, p, e) ((((unsigned)(p)) < (unsigned)blength(b)) ? ((b)->data[(p)]) : (e))
#define bchar(b, p) bchare ((b), (p), '\0')
/* Static constant string initialization macro */
#define bsStaticMlen(q,m) {(m), (int) sizeof(q)-1, (unsigned char *) ("" q "")}
#if defined(_MSC_VER)
# define bsStatic(q) bsStaticMlen(q,-32)
#endif
#ifndef bsStatic
# define bsStatic(q) bsStaticMlen(q,-__LINE__)
#endif
/* Static constant block parameter pair */
#define bsStaticBlkParms(q) ((void *)("" q "")), ((int) sizeof(q)-1)
#define bcatStatic(b,s) ((bcatblk)((b), bsStaticBlkParms(s)))
#define bfromStatic(s) ((blk2bstr)(bsStaticBlkParms(s)))
#define bassignStatic(b,s) ((bassignblk)((b), bsStaticBlkParms(s)))
#define binsertStatic(b,p,s,f) ((binsertblk)((b), (p), bsStaticBlkParms(s), (f)))
#define bjoinStatic(b,s) ((bjoinblk)((b), bsStaticBlkParms(s)))
#define biseqStatic(b,s) ((biseqblk)((b), bsStaticBlkParms(s)))
#define bisstemeqStatic(b,s) ((bisstemeqblk)((b), bsStaticBlkParms(s)))
#define biseqcaselessStatic(b,s) ((biseqcaselessblk)((b), bsStaticBlkParms(s)))
#define bisstemeqcaselessStatic(b,s) ((bisstemeqcaselessblk)((b), bsStaticBlkParms(s)))
/* Reference building macros */
#define cstr2tbstr btfromcstr
#define btfromcstr(t,s) { \
(t).data = (unsigned char *) (s); \
(t).slen = ((t).data) ? ((int) (strlen) ((char *)(t).data)) : 0; \
(t).mlen = -1; \
}
#define blk2tbstr(t,s,l) { \
(t).data = (unsigned char *) (s); \
(t).slen = l; \
(t).mlen = -1; \
}
#define btfromblk(t,s,l) blk2tbstr(t,s,l)
#define bmid2tbstr(t,b,p,l) { \
const_bstring bstrtmp_s = (b); \
if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
int bstrtmp_left = (p); \
int bstrtmp_len = (l); \
if (bstrtmp_left < 0) { \
bstrtmp_len += bstrtmp_left; \
bstrtmp_left = 0; \
} \
if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) \
bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
if (bstrtmp_len <= 0) { \
(t).data = (unsigned char *)""; \
(t).slen = 0; \
} else { \
(t).data = bstrtmp_s->data + bstrtmp_left; \
(t).slen = bstrtmp_len; \
} \
} else { \
(t).data = (unsigned char *)""; \
(t).slen = 0; \
} \
(t).mlen = -__LINE__; \
}
#define btfromblkltrimws(t,s,l) { \
int bstrtmp_idx = 0, bstrtmp_len = (l); \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
} \
} \
(t).data = bstrtmp_s + bstrtmp_idx; \
(t).slen = bstrtmp_len - bstrtmp_idx; \
(t).mlen = -__LINE__; \
}
#define btfromblkrtrimws(t,s,l) { \
int bstrtmp_len = (l) - 1; \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_len >= 0; bstrtmp_len--) { \
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
} \
} \
(t).data = bstrtmp_s; \
(t).slen = bstrtmp_len + 1; \
(t).mlen = -__LINE__; \
}
#define btfromblktrimws(t,s,l) { \
int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
} \
for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
} \
} \
(t).data = bstrtmp_s + bstrtmp_idx; \
(t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
(t).mlen = -__LINE__; \
}
/* Write protection macros */
#define bwriteprotect(t) { if ((t).mlen >= 0) (t).mlen = -1; }
#define bwriteallow(t) { if ((t).mlen == -1) (t).mlen = (t).slen + ((t).slen == 0); }
#define biswriteprotected(t) ((t).mlen <= 0)
#ifdef __cplusplus
}
#endif
#endif

1721
common/bstrlib/bstrwrap.cpp Normal file

File diff suppressed because it is too large Load diff

449
common/bstrlib/bstrwrap.h Normal file
View file

@ -0,0 +1,449 @@
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license and the GPL. Refer to the accompanying documentation for details
* on usage and license.
*/
/*
* bstrwrap.h
*
* This file is the C++ wrapper for the bstring functions.
*/
#ifndef BSTRWRAP_INCLUDE
#define BSTRWRAP_INCLUDE
/////////////////// Configuration defines //////////////////////////////
// WATCOM C/C++ has broken STL and std::iostream support. If you have
// ported over STLport, then you can #define BSTRLIB_CAN_USE_STL to use
// the CBStringList class.
#if defined(__WATCOMC__)
# if !defined (BSTRLIB_CAN_USE_STL) && !defined (BSTRLIB_CANNOT_USE_STL)
# define BSTRLIB_CANNOT_USE_STL
# endif
# if !defined (BSTRLIB_CAN_USE_IOSTREAM) && !defined (BSTRLIB_CANNOT_USE_IOSTREAM)
# define BSTRLIB_CANNOT_USE_IOSTREAM
# endif
#endif
// By default it assumed that STL has been installed and works for your
// compiler. If this is not the case, then #define BSTRLIB_CANNOT_USE_STL
#if !defined (BSTRLIB_CANNOT_USE_STL) && !defined (BSTRLIB_CAN_USE_STL)
#define BSTRLIB_CAN_USE_STL
#endif
// By default it assumed that std::iostream works well with your compiler.
// If this is not the case, then #define BSTRLIB_CAN_USE_IOSTREAM
#if !defined (BSTRLIB_CANNOT_USE_IOSTREAM) && !defined (BSTRLIB_CAN_USE_IOSTREAM)
#define BSTRLIB_CAN_USE_IOSTREAM
#endif
// By default it is assumed that your compiler can deal with and has enabled
// exception handlling. If this is not the case then you will need to
// #define BSTRLIB_DOESNT_THROW_EXCEPTIONS
#if !defined (BSTRLIB_THROWS_EXCEPTIONS) && !defined (BSTRLIB_DOESNT_THROW_EXCEPTIONS)
#define BSTRLIB_THROWS_EXCEPTIONS
#endif
////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include "bstrlib.h"
#include "../ubytearray.h"
#ifdef __cplusplus
#if defined(BSTRLIB_CAN_USE_STL)
#if defined(__WATCOMC__)
#pragma warning 604 10
#pragma warning 595 10
#pragma warning 594 10
#pragma warning 549 10
#endif
#include <vector>
#include <string>
#if defined(__WATCOMC__)
#pragma warning 604 9
#pragma warning 595 9
#pragma warning 594 9
#endif
#endif
namespace Bstrlib {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
#if defined(BSTRLIB_CAN_USE_STL)
struct CBStringException : public std::exception {
private:
std::string msg;
public:
CBStringException (const std::string inmsg) : msg(inmsg) {}
virtual ~CBStringException () throw () {}
virtual const char *what () const throw () { return msg.c_str(); }
};
#else
struct CBStringException {
private:
char * msg;
int needToFree;
public:
CBStringException (const char * inmsg) : needToFree(0) {
if (inmsg) {
msg = (char *) malloc (1 + strlen (inmsg));
if (NULL == msg) msg = "Out of memory";
else {
strcpy (msg, inmsg);
needToFree = 1;
}
} else {
msg = "NULL exception message";
}
}
virtual ~CBStringException () throw () {
if (needToFree) {
free (msg);
needToFree = 0;
msg = NULL;
}
}
virtual const char *what () const throw () { return msg; }
};
#endif
#define bstringThrow(er) {\
CBStringException bstr__cppwrapper_exception ("CBString::" er "");\
throw bstr__cppwrapper_exception;\
}
#else
#define bstringThrow(er) {}
#endif
struct CBString;
#ifdef _MSC_VER
#pragma warning(disable:4512)
#endif
class CBCharWriteProtected {
friend struct CBString;
private:
const struct tagbstring& s;
unsigned int idx;
CBCharWriteProtected (const struct tagbstring& c, int i) : s(c), idx((unsigned int)i) {
if (idx >= (unsigned) s.slen) {
bstringThrow ("character index out of bounds");
}
}
public:
inline char operator = (char c) {
if (s.mlen <= 0) {
bstringThrow ("Write protection error");
} else {
#ifndef BSTRLIB_THROWS_EXCEPTIONS
if (idx >= (unsigned) s.slen) return '\0';
#endif
s.data[idx] = (unsigned char) c;
}
return (char) s.data[idx];
}
inline unsigned char operator = (unsigned char c) {
if (s.mlen <= 0) {
bstringThrow ("Write protection error");
} else {
#ifndef BSTRLIB_THROWS_EXCEPTIONS
if (idx >= (unsigned) s.slen) return '\0';
#endif
s.data[idx] = c;
}
return s.data[idx];
}
inline operator unsigned char () const {
#ifndef BSTRLIB_THROWS_EXCEPTIONS
if (idx >= (unsigned) s.slen) return (unsigned char) '\0';
#endif
return s.data[idx];
}
};
struct CBString : public tagbstring {
// Constructors
CBString ();
CBString (char c);
CBString (unsigned char c);
CBString (const char *s);
CBString (int len, const char *s);
CBString (const CBString& b);
CBString (const tagbstring& x);
CBString (char c, int len);
CBString (const void * blk, int len);
#if defined(BSTRLIB_CAN_USE_STL)
CBString (const struct CBStringList& l);
CBString (const struct CBStringList& l, const CBString& sep);
CBString (const struct CBStringList& l, char sep);
CBString (const struct CBStringList& l, unsigned char sep);
#endif
// Destructor
#if !defined(BSTRLIB_DONT_USE_VIRTUAL_DESTRUCTOR)
virtual
#endif
~CBString ();
// = operator
const CBString& operator = (char c);
const CBString& operator = (unsigned char c);
const CBString& operator = (const char *s);
const CBString& operator = (const CBString& b);
const CBString& operator = (const tagbstring& x);
// += operator
const CBString& operator += (char c);
const CBString& operator += (unsigned char c);
const CBString& operator += (const char *s);
const CBString& operator += (const CBString& b);
const CBString& operator += (const tagbstring& x);
// *= operator
inline const CBString& operator *= (int count) {
this->repeat (count);
return *this;
}
// + operator
const CBString operator + (char c) const;
const CBString operator + (unsigned char c) const;
const CBString operator + (const unsigned char *s) const;
const CBString operator + (const char *s) const;
const CBString operator + (const CBString& b) const;
const CBString operator + (const tagbstring& x) const;
// * operator
inline const CBString operator * (int count) const {
CBString retval (*this);
retval.repeat (count);
return retval;
}
// Comparison operators
bool operator == (const CBString& b) const;
bool operator == (const char * s) const;
bool operator == (const unsigned char * s) const;
bool operator != (const CBString& b) const;
bool operator != (const char * s) const;
bool operator != (const unsigned char * s) const;
bool operator < (const CBString& b) const;
bool operator < (const char * s) const;
bool operator < (const unsigned char * s) const;
bool operator <= (const CBString& b) const;
bool operator <= (const char * s) const;
bool operator <= (const unsigned char * s) const;
bool operator > (const CBString& b) const;
bool operator > (const char * s) const;
bool operator > (const unsigned char * s) const;
bool operator >= (const CBString& b) const;
bool operator >= (const char * s) const;
bool operator >= (const unsigned char * s) const;
// Casts
inline operator const char* () const { return (const char *)data; }
inline operator const unsigned char* () const { return (const unsigned char *)data; }
operator double () const;
operator float () const;
operator int () const;
operator unsigned int () const;
// Accessors
inline int length () const {return slen;}
inline unsigned char character (int i) const {
if (((unsigned) i) >= (unsigned) slen) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("character idx out of bounds");
#else
return '\0';
#endif
}
return data[i];
}
inline unsigned char operator [] (int i) const { return character(i); }
inline CBCharWriteProtected character (int i) {
return CBCharWriteProtected (*this, i);
}
inline CBCharWriteProtected operator [] (int i) { return character(i); }
// Space allocation hint method.
void alloc (int length);
// Search methods.
int caselessEqual (const CBString& b) const;
int caselessCmp (const CBString& b) const;
int find (const CBString& b, int pos = 0) const;
int find (const char * b, int pos = 0) const;
int caselessfind (const CBString& b, int pos = 0) const;
int caselessfind (const char * b, int pos = 0) const;
int find (char c, int pos = 0) const;
int reversefind (const CBString& b, int pos) const;
int reversefind (const char * b, int pos) const;
int caselessreversefind (const CBString& b, int pos) const;
int caselessreversefind (const char * b, int pos) const;
int reversefind (char c, int pos) const;
int findchr (const CBString& b, int pos = 0) const;
int findchr (const char * s, int pos = 0) const;
int reversefindchr (const CBString& b, int pos) const;
int reversefindchr (const char * s, int pos) const;
int nfindchr (const CBString& b, int pos = 0) const;
int nfindchr (const char * b, int pos = 0) const;
int nreversefindchr (const CBString& b, int pos) const;
int nreversefindchr (const char * b, int pos) const;
// Search and substitute methods.
void findreplace (const CBString& find, const CBString& repl, int pos = 0);
void findreplace (const CBString& find, const char * repl, int pos = 0);
void findreplace (const char * find, const CBString& repl, int pos = 0);
void findreplace (const char * find, const char * repl, int pos = 0);
void findreplacecaseless (const CBString& find, const CBString& repl, int pos = 0);
void findreplacecaseless (const CBString& find, const char * repl, int pos = 0);
void findreplacecaseless (const char * find, const CBString& repl, int pos = 0);
void findreplacecaseless (const char * find, const char * repl, int pos = 0);
// Extraction method.
CBString midstr (int left, int len) const;
// Standard manipulation methods.
void setsubstr (int pos, const CBString& b, unsigned char fill = ' ');
void setsubstr (int pos, const char * b, unsigned char fill = ' ');
void insert (int pos, const CBString& b, unsigned char fill = ' ');
void insert (int pos, const char * b, unsigned char fill = ' ');
void insertchrs (int pos, int len, unsigned char fill = ' ');
void replace (int pos, int len, const CBString& b, unsigned char fill = ' ');
void replace (int pos, int len, const char * s, unsigned char fill = ' ');
void remove (int pos, int len);
void trunc (int len);
// Miscellaneous methods.
void format (const char * fmt, ...);
void formata (const char * fmt, ...);
void fill (int length, unsigned char fill = ' ');
void repeat (int count);
void ltrim (const CBString& b = CBString (bsStaticBlkParms (" \t\v\f\r\n")));
void rtrim (const CBString& b = CBString (bsStaticBlkParms (" \t\v\f\r\n")));
inline void trim (const CBString& b = CBString (bsStaticBlkParms (" \t\v\f\r\n"))) {
rtrim (b);
ltrim (b);
}
void toupper ();
void tolower ();
// Write protection methods.
void writeprotect ();
void writeallow ();
inline bool iswriteprotected () const { return mlen <= 0; }
// Join methods.
#if defined(BSTRLIB_CAN_USE_STL)
void join (const struct CBStringList& l);
void join (const struct CBStringList& l, const CBString& sep);
void join (const struct CBStringList& l, char sep);
void join (const struct CBStringList& l, unsigned char sep);
#endif
// CBStream methods
int gets (bNgetc getcPtr, void * parm, char terminator = '\n');
int read (bNread readPtr, void * parm);
// QString compatibility methods
CBString toLocal8Bit() const { return *this; }
bool isEmpty() const { return slen == 0; }
void clear() { *this = ""; }
CBString left(int len) const { return midstr(0, len); }
CBString mid(int pos, int len) const { return midstr(pos, len); }
static CBString fromUtf16(const unsigned short* str) { // Naive implementation assuming that only ASCII part of UCS2 is used
CBString msg; while (*str) { msg += *(char*)str; str++; } return msg;
}
CBString leftJustified(int length) { if (length > slen) { return *this + CBString(' ', length - slen); } return *this; }
};
extern const CBString operator + (const char *a, const CBString& b);
extern const CBString operator + (const unsigned char *a, const CBString& b);
extern const CBString operator + (char c, const CBString& b);
extern const CBString operator + (unsigned char c, const CBString& b);
extern const CBString operator + (const tagbstring& x, const CBString& b);
inline const CBString operator * (int count, const CBString& b) {
CBString retval (b);
retval.repeat (count);
return retval;
}
#if defined(BSTRLIB_CAN_USE_IOSTREAM)
extern std::ostream& operator << (std::ostream& sout, CBString b);
extern std::istream& operator >> (std::istream& sin, CBString& b);
extern std::istream& getline (std::istream& sin, CBString& b, char terminator='\n');
#endif
struct CBStream {
friend struct CBStringList;
private:
struct bStream * m_s;
public:
CBStream (bNread readPtr, void * parm);
~CBStream ();
int buffLengthSet (int sz);
int buffLengthGet ();
int eof () const;
CBString readLine (char terminator);
CBString readLine (const CBString& terminator);
void readLine (CBString& s, char terminator);
void readLine (CBString& s, const CBString& terminator);
void readLineAppend (CBString& s, char terminator);
void readLineAppend (CBString& s, const CBString& terminator);
CBString read ();
CBString& operator >> (CBString& s);
CBString read (int n);
void read (CBString& s);
void read (CBString& s, int n);
void readAppend (CBString& s);
void readAppend (CBString& s, int n);
void unread (const CBString& s);
inline CBStream& operator << (const CBString& s) {
this->unread (s);
return *this;
}
CBString peek () const;
void peek (CBString& s) const;
void peekAppend (CBString& s) const;
};
#if defined(BSTRLIB_CAN_USE_STL)
struct CBStringList : public std::vector<CBString> {
// split a string into a vector of strings.
void split (const CBString& b, unsigned char splitChar);
void split (const CBString& b, const CBString& s);
void splitstr (const CBString& b, const CBString& s);
void split (const CBStream& b, unsigned char splitChar);
void split (const CBStream& b, const CBString& s);
void splitstr (const CBStream& b, const CBString& s);
};
#endif
} // namespace Bstrlib
#if !defined (BSTRLIB_DONT_ASSUME_NAMESPACE)
using namespace Bstrlib;
#endif
#endif
#endif

View file

@ -473,7 +473,7 @@ UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT
emit layoutChanged();
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
setFixed(created, fixed); // Non-trivial logic requires additional call
setFixed(created, (bool)fixed); // Non-trivial logic requires additional call
return created;
}

View file

@ -21,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#else
// Use Bstrlib
#define BSTRLIB_DOESNT_THROW_EXCEPTIONS
#include "../bstrlib/bstrwrap.h"
#include "bstrlib/bstrwrap.h"
#define UString CBString
#endif // QT_CORE_LIB