git-svn-id: svn://db.shs.com.ru/pip@816 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-06-26 11:08:10 +00:00
parent 4e84f935d2
commit 19d4ab94b9
16 changed files with 61 additions and 94 deletions

View File

@@ -29,6 +29,7 @@
#include "piversion.h"
#include "piplatform.h"
#include "pip_export.h"
#include "pip_defs.h"
//! Version of PIP in hex - 0x##(Major)##(Minor)##(Revision)
#define PIP_VERSION ((PIP_VERSION_MAJOR << 16) | (PIP_VERSION_MINOR < 8) | PIP_VERSION_REVISION)

View File

@@ -22,14 +22,11 @@
#include "pibase.h"
#include "piflags.h"
#include "pimonitor.h"
#include <sys/types.h>
#ifdef PIP_STD_IOSTREAM
# include <iostream>
#endif
extern PIMonitor piMonitor;
class PIObject;
class PIMutex;
class PIString;

View File

@@ -77,7 +77,6 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
setName(name);
setDebug(true);
mutexObjects().lock();
piMonitor.objects++;
objects() << this;
mutexObjects().unlock();
//piCout << "new" << this;
@@ -87,7 +86,6 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
PIObject::~PIObject() {
//piCout << "delete" << this;
mutexObjects().lock();
piMonitor.objects--;
objects().removeAll(this);
mutexObjects().unlock();
piDisconnect(this);

View File

@@ -86,6 +86,10 @@ const int PIString::fromBaseN[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
const float PIString::ElideLeft = 0.f;
const float PIString::ElideCenter = .5f;
const float PIString::ElideRight = 1.f;
#ifndef CC_VC
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf(ch, f, v);
@@ -629,6 +633,21 @@ PIString & PIString::insert(int index, const PIString & str) {
}
PIString & PIString::elide(int size, float pos) {
if (length() <= size) return *this;
if (length() <= 2) {
fill(".");
return *this;
}
pos = piClampf(pos, 0.f, 1.f);
int ns = size - 2;
int ls = piRoundf(ns * pos);
remove(ls, length() - ns);
insert(ls, "..");
return *this;
}
PIStringList PIString::split(const PIString & delim) const {
PIStringList sl;
if (isEmpty() || delim.isEmpty()) return sl;

View File

@@ -39,6 +39,10 @@ public:
//! Contructs an empty string
PIString(): PIDeque<PIChar>() {}
static const float ElideLeft ;
static const float ElideCenter;
static const float ElideRight ;
//inline PIString & operator +=(const char c) {push_back(c); return *this;}
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
PIString & operator +=(const char * str);
@@ -354,7 +358,7 @@ public:
PIString quoted(PIChar c = PIChar('"')) {return PIString(*this).quote(c);}
/*! \brief Reverse string and return this string
* \details Example: \snippet pistring.cpp PIString::reverse
* \details Example: \snippet pistring.cpp PIString::reverse
* \sa \a reversed() */
PIString & reverse() {PIString str(*this); clear(); piForeachR (const PIChar & c, str) push_back(c); return *this;}
@@ -362,6 +366,15 @@ public:
* \details Example: \snippet pistring.cpp PIString::reversed
* \sa \a reverse() */
PIString reversed() const {PIString str(*this); str.reverse(); return str;}
/*! \brief Elide string to maximum size \"size\" and return this string
* \sa \a elided() */
PIString & elide(int size, float pos = ElideCenter);
/*! \brief Elide copy of this string to maximum size \"size\" and return it
* \details Example: \snippet pistring.cpp PIString::elided
* \sa \a elide() */
PIString elided(int size, float pos = ElideCenter) const {PIString str(*this); str.elide(size, pos); return str;}
/*! \brief Take a part of string from symbol at index "start" and maximum length "len" and return it