const Byte* value, size_t valueLength){
ReSeqArray::Index index;
ReSeqArray::Tag tag;
+ if (keyLength == (size_t) -1)
+ keyLength = strlen(key);
+ if (valueLength == (size_t) -1)
+ valueLength = strlen(value);
if (m_keys.binarySearch(key, keyLength, index, &tag)){
// replace the value:
m_values.set((ReSeqArray::Index) tag, value, valueLength, 0);
:
m_usage(),
m_examples(),
- m_properties(),
+ m_properties(false, 2, 2, 1),
m_values(),
m_args(NULL),
m_argCount(0),
m_lastError()
{
+ m_properties.setCapacity(64, 64*8, 64*1024);
for (const char** argv = usageList; *argv != NULL; argv++){
m_usage.add(-1, *argv, -1);
}
* @throws ReOptionException Unknown name or wrong type.
*/
bool ReProgramArgs::getBool(const char* name) {
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
ReByteBuffer buffer;
ReVarArgs args;
if (! m_properties.get(name, -1, buffer))
* @throws ReOptionException Unknown name or wrong type.
*/
int ReProgramArgs::getInt(const char* name) {
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
ReByteBuffer buffer;
ReVarArgs args;
if (! m_properties.get(name, -1, buffer))
* @throws ReOptionException Unknown name or wrong type.
*/
const char* ReProgramArgs::getString(const char* name, ReByteBuffer& buffer) {
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
ReVarArgs args;
- if (! m_properties.get(name, -1, buffer))
+ if (! m_properties.get(name, strlen(name), buffer))
throw ReOptionException(this, i18n("$1 is not an option name"), name);
properties.split(buffer.str(), '\1');
*/
bool ReProgramArgs::analyseShort(const char* opt, const char* nextArg){
bool rc = false;
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
bool again;
ReByteBuffer name;
do {
*
*/
void ReProgramArgs::analyseLong(const char* opt){
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
ReByteBuffer name;
search('\0', opt, name, properties);
ReByteBuffer param;
while(m_properties.next(position, &name, &prop)){
- ReStringList properties;
+ ReStringList properties(512, 1024, 2, 2);
properties.split(prop.str(), '\1');
line.setLength(0);
DataType dataType = DataType(properties.strOf(IxType)[0]);
}
void ReProgramArgs::help(const char* message, bool issueLastError, FILE* stream) const{
- ReStringList lines;
+ ReStringList lines(512, 1024, 2, 2);
help(message, issueLastError, lines);
for(size_t ii = 0; ii < lines.count(); ii++){
fputs(lines.strOf(ii), stream);
LC_SET_SIZES_1 = LC_SEQARRAY + 1, // 50201
LC_SET_SIZES_2, // 50202
LC_SET_SIZES_3, // 50203
+ LC_SET_SEQ_1, // 50204
+ LC_SET_SEQ_2, // 50205
+ LC_SET_SEQ_3, // 50206
+ LC_SET_SEQ_4, // 50207
+ LC_SET_SEQ_5, // 50208
+ LC_SET_SEQ_6, // 50209
+ LC_SET_SEQ_7, // 50210
+ LC_SET_SEQ_8, // 50211
+ LC_SET_SEQ_9, // 50212
+ LC_SET_SEQ_10, // 50213
};
/**
* @file
uint8_t* ptr = reinterpret_cast<uint8_t*>(seq) + m_offsetOfLength;
switch (m_sizeOfLength){
case 1:
+ if (length > 0xff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_1,
+ i18n("length > 255: $1")).arg((int64_t) length).end();
ptr[0] = length & 0xff;
break;
case 2:
+ if (length > 0xffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_2,
+ i18n("length > 64k: $1")).arg((int64_t) length).end();
ptr[0] = length & 0xff;
ptr[1] = (length >> 8) & 0xff;
break;
case 3:
+ if (length > 0xffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_3,
+ i18n("length > 16M: $1")).arg((int64_t) length).end();
ptr[0] = length & 0xff;
ptr[1] = (length >> 8) & 0xff;
ptr[2] = (length >> 16) & 0xff;
break;
case 4:
+ if (length > 0xffffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_4,
+ i18n("length > 4G: $1")).arg((int64_t) length).end();
ptr[0] = length & 0xff;
ptr[1] = (length >> 8) & 0xff;
ptr[2] = (length >> 16) & 0xff;
ptr[3] = (length >> 24) & 0xff;
break;
case 5:
+ if (length > 0xffffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_5,
+ i18n("length > 1T: $1")).arg((int64_t) length).end();
ptr[0] = length & 0xff;
ptr[1] = (length >> 8) & 0xff;
ptr[2] = (length >> 16) & 0xff;
uint8_t* ptr = reinterpret_cast<uint8_t*>(seq) + m_offsetOfTag;
switch (m_sizeOfTag){
case 1:
+ if (tag > 0xff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_6,
+ i18n("tag > 255: $1")).arg((int64_t) tag).end();
ptr[0] = tag & 0xff;
break;
case 2:
- ptr[0] = length & 0xff;
+ if (tag > 0xffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_7,
+ i18n("tag > 64k: $1")).arg((int64_t) tag).end();
+ ptr[0] = tag & 0xff;
ptr[1] = (tag >> 8) & 0xff;
break;
case 3:
+ if (tag > 0xffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_8,
+ i18n("tag > 16M: $1")).arg((int64_t) tag).end();
ptr[0] = tag & 0xff;
ptr[1] = (tag >> 8) & 0xff;
ptr[2] = (tag >> 16) & 0xff;
break;
case 4:
+ if (tag > 0xffffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_9,
+ i18n("tag > 4G: $1")).arg((int64_t) tag).end();
ptr[0] = tag & 0xff;
ptr[1] = (tag >> 8) & 0xff;
ptr[2] = (tag >> 16) & 0xff;
ptr[3] = (tag >> 24) & 0xff;
break;
case 5:
+ if (tag > 0xffffffff)
+ globalLogger()->sayF(LOG_ERROR | CAT_LIB, LC_SET_SEQ_10,
+ i18n("tag > 1T: $1")).arg((int64_t) tag).end();
ptr[0] = tag & 0xff;
ptr[1] = (tag >> 8) & 0xff;
ptr[2] = (tag >> 16) & 0xff;
* @param deltaList list reservation will be incremented by this amount
* @param deltaBuffer buffer reservation will be incremented by this amount
*/
-ReStringList::ReStringList(int deltaList, int deltaBuffer) :
+ReStringList::ReStringList(int deltaList, int deltaBuffer, int sizeOfTag,
+ int sizeOfLength, size_t constantLength) :
ReSeqArray(deltaList, deltaBuffer)
{
+ setSizes(sizeOfTag, sizeOfLength, constantLength);
}
/** @brief Destructor.
*/
class ReStringList : public ReSeqArray {
public:
- ReStringList(int deltaList = 1024, int deltaBuffer = 1024);
+ ReStringList(int deltaList = 1024, int deltaBuffer = 1024, int sizeOfTag = 4,
+ int sizeOfLength = 1, size_t constantLength = INDIVIDUAL_SIZE);
virtual ~ReStringList();
public:
ReStringList& append(const char* source, Tag tag = 0);
}
void testOs(){
void testReTraverser();
- //testReTraverser();
+ testReTraverser();
}
void testMath(){
extern void testReRandomizer();
void testAll(){
try
{
+ testOs();
testBase();
testMath();
- testOs();
testString();
} catch (ReException e){
fprintf(stderr, "testBase.cpp: unexpected exception: %s\n", e.getMessage());
"units: m(inutes) h(hours), d(days). Default: m(inutes)\n"
"examples: -o25 --older-than=30d -o24h -o2009.3.2/12:00 -o1999.01.01"),
'o', "older-than", false, NULL);
+ReByteBuffer buffer;
+const char* ptr = m_programArgs.getString("older", buffer);
m_programArgs.addString("pathpattern",
i18n("a list of patterns for the path (without basename)\n"
"the separator is the first character of the list\n"
"and none of the 'not patterns' matches\n"
"examples: ';*;-*/.git/' ',*/cache/,*/temp/"),
'P', "path-pattern", false, NULL);
- m_programArgs.addString("nodepattern",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addString("nodepattern",
i18n("a list of patterns for the basename (name without path) separated by ';'\n"
"Each pattern can contain '*' as wildcard\n"
"If the first character is '-' the pattern is a 'not pattern':\n"
"of the 'not patterns' matches\n"
"examples: '*.cpp;*.hpp;Make*' '*;-*.bak;-*~"),
'p', "basename-pattern", false, NULL);
- m_programArgs.addBool("quiet",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addBool("quiet",
i18n("no additional information like runtime"),
'q', "quiet", false);
- m_programArgs.addInt("trace",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addInt("trace",
i18n("all <number> seconds the current path will be traced\n"
"0: no trace"),
'T', "trace-interval", 0);
- m_programArgs.addString("type",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addString("type",
i18n("the file type\n"
"<string> is a list of <v> values:\n"
"<v>: b(lock) c(har) d(irectory) (l)i(nkdir) l(ink) o(ther)\n"
"<v>-sets: S(pecial)=bcspo N(ondir)=Slr\n"
"examples: -td --type=dr -tNi"),
't', "type", false, NULL);
- m_programArgs.addString("younger",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addString("younger",
i18n("the modification date is younger than <string>\n"
"<string> is a date (e.g. 2015.02.17) or number followed by an unit\n"
"units: m(inutes) h(hours), d(days). Default: m(inutes)"),
'y', "younger-than", false, NULL);
- m_programArgs.addString("maxsize",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addString("maxsize",
i18n("the filesize is greater or equal <string>\n"
"<string> is a number followed by an unit\n"
"units: b(yte) k(Byte) K(iByte) m(Byte), M(iByte), g(Byte) G(iByte)\n"
"examples: -Z50m --max-size=1G"),
'Z', "max-size", false, NULL);
- m_programArgs.addString("minsize",
+ptr = m_programArgs.getString("older", buffer);
+ m_programArgs.addString("minsize",
i18n("the filesize is greater or equal <string>\n"
"<string> is a number followed by an unit\n"
"units: b(yte) k(Byte) K(iByte) m(Byte), M(iByte), g(Byte) G(iByte)\n"
"examples: -z50m --min-size=1G"),
'z', "min-size", false, NULL);
+ptr = m_programArgs.getString("older", buffer);
}
/**