#ifndef REBYTEBUFFER_H_
#define REBYTEBUFFER_H_
-#define PRIMARY_BUFFER_SIZE 512
+#define PRIMARY_BUFFER_SIZE 513
/** @brief An efficient dynamic memory buffer.
*
indexContent = m_content.length();
m_content.append(source, sourceLength);
}
- printf("vor:\n%s\n", ReByteBuffer("")
+/* printf("vor:\n%s\n", ReByteBuffer("")
.appendHexDump(m_list.str(), m_entrySize*(1+index), 0,
m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str());
+ */
setSequence(seq, indexContent, sourceLength, tag);
- printf("dann:\n%s\n", ReByteBuffer("")
+ /*printf("dann:\n%s\n", ReByteBuffer("")
.appendHexDump(m_list.str(), m_entrySize*(1+index), 0,
m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str());
+ */
}
}
}
private:
void run(){
+ testEnsureSize2();
testHexDump();
testFill();
testAppendMilliSec();
testSplice();
testReplace();
}
+ void testEnsureSize2(){
+ ReByteBuffer buffer;
+ buffer.setLength(PRIMARY_BUFFER_SIZE - 1);
+ buffer.fill('x', PRIMARY_BUFFER_SIZE - 1);
+ checkEqu(PRIMARY_BUFFER_SIZE - 1, (int) buffer.capacity());
+ buffer.ensureSize(PRIMARY_BUFFER_SIZE);
+ checkEqu(PRIMARY_BUFFER_SIZE*2 - 1, (int) buffer.capacity());
+ }
void testHexDump(){
ReByteBuffer buf;
/* appendHexDump(const char* data, size_t length, int offset = 0, int bytePerLine = 16,
" 28: 36373839 783132336789x123\n"
" 36: 343536 456 \n", buf.str());
buf.setLength(0).appendHexDump("abcdefghijk", -1, 0, 8, "%3d: ", true, 2, 4);
- printf("%s", buf.str());
- checkEqu(" 20: 090ac3bc 32333435....2345\n"
- " 28: 36373839 783132336789x123\n"
- " 36: 343536 456 \n", buf.str());
+ checkEqu(" 0: 6162 6364 6566 6768 | abcd efgh\n"
+ " 8: 696a 6b | ijk \n", buf.str());
}
void testFill(){
ReByteBuffer buf;
checkEqu("123", buffer.buffer());
checkEqu(3u, buffer.length());
- buffer.setLengthAndFillOut(511, 'y');
- buffer.setLengthAndFillOut(512, 'z');
- checkEqu("yyz", buffer.buffer() + 509);
- checkEqu(521u, buffer.capacity());
+ buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE - 1, 'y');
+ buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE, 'z');
+ checkEqu("yyz", buffer.buffer() + PRIMARY_BUFFER_SIZE - 3);
+ checkEqu(PRIMARY_BUFFER_SIZE + 10 - 1, (int) buffer.capacity());
ReByteBuffer buffer2;
buffer2.set("xyz", -1);
ReSeqArray list;
ReByteBuffer value;
ReSeqArray::Tag tag = 0;
-
+ list.setSizes(8, 4);
list.add(-1, "xxx", -1, ReSeqArray::Tag(1l) << 31);
checkT(list.get(0, value, &tag));
checkEqu(1ll << 31, tag);
#endif
void testBase(){
- extern void testReByteBuffer();
- testReByteBuffer();
+ extern void testReSeqArray(void);
+ testReSeqArray();
extern void testReTestUnit();
//testReTestUnit();
void testAll(){
try
{
- testString();
-
testOs();
+
testBase();
- testMath();
testString();
+ testMath();
+ testOs();
} catch (ReException e){
fprintf(stderr, "testBase.cpp: unexpected exception: %s\n", e.getMessage());
}
* @param filter OUT: the filter to set\r
*/\r
void ReDirOptions::setFilterFromProgramArgs(ReDirEntryFilter_t& filter){\r
+{ ReByteBuffer buf;\r
+const char* ptr = m_programArgs.getString("pathpattern", buf);\r
+}\r
ReByteBuffer buffer;\r
if (m_programArgs.getString("younger", buffer)[0] != '\0')\r
filter.m_maxAge = checkDate(buffer.str());\r
if (ReStringUtils::lengthOfUnsigned(arg1, -1, (unsigned *) &depth) == 0)\r
m_programArgs.help("depth is not an integer", false, stdout);\r
}\r
- ReDirStatistic statistic;\r
void (*proc) (const ReDirStatisticData& data,\r
ReDirStatistic& parent, ReByteBuffer& line) = &formatWithSizeFilesAndDirs;\r
if (m_programArgs.getBool("kbyte"))\r
proc = &formatLikeDu;\r
- const ReStringList& list = statistic.calculate(m_programArgs.getArg(0), depth, proc);\r
+ const ReStringList& list = calculate(m_programArgs.getArg(0), depth, proc);\r
ReByteBuffer buffer;\r
for (size_t ix = 0; ix < list.count(); ix++){\r
buffer.set(list.strOf(ix), list.strLengthOf(ix));\r
void ReTraverser::setPropertiesFromFilter(ReDirEntryFilter_t* filter){\r
m_minLevel = filter->m_minDepth;\r
m_maxLevel = filter->m_maxDepth;\r
- m_dirPatterns = filter->m_pathPatterns;\r
+ setDirPattern(filter->m_pathPatterns);\r
}\r
\r
/**\r
* @param pattern pattern list for the subdirs to be entered
*/
void setDirPattern(RePatternList* pattern)
- { m_dirPatterns = pattern; }
+ { m_dirPatterns = pattern; m_dirPatterns->setIgnoreCase(true); }
/** Sets the maximal depth.
* @param value the value to set
*/