PIIODevice registration dramatically optimization
This commit is contained in:
@@ -48,6 +48,18 @@
|
||||
//! \}
|
||||
|
||||
|
||||
bool PIConstChars::startsWith(const PIConstChars & str) const {
|
||||
if (size() < str.size()) return false;
|
||||
return str == left(str.size());
|
||||
}
|
||||
|
||||
|
||||
bool PIConstChars::endsWith(const PIConstChars & str) const {
|
||||
if (size() < str.size()) return false;
|
||||
return str == right(str.size());
|
||||
}
|
||||
|
||||
|
||||
PIConstChars PIConstChars::mid(const int start, const int len) const {
|
||||
int s = start, l = len;
|
||||
if (l == 0 || s >= (int)size() || isEmpty()) return PIConstChars("");
|
||||
|
||||
@@ -94,6 +94,14 @@ public:
|
||||
//! \~russian Возвращает длину строки в символах.
|
||||
inline ssize_t size_s() const {return len;}
|
||||
|
||||
//! \~english Returns if string starts with "str".
|
||||
//! \~russian Возвращает начинается ли строка со "str".
|
||||
bool startsWith(const PIConstChars & str) const;
|
||||
|
||||
//! \~english Returns if string ends with "str".
|
||||
//! \~russian Возвращает оканчивается ли строка на "str".
|
||||
bool endsWith(const PIConstChars & str) const;
|
||||
|
||||
//! \~english Returns part of string from character at index "start" and maximum length "len".
|
||||
//! \~russian Возвращает подстроку от символа "start" и максимальной длиной "len".
|
||||
//! \~\sa \a left(), \a right()
|
||||
|
||||
@@ -250,7 +250,7 @@ PIStringList PIObject::scopeList() const {
|
||||
PIMutexLocker ml(__meta_mutex());
|
||||
const PIVector<const char *> & scope(__meta_data()[classNameID()].scope_list);
|
||||
for (const char * c: scope)
|
||||
ret = PIStringAscii(c);
|
||||
ret << PIStringAscii(c);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -727,7 +727,7 @@ void PIObject::dump(const PIString & line_prefix) const {
|
||||
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
void dumpApplication() {
|
||||
void dumpApplication(bool with_objects) {
|
||||
PIMutexLocker _ml(PIObject::mutexObjects());
|
||||
//printf("dump application ...\n");
|
||||
PIDateTime cd = PIDateTime::current();
|
||||
@@ -745,22 +745,24 @@ void dumpApplication() {
|
||||
PICout(PICoutManipulators::AddNewLine) << " uptime: " << PITime::fromSystemTime(cd.toSystemTime() - pi->execDateTime.toSystemTime()).toString();
|
||||
PICout(PICoutManipulators::AddNewLine) << " PIObjects {";
|
||||
PICout(PICoutManipulators::AddNewLine) << " count: " << PIObject::objects().size_s();
|
||||
piForeachC (PIObject * o, PIObject::objects())
|
||||
o->dump(" ");
|
||||
if (with_objects) {
|
||||
for (const PIObject * o: PIObject::objects())
|
||||
o->dump(" ");
|
||||
}
|
||||
PICout(PICoutManipulators::AddNewLine) << " }";
|
||||
PICout(PICoutManipulators::AddNewLine) << "}";
|
||||
//printf("dump application done\n");
|
||||
}
|
||||
|
||||
|
||||
bool dumpApplicationToFile(const PIString & path) {
|
||||
bool dumpApplicationToFile(const PIString & path, bool with_objects) {
|
||||
PIFile f(path + "_tmp");
|
||||
f.setName("__S__DumpFile");
|
||||
f.clear();
|
||||
if (!f.open(PIIODevice::WriteOnly)) return false;
|
||||
bool ba = PICout::isBufferActive();
|
||||
PICout::setBufferActive(true, true);
|
||||
dumpApplication();
|
||||
dumpApplication(with_objects);
|
||||
f << PICout::buffer();
|
||||
f.close();
|
||||
PICout::setBufferActive(ba, true);
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef void (*Handler)(void * );
|
||||
class PIP_EXPORT PIObject {
|
||||
#ifndef MICRO_PIP
|
||||
friend class PIObjectManager;
|
||||
friend void dumpApplication();
|
||||
friend void dumpApplication(bool);
|
||||
friend class PIIntrospection;
|
||||
#endif
|
||||
typedef PIObject __PIObject__;
|
||||
@@ -587,8 +587,8 @@ private:
|
||||
};
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
PIP_EXPORT void dumpApplication();
|
||||
PIP_EXPORT bool dumpApplicationToFile(const PIString & path);
|
||||
PIP_EXPORT void dumpApplication(bool with_objects = true);
|
||||
PIP_EXPORT bool dumpApplicationToFile(const PIString & path, bool with_objects = true);
|
||||
#endif
|
||||
|
||||
#endif // PIOBJECT_H
|
||||
|
||||
Reference in New Issue
Block a user