PIIODevice fullPathPrefix returns PIConstChars
This commit is contained in:
@@ -23,10 +23,7 @@
|
||||
//! \addtogroup Core
|
||||
//! \{
|
||||
//! \~\class PIConstChars piconstchars.h
|
||||
//! \~\brief
|
||||
//! \~english C-String class
|
||||
//! \~russian Класс C-строки
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english \section PICout_sec0 Synopsis
|
||||
//! \~russian \section PICout_sec0 Краткий обзор
|
||||
//! \~english
|
||||
@@ -54,12 +51,24 @@ bool PIConstChars::startsWith(const PIConstChars & str) const {
|
||||
}
|
||||
|
||||
|
||||
bool PIConstChars::startsWith(const char c) const {
|
||||
if (size() < 1) return false;
|
||||
return str[0] == c;
|
||||
}
|
||||
|
||||
|
||||
bool PIConstChars::endsWith(const PIConstChars & str) const {
|
||||
if (size() < str.size()) return false;
|
||||
return str == right(str.size());
|
||||
}
|
||||
|
||||
|
||||
bool PIConstChars::endsWith(const char c) const {
|
||||
if (size() < 1) return false;
|
||||
return str[len - 1] == c;
|
||||
}
|
||||
|
||||
|
||||
PIConstChars PIConstChars::mid(const int start, const int len) const {
|
||||
int s = start, l = len;
|
||||
if (l == 0 || s >= (int)size() || isEmpty()) return PIConstChars("");
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "picout.h"
|
||||
|
||||
|
||||
//! \ingroup Core
|
||||
//! \~\brief
|
||||
//! \~english C-String class
|
||||
//! \~russian Класс C-строки
|
||||
class PIP_EXPORT PIConstChars {
|
||||
public:
|
||||
|
||||
@@ -98,10 +102,18 @@ public:
|
||||
//! \~russian Возвращает начинается ли строка со "str".
|
||||
bool startsWith(const PIConstChars & str) const;
|
||||
|
||||
//! \~english Returns if string starts with "c".
|
||||
//! \~russian Возвращает начинается ли строка с "c".
|
||||
bool startsWith(const char c) const;
|
||||
|
||||
//! \~english Returns if string ends with "str".
|
||||
//! \~russian Возвращает оканчивается ли строка на "str".
|
||||
bool endsWith(const PIConstChars & str) const;
|
||||
|
||||
//! \~english Returns if string ends with "c".
|
||||
//! \~russian Возвращает оканчивается ли строка "c".
|
||||
bool endsWith(const char c) const;
|
||||
|
||||
//! \~english Returns part of string from character at index "start" and maximum length "len".
|
||||
//! \~russian Возвращает подстроку от символа "start" и максимальной длиной "len".
|
||||
//! \~\sa \a left(), \a right()
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
//! \n \a constructFullPath() should returns full unambiguous string, contains prefix and all device parameters
|
||||
//! \n \a configureFromFullPath() provide configuring device from full unambiguous string without prefix and "://"
|
||||
//! \n Macro PIIODEVICE should be used instead of PIOBJECT
|
||||
//! \n Macro REGISTER_DEVICE should be used after definition of class, i.e. at the last line of *.cpp file
|
||||
//! \n Macro REGISTER_DEVICE should be used after declaration of class, i.e. at the last line of *.h file
|
||||
//! \n \n If custom I/O device corresponds there rules, it can be returned by function \a createFromFullPath().
|
||||
//! \n Each PIP I/O device has custom unambiguous string description:
|
||||
//! * PIFile: "file://<path>"
|
||||
@@ -423,7 +423,7 @@ bool PIIODevice::configure(const PIString & config_file, const PIString & sectio
|
||||
|
||||
|
||||
PIString PIIODevice::constructFullPath() const {
|
||||
return PIStringAscii(fullPathPrefix()) + PIStringAscii("://") + constructFullPathDevice() + fullPathOptions();
|
||||
return fullPathPrefix().toString() + PIStringAscii("://") + constructFullPathDevice() + fullPathOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -499,16 +499,15 @@ PIStringList PIIODevice::availableClasses() {
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::registerDevice(const char * prefix, const char * classname, PIIODevice * (*fabric)()) {
|
||||
PIConstChars p(prefix);
|
||||
if (p.isEmpty()) return;
|
||||
void PIIODevice::registerDevice(PIConstChars prefix, PIConstChars classname, PIIODevice * (*fabric)()) {
|
||||
if (prefix.isEmpty()) return;
|
||||
//printf("registerDevice %s %d %d\n", prefix, p.isEmpty(), fabrics().size());
|
||||
if (!fabrics().contains(p)) {
|
||||
if (!fabrics().contains(prefix)) {
|
||||
FabricInfo fi;
|
||||
fi.prefix = prefix;
|
||||
fi.classname = classname;
|
||||
fi.fabricator = fabric;
|
||||
fabrics()[p] = fi;
|
||||
fabrics()[prefix] = fi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ typedef bool (*ReadRetFunc)(void * , uchar * , int );
|
||||
PIOBJECT_SUBCLASS(name, PIIODevice) \
|
||||
PIIODevice * copy() const {return new name();} \
|
||||
public: \
|
||||
virtual const char * fullPathPrefix() const {return prefix;} \
|
||||
static const char * fullPathPrefixS() {return prefix;} \
|
||||
virtual PIConstChars fullPathPrefix() const {return prefix;} \
|
||||
static PIConstChars fullPathPrefixS() {return prefix;} \
|
||||
private:
|
||||
|
||||
|
||||
@@ -244,9 +244,9 @@ public:
|
||||
|
||||
|
||||
//! Returns full unambiguous string prefix. \ref PIIODevice_sec7
|
||||
virtual const char * fullPathPrefix() const {return "";}
|
||||
virtual PIConstChars fullPathPrefix() const {return "";}
|
||||
|
||||
static const char * fullPathPrefixS() {return "";}
|
||||
static PIConstChars fullPathPrefixS() {return "";}
|
||||
|
||||
//! Returns full unambiguous string, describes this device, \a fullPathPrefix() + "://"
|
||||
PIString constructFullPath() const;
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
//! Returns class names of all registered devices
|
||||
static PIStringList availableClasses();
|
||||
|
||||
static void registerDevice(const char * prefix, const char * classname, PIIODevice*(*fabric)());
|
||||
static void registerDevice(PIConstChars prefix, PIConstChars classname, PIIODevice*(*fabric)());
|
||||
|
||||
|
||||
EVENT_HANDLER(bool, open);
|
||||
|
||||
Reference in New Issue
Block a user