filters
- filters
- kpresenter
- powerpoint
- libppt
28#define USTRING_SIMPLIFIED
30#ifdef USTRING_SIMPLIFIED
39#ifndef USTRING_SIMPLIFIED
65 unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
66 unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
68 unsigned char NaN_Bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
69 unsigned char Inf_Bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
71 unsigned char NaN_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
72 unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
75 const double NaN = *( reinterpret_cast<const double* >( NaN_Bytes ) );
76 const double Inf = *( reinterpret_cast<const double* >( Inf_Bytes ) );
79using namespace Libppt;
81#ifdef USTRING_SIMPLIFIED
82bool Libppt::isNaN( double)
87bool Libppt::isNaN( double d)
91#elif defined HAVE_FLOAT_H
92 return _isnan(d) != 0;
99#ifdef USTRING_SIMPLIFIED
100bool Libppt::isPosInf( double)
105bool Libppt::isPosInf( double d)
107#if defined(HAVE_FUNC_ISINF)
108 return (isinf(d) == 1);
109#elif HAVE_FUNC_FINITE
110 return finite(d) == 0 && d == d;
111#elif HAVE_FUNC__FINITE
112 return _finite(d) == 0 && d == d;
119#ifdef USTRING_SIMPLIFIED
120bool Libppt::isNegInf( double)
125bool Libppt::isNegInf( double d)
127#if defined(HAVE_FUNC_ISINF)
128 return (isinf(d) == -1);
129#elif HAVE_FUNC_FINITE
130 return finite(d) == 0 && d == d;
131#elif HAVE_FUNC__FINITE
132 return _finite(d) == 0 && d == d;
139CString::CString( const char *c)
141 data = new char[strlen(c)+1];
145CString::CString( const CString &b)
147 data = new char[b.length()+1];
148 strcpy(data, b.c_str());
160 n = new char[strlen(data)+t.length()+1];
163 n = new char[t.length()+1];
166 strcat(n, t.c_str());
174CString &CString::operator=( const char *c)
178 data = new char[strlen(c)+1];
191 data = new char[str.length()+1];
192 strcpy(data, str.c_str());
199 return append(CString(str.c_str()));
202int CString::length() const
207bool Libppt::operator==( const Libppt::CString& c1, const Libppt::CString& c2)
209 return (strcmp(c1.c_str(), c2.c_str()) == 0);
213UString::Rep UString::Rep::null = { 0, 0, 1 };
215static char *statBuffer = 0L;
225 if (uc >= 256 || islower(uc))
228 return UChar(tolower(uc));
233 if (uc >= 256 || isupper(uc))
236 return UChar(toupper(uc));
242 if (offset < str->rep->len)
243 *(str->rep->dat + offset) = c;
248UChar& UCharReference::ref() const
250 if (offset < str->rep->len)
251 return *(str->rep->dat + offset);
258 static inline UChar* allocateChars( int s)
261 return reinterpret_cast<UChar* >( new short[s]);
265UString::Rep *UString::Rep::create( UChar *d, int l)
277 null.rep = &Rep::null;
283 UChar *d = allocateChars( 1 );
285 rep = Rep::create(d, 1);
290 UChar *d = allocateChars( 1 );
292 rep = Rep::create(d, 1);
305 rep = Rep::create(d, length);
312 d = allocateChars( length );
316 rep = Rep::create(d, length);
332 sprintf(buf, "%d", i);
340 sprintf(buf, "%u", u);
353 else if (isPosInf(d))
354 strcpy(buf, "Infinity");
355 else if (isNegInf(d))
356 strcpy(buf, "-Infinity");
358 sprintf(buf, "%.16g", d);
361 int buflen = strlen(buf);
362 if (buflen >= 4 && buf[buflen-4] == 'e' && buf[buflen-2] == '0') {
363 buf[buflen-2] = buf[buflen-1];
377 rep = Rep::create(n, l + t. length());
390 delete [] statBuffer;
392 statBuffer = new char[ length()+1];
393 for( int i = 0; i < length(); i++)
394 statBuffer[i] = data()[i]. low();
395 statBuffer[ length()] = '\0';
403 int l = c ? strlen(c) : 0;
404 UChar *d = allocateChars( l );
405 for ( int i = 0; i < l; i++)
406 d[i].uc = static_cast<unsigned char>( c[i] );
407 rep = Rep::create(d, l);
429 for( int i = 0; i < length(); i++, u++)
441 return static_cast<const UChar * >( data() )[pos];
447 return UCharReference( this, pos);
458 const char *c = str.c_str();
466 return tolerant ? NaN : 0.0;
469 if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) {
473 if (*c >= '0' && *c <= '9')
474 d = d * 16.0 + *c - '0';
475 else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f'))
476 d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0;
484 if ((d != 0.0 || end != c) && d != HUGE_VAL && d != -HUGE_VAL) {
491 else if (*c == '-') {
495 if (strncmp(c, "Infinity", 8) != 0)
506 if ( !tolerant && *c != '\0')
517 if (isNaN(d) || d != static_cast<unsigned long>(d)) {
525 return static_cast<unsigned long>(d);
536 for ( const UChar *c = data() + pos; c <= end; c++)
537 if (!memcmp(c, f. data(), fsize))
551 if (!memcmp(c, f. data(), fsize))
564 else if (pos >= static_cast<int>( length() ))
568 if (pos + len >= static_cast<int>( length() ))
571 UChar *tmp = allocateChars( len );
572 memcpy(tmp, data()+pos, len * sizeof( UChar));
579void UString::attach(Rep *r)
585void UString::detach()
589 UChar *n = allocateChars( l );
592 rep = Rep::create(n, l);
596void UString::release()
606 if (s1.rep->len != s2.rep->len)
609 return (memcmp(s1.rep->dat, s2.rep->dat,
610 s1.rep->len * sizeof(UChar)) == 0);
613bool Libppt::operator==( const UString& s1, const char *s2)
615 if (s2 == 0L && s1. isNull())
618 if (s1. length() != static_cast<int>( strlen(s2) ))
621 const UChar *u = s1. data();
634 const int l1 = s1. length();
635 const int l2 = s2. length();
636 const int lmin = l1 < l2 ? l1 : l2;
637 const UChar *c1 = s1. data();
638 const UChar *c2 = s2. data();
640 while (l < lmin && *c1 == *c2) {
664UConstString::~UConstString()
668 UChar* n = allocateChars( l );
669 memcpy( n, data(), l * sizeof( UChar ) );
8 bit char based string class
Dynamic reference to a string character.
UCharReference & operator=(UChar c) Set the referenced character to c.
bool is8Bit() const Use this if you want to make sure that this string is a plain ASCII string.
int find(const UString &f, int pos=0) const
int rfind(const UString &f, int pos) const
UString() Constructs a null string.
UString & operator=(const char *c) Assignment operator.
char * ascii() const Convert the Unicode string to plain ASCII chars chopping of any higher bytes.
UString & operator+=(const UString &s) Appends the specified string.
double toDouble(bool tolerant=false) const Attempts an conversion to a number.
static UString null Static instance of a null string.
UString substr(int pos=0, int len=-1) const
const UChar * data() const
unsigned long toULong(bool *ok=0L) const Attempts an conversion to an unsigned long integer.
UChar operator[](int pos) const Const character at specified position.
UString & append(const UString &) Append another string.
static UString from(int i) Constructs a string from an int.
static UChar null A static instance of UChar(0).
unsigned char low() const
UChar() Construct a character with value 0.
unsigned short unicode() const
|