# title of most generated pages and in a few other places.
# The default value is: My Project.
-PROJECT_NAME = RePublib
+PROJECT_NAME = "Real Public Library - Qt Library"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER =
+PROJECT_NUMBER = 2015.11
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
-PROJECT_BRIEF =
+PROJECT_BRIEF = "Qt Source Code: Base Classes and Applications"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
-OUTPUT_DIRECTORY = doc
+OUTPUT_DIRECTORY = /home/doxygen/reqt
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
# normally produced when WARNINGS is set to YES.
# The default value is: NO.
-EXTRACT_ALL = NO
+EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
# messages should be written. If left blank the output is written to standard
# error (stderr).
-WARN_LOGFILE =
+WARN_LOGFILE = warnings.log
#---------------------------------------------------------------------------
# Configuration options related to the input files
# spaces.
# Note: If this tag is empty the current directory is searched.
-INPUT = .
+INPUT = /home/ws/qt/reqt
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE =
+EXCLUDE = build
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
-EXCLUDE_PATTERNS =
+EXCLUDE_PATTERNS = moc_*.cpp \
+ *.js
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# also VERBATIM_HEADERS is set to NO.
# The default value is: NO.
-SOURCE_BROWSER = NO
+SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
# classes and enums directly into the documentation.
/**
* Sets the maximum subdirectory depth.
*
- * @param minDepth 0: search only in the base directory<br>
+ * @param maxDepth 0: search only in the base directory<br>
* otherwise: the maximum depth
*/
void FileFinder::setMaxDepth(int maxDepth){
/**
* @brief Constructor.
*
+ * @param startDir the current directory at program start
+ * @param homeDir the base directory for the configuration files
* @param parent NULL or the parent widget
*/
MainWindow::MainWindow(const QString& startDir, const QString& homeDir,
/**
* Search a text pattern in the given file.
*
- * @param pattern a text pattern to search
- * @param ignoreCase <code>true</code>: the search must be case insensitive
- * @param isRegular <code>true</code>: the pattern is a regular expression
- * @return <code>true</code>: the patter was found
+ * @return <code>true</code>: the pattern was found
*/
bool TextFinder::contains(){
bool rc = false;
/**
* Constructor.
*
- * @param path the directory containing the configuration
- * @param logger the logger
+ * @param path the directory containing the configuration
+ * @param mainWindow the instance of the main window
*/
Project::Project(const QString& path, MainWindow* mainWindow) :
ReSettings(path, ".reditor.proj", mainWindow->logger()),
m_mainWindows->on_threadStateChanged(state, info);
}
-/**
- * Reads the image properties from an image file.
- *
- * @param name filename with path
- * @param width OUT: the width of the image
- * @param height OUT: the height of the image
- * @param info OUT: information of the image
- * @return <code>true</code>: success<br>
- * <code>false</code>: cannot retrieve the image data
- */
/**
* Converts an image into another format.
*
* <ul>
*<li>Makes the target directory (if necessary)</li>
*<li>Search the images *.png / *.jpg and converts them</li>
- *<ul>
+ *</ul>
*/
void Converter::run(){
QString msg;
/**
* @brief Constructor.
*
+ * @param file the file to view
* @param parent NULL or the parent widget
*/
MainWindow::MainWindow(const QString& file,
* The latest sources: https://github.com/republib
*/
-/** @file
+/** \@file
*
* @brief A very efficient storage for bytes and C strings.
*/
-/** @file rplcore/rplbytestorage.hpp
+/** @file base/ReByteStorage.hpp
*
* @brief Definitions for a very efficient storage for bytes and C strings.
*/
*
* @brief Reading/writing configuration files.
*/
-/** @file rplcore/rplconfig.hpp
+/** @file base/ReConfig.hpp
*
* @brief Definitions for reading/writing configuration files.
*/
* @brief Implements a portable data container.
*/
-/** @file recore/ReContainer.hpp
+/** @file base/ReContainer.hpp
*
* @brief Definition for a portable data container.
*/
*
* @note A real public library for QT.
*
- * This library contains the module groups
+ * This library contains the following module groups
* <ul>
- * <li>rplcore: basic definitions, used in all other module groups</li>
- * <li>rplmath: mathematic definitions and tools</li>
- * <li>rplexpr: definition for parsing and interpretation of languages</li>
- * <li>rplnet: definitions and tools for tcp/udp communication</li>
+ * <li>base: basic definitions, used in all other module groups</li>
+ * <li>os: Operating System specific definitions and tools</li>
+ * <li>math: mathematic definitions and tools</li>
+ * <li>expr: definition for parsing and interpretation of languages</li>
+ * <li>net: definitions and tools for tcp/udp communication</li>
* </ul>
*
* Each module group has a central include file, which organizes the necessary
* #include "base/rebase.hpp"
* #include "expr/reexpr.hpp"
* </code></pre>
- * In this case all definitions of rplcore and rplexpr are available.
+ * In this case all definitions of base and expr are available.
*/
/** @file
* @brief Generally usable exceptions.
*/
-/** @file rplcore/rplexception.hpp
+/** @file base/ReException.hpp
*
* @brief Definitions for a generally usable exceptions.
*/
logger->log(level, location, buffer);
}
-/** @class RplRangeException rplexception.hpp "rplcore/rplexception.hpp"
+/** @class RplRangeException ReException.hpp "base/ReException.hpp"
*
* @brief An exception for integer range errors.
*
logger->log(level, location, buffer);
}
-/** @class RplInvalidDataException rplexception.hpp "rplcore/rplexception.hpp"
+/** @class RplInvalidDataException ReException.hpp "base/ReException.hpp"
*
* @brief An exception usable if binary data have the wrong structure.
*
* Joins a line and the following line into one line.
*
* @param first the line number of the first line
- * @param <code>true</code>: the join has been done<br>
+ * @return <code>true</code>: the join has been done<br>
* <code>false</code>: wrong parameter (first)
*/
bool ReLines::joinLines(int first) {
* Constructor.
*
* @param filename name of the file
+ * @param readOnly <code>true</code>: the file will be opened for
+ * reading only
+ * @param logger the logger
*/
ReFile::ReFile(const QString& filename, bool readOnly, ReLogger* logger) :
ReLineSource(),
/**
* Prepares the undo operation of an insertion in a given lineNo.
*
- * @param line the line number of the the first line to insert
- * @param count the number of lines to insert
+ * @param lineNo the line number of the the first line to insert
+ * @param count the number of lines to insert
*/
void ReUndoList::storeInsertLines(int lineNo, int count) {
UndoItem* item = new UndoItem();
* @param host OUT: NULL or the host part
* @param path OUT: NULL or the path without the last node
* @param node OUT: NULL or the last node of the path
+ * @param params OUT: NULL or the parameters (e.g. at http)
*/
void ReFileUtils::splitUrl(const QString& url, QString* protocol, QString* host,
QString* path, QString* node, QString* params){
* @param modified the new modification time
* @param accessed the new access time.
* If <code>m_undefinedTime</code> the current time is taken
+ * @param logger the logger
* @return <code>true</code>: success
*/
bool ReFileUtils::setTimes(const char* filename, const QDateTime& modified,
/** @file
* A configurable logger for different output media.
*/
-/** @file rplcore/rpllogger.hpp
+/** @file base/ReLogger.hpp
*
* Definitions for a configurable logger for different output media.
*/
m_globalLogger = NULL;
}
-/** @class ReAppender rpllogger.hpp "rplcore/rpllogger.hpp"
+/** @class ReAppender ReLogger.hpp "base/ReLogger.hpp"
*
* @brief Puts the logging info to a medium (e.g. a file).
*
return m_autoDelete;
}
-/** @class ReLogger rpllogger.hpp "rplcore/rpllogger.hpp"
+/** @class ReLogger ReLogger.hpp "base/ReLogger.hpp"
*
* @brief Implements a logger.
*
addAppender((ReAppender*) fileAppender);
}
-/** @class ReStreamAppender rpllogger.hpp "rplcore/rpllogger.hpp"
+/** @class ReStreamAppender ReLogger.hpp "base/ReLogger.hpp"
*
* @brief Puts the logging info to a standard output stream.
*
}
#pragma GCC diagnostic warning "-Wunused-parameter"
-/** @class ReFileAppender rpllogger.hpp "rplcore/rpllogger.hpp"
+/** @class ReFileAppender ReLogger.hpp "base/ReLogger.hpp"
*
* @brief Puts the logging info to a file.
*
}
#pragma GCC diagnostic warning "-Wunused-parameter"
-/** @class ReMemoryAppender rpllogger.hpp "rplcore/rpllogger.hpp"
+/** @class ReMemoryAppender ReLogger.hpp "base/ReLogger.hpp"
*
* @brief Puts the logging info to an internal buffer.
*
* Constructor.
*
* @param pattern a pattern with wildcards '*' (any string)
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
+ * @param caseSensivity caseSensitive or caseInsensitive
+ * @param anchored <code>true</code>: the pattern starts at the strings
* start<br>
- * <code>false<code>: the pattern can start anywhere in
+ * <code>false</code>: the pattern can start anywhere in
* the string
*/
* Constructor.
*
* @param patterns a list of patterns with wildcards '*' (any string)
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
+ * @param caseSensivity caseSensitive or caseInsensitive
+ * @param anchored <code>true</code>: the pattern starts at the strings
* start<br>
- * <code>false<code>: the pattern can start anywhere in
+ * <code>false</code>: the pattern can start anywhere in
* the string
*/
ReListMatcher::ReListMatcher(const QStringList& patterns,
/**
* Sets a new pattern list.
*
- * @param patterns the patterns to search
- * @param anchored <code>true<code>: the pattern must match the string's start<br>
- * <code>false<code>: the pattern can match anywhere
+ * @param patterns the patterns to search
+ * @param caseSensivity CaseSensitive or CaseInsensitive
+ * @param anchored <code>true</code>: the pattern must match the string's start<br>
+ * <code>false</code>: the pattern can match anywhere
*/
void ReListMatcher::setPatterns(const QStringList& patterns,
Qt::CaseSensitivity caseSensivity, bool anchored) {
*
* @param patterns a comma delimited pattern list, exclude patterns
* marked with the prefix '-'. Example: "*.c,*.h,-test*'
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
+ * @param caseSensivity CaseSensitive or CaseInsensitive
+ * @param anchored <code>true</code>: the pattern starts at the strings
* start<br>
- * <code>false<code>: the pattern can start anywhere in
+ * <code>false</code>: the pattern can start anywhere in
* the string
*/
ReIncludeExcludeMatcher::ReIncludeExcludeMatcher(const QString& patterns,
*
* @param includes a list of include patterns
* @param excludes a list of exclude patterns
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
+ * @param caseSensivity CaseSensitive or CaseInsensitive
+ * @param anchored <code>true</code>: the pattern starts at the strings
* start<br>
- * <code>false<code>: the pattern can start anywhere in
+ * <code>false</code>: the pattern can start anywhere in
* the string
*/
ReIncludeExcludeMatcher::ReIncludeExcludeMatcher(const QStringList& includes,
* Removes end of line characters if any.
*
* @param text text to inspect
- * @return <code>text</code> without trailing '\n' and/or '\r'
+ * @return <code>text</code> without trailing '\\n' and/or '\\r'
*/
ReString ReQStringUtils::chomp(const ReString& text) {
int last = text.length() - 1;
}
/**
- * @brief Determines the length and vlaue of an integer.
+ * @brief Determines the length and value of an integer.
*
* @param text the number as text
* @param start the first index to inspect
* @param radix the base of the number sytem: 8 (octal), 10 or 16
- * @param pValue OUT: the value of the integer. May be NULL
+ * @param pValue OUT: the value of the integer. May be NULL
*
- * @return <=0: no integer found
+ * @return <=0: no integer found<br>
* otherwise: the length of the integer
*/
int ReQStringUtils::lengthOfUInt64(const ReString& text, int start, int radix,
- quint64* pValue) {
+ int64_t* pValue) {
int inputLength = text.size();
int64_t value = 0;
int ix = start;
* @param expr an expression, e.g. "10*1024kByte+5MiByte"
* @param unitList description of the allowed units with its factor<br>
* example: "kibyte:1024;kbyte:1000;mibyte:1048576;mbyte:1000000"
+ * @param parseAtOnce <code>true</code>: the parse process will be started
*/
ReUnitParser::ReUnitParser(const QString& expr, const char* unitList,
bool parseAtOnce) :
/**
* Parses a date/time expression.
*
- * Syntax: { "now" | <date> [<time>] | <time> } [ { '+' | '-' } <second expr>]
- * | <second expr>
+ * Syntax: { "now" | DATE [TIME] | TIME } [ { '+' | '-' } SECOND_EXPR]
+ * | SECOND_EXPR
* @param expr expression to parse, e.g. "now+3weeks-5*30days"
* @return start of the epoche: no valid input<br>
* othewise: the calculated date/time
/**
* Calculates time expressions.
*
- * Syntax: { "now" | <date> [<time>] | <time> } [ { '+' | '-' } <second expr>]
- * | <second expr>
+ * Syntax: { "now" | DATE [TIME] | TIME } [ { '+' | '-' } SECOND_EXPR]
+ * | SECOND_EXPR
* Example: now+3weeks-5*30days
*/
class ReDateTimeParser: public ReUnitParser {
LOC_READ_1 = LOC_FIRST_OF(LOC_RANDOMIZER), // 12201
LOC_DECODE_CONTENT_1, // 12202
LOC_DECODE_CONTENT_2, // 12203
+ LOC_UPDATE_1, // 22204
};
const char ReNameScrambler::ESC = '%';
const int ReNameScrambler::m_countNodeChars =
sizeof ReNameScrambler::m_nodeChars;
+
+/**
+ * Contructor.
+ *
+ * @param factor
+ * @param increment
+ */
+ReHmHash64::ReHmHash64(int64_t factor, int64_t increment) :
+ m_factor(factor),
+ m_increment(increment),
+ m_hash(0),
+ m_sumLength(0),
+ m_closed(false),
+ m_littleEndian(true)
+{
+ int src = 1;
+ int trg = 0;
+ memcpy(&trg, &src, 1);
+ m_littleEndian = trg != 0;
+}
+
+/**
+ * Return the hash value as 64 bit integer.
+ *
+ * @return the hash value as 64 bit integer
+ */
+int64_t ReHmHash64::digestAsInt()
+{
+ if (! m_closed){
+ m_closed = true;
+ m_hash ^= (m_sumLength ^ 0x2011195811081965L) * m_factor
+ + (m_increment >> m_sumLength % 29);
+ }
+ return m_hash;
+}
+
+/**
+ * Returns the hash value as byte array.
+ *
+ * @return the hash value as byte array, stored in "little endian" byte order
+ */
+QByteArray ReHmHash64::digest()
+{
+ QByteArray rc;
+ rc.resize(sizeof m_hash);
+ int64_t value = digestAsInt();
+ if (m_littleEndian){
+ * (int64_t*) rc.data() = value;
+ } else {
+ memcpy(rc.data(), &value, sizeof m_hash);
+ }
+ return rc;
+}
+
+/**
+ * Returns the hash value as hex string.
+ * @return the hash value as hex string, stored in "big endian" byte order
+ */
+QByteArray ReHmHash64::hexDigest()
+{
+ QByteArray rc;
+ int size = sizeof m_hash * 2;
+ rc.reserve(size);
+ rc = QByteArray::number((qlonglong) digestAsInt(), 16);
+ if (rc.length() != size)
+ rc.insert(0, QByteArray("0000000000000000").mid(0, size - rc.length()));
+ return rc;
+}
+
+/**
+ * Resets the hash.
+ *
+ * The state is equal after the constructor.
+ */
+void ReHmHash64::reset(){
+ m_hash = m_sumLength = 0;
+ m_closed = false;
+}
+
+/**
+ * Sets the flag "handle as little endian".
+ *
+ * @param littleEndian <code>true</code>: the byte order is "little endian"
+ */
+void ReHmHash64::setLittleEndian(bool littleEndian)
+{
+ m_littleEndian = littleEndian;
+}
+
+/**
+ * Adds the content of a block to the hash.
+ *
+ *
+ * @param source the data block which will be added to the hash
+ * @param length the length of the data (in bytes)
+ */
+void ReHmHash64::update(void* source, size_t length)
+{
+#define CalcNextHash(data) m_hash ^= (data ^ 0x2004199111121989L) \
+ * m_factor + (m_increment >> (data % 23))
+ int64_t data;
+ if (m_sumLength % sizeof m_hash != 0)
+ ReLogger::logv(LOG_ERROR, LOC_UPDATE_1,
+ "ReHmHash64::update() non last block called with wrong length: %d",
+ m_sumLength);
+ m_sumLength += length;
+ if (m_littleEndian){
+ const int64_t* src = reinterpret_cast<const int64_t*>(source);
+ for (int ix = length / sizeof m_hash - 1; ix >= 0; ix--){
+ data = *src++;
+ CalcNextHash(data);
+ }
+ int rest = length % sizeof m_hash;
+ if (rest > 0){
+ data = 0;
+ memcpy(&data, src, rest);
+ data <<= sizeof m_hash - rest;
+ CalcNextHash(data);
+ }
+ } else {
+ const int8_t* src = reinterpret_cast<const int8_t*>(source);
+ for (int ix = length / sizeof m_hash - 1; ix >= 0; ix--){
+ data = 0;
+ for (int ix2 = 0; ix2 < 8; ix2++)
+ data |= (*src++ << ix2 * 8);
+ CalcNextHash(data);
+ }
+ int rest = length % sizeof m_hash;
+ if (rest > 0){
+ data = 0;
+ memcpy(&data, src, rest);
+ data <<= sizeof m_hash - rest;
+ CalcNextHash(data);
+ }
+ }
+}
+
/**
* @brief Constructor.
*
* @param name the name of the generator
*/
ReRandomizer::ReRandomizer(const char* name) :
- m_name(name),
- m_counter(0){
+ m_name(name),
+ m_counter(0){
}
/**
* @brief Destructor.
/**
* Encodes a block of file content.
*
- * @param first <code>true</code>: this is the first block of the file
* @param source the source block
* @param target OUT: the target block<br>
* Can be identical to <code>source</code> (in place replacement)
* Method:
* <ul><li>Invert the name without extension (first char becomes the last),
* add the extension</li>
- * <li>Replace the "unconvertable" chars (> 127) into "%xx" ('%' with 2 hexdigits)</li>
+ * <li>Replace the "unconvertable" chars (< 127) into "%xx" ('%' with 2 hexdigits)</li>
* <li>exchange the char with a value generated by the pseudo random generator</li>
* </ul>
- * @param name clear text filename
+ * @param node clear text filename
* @return the encrypted filename
*/
QByteArray& ReNameScrambler::encodeName(const QByteArray& node) {
}
+
#ifndef RANDOMIZER_H_
#define RANDOMIZER_H_
+/**
+ * Pure abstract base class for hash generators.
+ */
+class ReDigest {
+public:
+ /** Returns the hash value as byte array.
+ * @return the hash value as byte array, stored in "little endian" byte order
+ */
+ virtual QByteArray digest() = 0;
+ /** Returns the hash value as hex string.
+ * @return the hash value as hex string, stored in "little endian" byte order
+ */
+ virtual QByteArray hexDigest() = 0;
+ /** Resets the hash.
+ * The state is equal after the constructor.
+ */
+ virtual void reset() = 0;
+ /** Adds the content of a block to the hash.
+ * @param source the data block which will be added to the hash
+ * @param length the length of the data (in bytes)
+ */
+ virtual void update(void* source, size_t length) = 0;
+};
+
+/**
+ * Implements a very simple (and cheap) checksum.
+ */
+class ReHmHash64 : ReDigest{
+public:
+ ReHmHash64(int64_t factor = 0x70cf79d585f5a313L,
+ int64_t increment = 0x75c280b9881252dbL);
+public:
+ int64_t digestAsInt();
+public:
+ virtual QByteArray digest();
+ virtual QByteArray hexDigest();
+ virtual void reset();
+ virtual void setLittleEndian(bool littleEndian);
+ virtual void update(void* source, size_t length);
+
+private:
+ int64_t m_factor;
+ int64_t m_increment;
+ int64_t m_hash;
+ int64_t m_sumLength;
+ bool m_closed;
+ bool m_littleEndian;
+};
+
/**
* This implements an abstract base class for random generators.
*/
/**
* A simple pseudo random generator simular to <code>ReCongruentialGenerator</code>.
*
- * Difference: An array of seeds is used (round robin)</code>.
+ * Difference: An array of seeds is used (round robin).
*/
class ReMultiCongruentialGenerator: public ReMultiSeedRandomizer,
public ReCongruentialGeneratorBase {
/** @file
* @brief Missed operations for <code>QByteArray</code>s.
*/
-/** @file base/ReStringUtil.cpp
+/** @file base/ReStringUtils.cpp
*
* @brief Definitions for missed operations for <code>QByteArray</code>s.
*/
#include "base/rebase.hpp"
-/** @class ReStringUtil ReStringUtil.hpp "base/ReStringUtil.hpp"
+/** @class ReStringUtil ReStringUtils.hpp "base/ReStringUtils.hpp"
*
* @brief Implements some services around strings.
*
* @param charOf a string containing all member characters of the char set.
* @param indexOf an array containing the index of the char at the position
* of the char, starting with the minimum character
+ * @param minChar the lowest character of the set
+ * @param maxChar the highest character of the set
* @param count -1: strlen(charOf) is taken<br>
*
* otherwise: the length of charOf[]
};
/**
- * @class ReTerminator ReTerminator.hpp "rplcore/ReTerminator.hpp"
+ * @class ReTerminator ReTerminator.hpp "base/ReTerminator.hpp"
*
* @brief Implements a thread stopper.
*
/** @file
* @brief A testing tool like JUnit.
*/
-/** @file rplcore/rpltest.hpp
+/** @file base/ReTest.hpp
*
* @brief Definitions for a testing tool like JUnit.
*/
#include "base/rebase.hpp"
-/** @class ReTest rpltest.hpp "rplcore/repltest"
+/** @class ReTest ReTest.hpp "base/ReTest"
*
* @brief Implements an unit test base class similar JUnit for java.
*
- * Example for usage:
- *
- * @see rplexample.cpp
*/
class ReTest;
m_memoryAppender(1024),
m_memoryLogger() {
m_memoryAppender.setAutoDelete(false);
- m_logger.buildStandardAppender(getTempDir("rpltest"));
+ m_logger.buildStandardAppender(getTempDir("retest"));
log(QByteArray("Start of ") + m_name);
m_memoryLogger.addAppender(&m_memoryAppender);
}
* Implementation of the abstract base class <code>ReWriter</code> and
* the concrete derivation <code>ReFileWriter</code>.
*/
-/** @file rplcore/rplwriter.hpp
+/** @file base/ReWriter.hpp
*
* @brief Definitions for a writer to an output media.
*/
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
int ReWriter::m_maxIndention = strlen(ReWriter::m_tabs);
-/** @class ReWriter ReWriter.hpp "rplcore/ReWriter.hpp"
+/** @class ReWriter ReWriter.hpp "base/ReWriter.hpp"
*
* @brief Implements an abstract base class for producing text lines.
*
writeLine(buffer);
}
-/** @class ReWriter rplwriter.hpp "rplcore/rplwriter.hpp"
+/** @class ReWriter ReWriter.hpp "base/ReWriter.hpp"
*
* @brief Implements a class which writes lines into a file.
*/
printf("MLC: %s\n", rand3.nextString(80, 80, buffer));
printf("KIS: %s\n", rand4.nextString(80, 80, buffer));
}
+ void printHash(const char* source){
+ ReHmHash64 hash;
+ hash.update((void*) source, strlen(source));
+ printf("%-8s: %s\n", source, hash.hexDigest().constData());
+ }
+ void printBinary(int length){
+ QByteArray source;
+ source.fill(0, length);
+ ReHmHash64 hash;
+ hash.update((void*) source.constData(), length);
+ printf("0 x %2d: %s\n",
+ length, hash.hexDigest().constData());
+ }
+
+ void testReHmHash64(){
+ ReHmHash64 hash;
+ hash.update((void*) "12345678abcdefghABC", 8+8+3);
+ int64_t value = hash.digestAsInt();
+ hash.reset();
+ hash.update((void*) "12345678", 8);
+ hash.update((void*) "abcdefgh", 8);
+ hash.update((void*) "ABC", 3);
+ checkEqu(value, hash.digestAsInt());
+
+ printHash("a");
+ printHash("b");
+ printHash("aa");
+ printHash("ab");
+ printHash("aaa");
+ printHash("aab");
+ printHash("aaaa");
+ printHash("aaab");
+ printHash("aaaaaaaa");
+ printHash("aaaaaaab");
+ printHash("aaaaaaba");
+ printHash("aaaaabaa");
+ printHash("aaaabaaa");
+ printHash("aaabaaaa");
+ printHash("aabaaaaa");
+ printHash("abaaaaaa");
+ printHash("baaaaaaa");
+ for (int ix = 0; ix < 16; ix++)
+ printBinary(ix);
+ log("ready");
+ }
void special(){
ReKISSRandomizer rand;
rand.dump();
}
virtual void run(void) {
+ testReHmHash64();
testNextString();
testRealRandom();
testShuffle();
/** @file
* @brief Predefined classes of the virtual machine, e.g ReASInteger.
*/
-/** @file rplexpr/rplasclasses.hpp
+/** @file expr/ReASClasses.hpp
*
* @brief Definitions for predefined classes of the virtual machine.
*/
ReASVoid* ReASVoid::m_instance = NULL;
ReASFormula* ReASFormula::m_instance = NULL;
-/** @class ReSymbolSpace rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReSymbolSpace ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements a symbol space for the parser.
*
return m_name;
}
-/** @class ReASBoolean rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASBoolean ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a Boolean.
*
return ((ReASVariant*) object)->asBool() ? "True" : "False";
}
-/** @class ReASNumber rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNumber ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a Boolean.
*
return buffer;
}
-/** @class ReASInteger rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASInteger ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a Boolean.
*
return buffer;
}
-/** @class ReASString rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASString ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a string.
*
return rc;
}
-/** @class ReASList rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASList ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a list.
*
return rc;
}
-/** @class ReASMap rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASMap ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements the class of a map.
*
return rc;
}
-/** @class ReVariable rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReVariable ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements a variable of a symbol space.
*/
return m_name;
}
-/** @class ReVariable rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReVariable ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements a data type representing a none type.
*/
return QByteArray("");
}
-/** @class ReASFormula rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASFormula ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements a data type representing a calculated value.
*/
return buffer;
}
-/** @class ReASUserClass rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASUserClass ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements a data type representing an user defined class.
*/
return m_position;
}
-/** @class ReASUserObject rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASUserObject ReASClasses.hpp "expr/ReASClasses.hpp"
*
* @brief Implements an instance of an user defined class.
*/
* @brief Implementation of an Abstract Syntax Tree.
*
*/
-/** @file rplexpr/rplastree.hpp
+/** @file expr/ReASTree.hpp
*
* @brief Definitions for an Abstract Syntax Tree.
*
writer.writeLine();
}
-/** @class ReASException rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASException ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a specific exception for the Abstract Syntax Tree.
*/
ReException("") {
}
-/** @class ReASVariant rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASVariant ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a class which can hold the value of any type.
*
m_class = clazz;
}
-/** @class ReASItem rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASItem ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements the abstract base class of all entries of an AST.
*
return false;
}
-/** @class ReASCalculable rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASCalculable ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief An abstract base class for items which calculates a value.
*
m_class = clazz;
}
-/** @class ReASStorable rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASStorable ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements the abstract base class of value containing items.
*
*/
-/** @class ReASConstant rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASConstant ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a constant for the Abstract Syntax Tree.
*
return m_value;
}
-/** @class ReASListConstant rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASListConstant ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a container for constant list entries.
*
return m_value;
}
-/** @class ReASMapConstant rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASMapConstant ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a hash map for constant list entries.
*
return rc;
}
-/** @class ReASNamedValue rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNamedValue ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a named values, a constant or a variable
*/
return m_variableNo;
}
-/** @class ReASConversion rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASConversion ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a data type conversion.
*
return rc;
}
-/** @class ReASIndexedValue rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASIndexedValue ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an indexed values (member of a list)
*
m_child->dump(writer, indent + 1);
}
-/** @class RplVarDefinition rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class RplVarDefinition ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements variable definition for the Abstract Syntax Tree.
*
return 0;
}
-/** @class ReASExprStatement rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASExprStatement ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an statement consisting of an expression.
*
m_child2->dump(writer, indent + 1);
}
-/** @class ReASNode1 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode1 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with one child.
*
}
}
-/** @class ReASNode2 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode2 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with two childs.
*
m_child2 = child2;
}
-/** @class ReASNode3 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode3 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with 3 childs.
*
m_child3 = child3;
}
-/** @class ReASNode4 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode4 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with 3 childs.
*
m_child4 = child4;
}
-/** @class ReASNode5 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode5 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with 4 childs.
*
m_child5 = child5;
}
-/** @class ReASNode6 rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASNode6 ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an inner node of the abstract syntax tree with 4 childs.
*
m_child6 = child6;
}
-/** @class ReASUnaryOp rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASUnaryOp ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an unary operation.
*
return rc;
}
-/** @class ReASStatement rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASStatement ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a base class for all statements.
*
return rc;
}
-/** @class ReASIf rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASIf ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an if statement.
*
m_child4->dump(writer, indent + 1);
}
-/** @class ReASFor rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASFor ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a for statement.
*
dumpStatements(writer, indent + 1, m_child2);
}
-/** @class ReASForCounted rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASForCounted ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a for statement.
*
dumpStatements(writer, indent + 1, m_child2);
}
-/** @class ReASWhile rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASWhile ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a while statement.
*
dumpStatements(writer, indent + 1, m_child3);
}
-/** @class ReASRepeat rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASRepeat ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a while statement.
*
dumpStatements(writer, indent + 1, m_child3);
}
-/** @class ReASClass rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASClass ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements the base class of an Abstract Syntax Tree class.
*
m_symbols = m_tree.currentSpace();
}
-/** @class ReASTree rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASTree ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a manager for all parts of an Abstract Syntax Tree.
*
writer.close();
}
-/** @class ReASMethodCall rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASMethodCall ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a method or function call for the Abstract Syntax Tree.
*
return dynamic_cast<ReASExprStatement*>(m_child2);
}
-/** @class ReASException rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASException ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a call of a method or function.
*
* <code>m_child2</code>: argument list (or NULL)
*/
-/** @class ReASBinaryOp rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASBinaryOp ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements binary operator for the Abstract Syntax Tree.
*
return rc;
}
-/** @class ReASMethod rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASMethod ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements a method definition for the Abstract Syntax Tree.
*
firstParamWithDefault = value;
}
-/** @class ReASField rplastree.hpp "rplexpr/rplastree.hpp"
+/** @class ReASField ReASTree.hpp "expr/ReASTree.hpp"
*
* @brief Implements an class field for the Abstract Syntax Tree.
*
};
-/** @class ReMFParser rpllexer.hpp "rplexpr/rplmfparser.hpp"
+/** @class ReMFParser ReMFParser.hpp "expr/ReMFParser.hpp"
*
* @brief Implements a parser for the language MF.
*
/**
* @brief Constructor.
*
+ * @param caller name of the caller (for debugging)
* @param symbols the symbol space belonging to the stack frame
*/
/**
* Constructor.
- *
- * @param foreground symbolic foreground color
- * @param background symbolic background color
- * @param edit the parent
*/
ReLook::ReLook() :
m_font(NULL),
/**
* Ensures that a given line / column is visible.
*
- * @param firstLine number of the line which should be visible
+ * @param firstLine number of the line which should be visible
+ * @param firstCol the first column which should be visible
*/
void ReEdit::reposition(int firstLine, int firstCol) {
if (firstLine != m_firstLine) {
*
* Example (tab width = 3):
* <pre>
- * "\tz" -> ' z' -> '\t' + ' '
- * "x\tz" -> 'x z' -> '\t' + ' '
- * "xy\tz" -> 'xy z' -> '\t'
+ * "\tz" -> ' z' -> TAB + ' '
+ * "x\tz" -> 'x z' -> TAB + ' '
+ * "xy\tz" -> 'xy z' -> TAB
* </pre>
* @param tabWidth
*/
* @param lineNo the line number of the first line to transfer
* @param count the number of lines to transfer
* @param width width of the screen (in chars)
+ * @param edit the parent (instance of the editor)
*/
void ReParagraphs::load(int lineNo, int count, int width, ReEdit* edit) {
clear();
*
* @param paragraph the paragraph to change
* @param lineNo the line number (0..N-1) of the paragraph in the source
- * @param firstCol the first column of the text (with expanded tabulators)
* @param edit the parent, the edit field
*/
void ReParagraphBuilder::buildParagraph(ReParagraph& paragraph, int lineNo,
* A manipulator of a paragraph.
*
* A <code>ReParagraphBuilder</code> changes the presentation of the given text
- * inside the paragraph. It should <bold>never</bold> change the text!
+ * inside the paragraph. It should <b>never</b> change the text!
*/
class ReParagraphBuilder {
public:
/**
* Constructor.
*
- * @param delay time between first change of setting and storage in seconds
+ * @param file the file to store the settings
+ * @param logger the logger
+ * @param delay time between first change of setting and storage in seconds
*/
ReDelayedStorage::ReDelayedStorage(const QString& file, ReLogger* logger,
int delay) :
* Constructor.
*
* @param filename filename with path of the storage file
+ * @param logger the logger
*/
ReStateStorage::ReStateStorage(const QString& filename, ReLogger* logger) :
m_filename(filename),
* Returns the full name of a widget.
*
* @param name the name of the widget
- * @return <form name> '.' <name> or <name> (if no form name is set)
+ * @return <form name> '.' <name> or <name> (if no form name is set)
*/
QByteArray ReStateStorage::fullname(const char* name) {
QByteArray rc;
*
* @param name the key of the key-value-pair. May be extended by <code>m_form</code>
* @param value the value to store
+ * @param index -1 or the index in the array
*/
void ReStateStorage::store(const char* name, const QString& value, int index) {
if (initForWrite()) {
* Tests whether a point is inside the rectangle (including border).
* @param rect rectangle to test
* @param point point to test
+ * @param what description of the caller
* @return <code>true</code>: the point lays inside the rectangle
*/
inline bool rectContains(const QRect& rect, const QPoint& point,
*
* @param row the row number
* @param withNode true: the node will be appended to the result
- * @param uriFormat true: example: file:///u:/tmp/file.txt<br>
- * false: example: u:\tmp\file.txt
+ * @param uriFormat true: example: "file:///u:/tmp/file.txt"<br>
+ * false: example: "u:\\tmp\\file.txt"
* @return the absolute path of the file given by the row
*/
QString ReFileTable::buildAbsPath(int row, bool withNode, bool uriFormat){
/**
* Fills the table with the file data of the filesystem.
- *
- * @param table OUT: table to fill
*/
void ReFileTable::fillTable()
{
/**
* Handles the double click of a table cell.
*
- * @param index the abstract index of the cell
+ * @param row the row of the cell has been clicked
+ * @param column the column of the cell has been clicked
*/
void ReFileTable::tableDoubleClicked(int row, int column){
openEntry(row);
/** @file
* @brief Implements 2 dimensional matrices.
*/
-/** @file rplmath/rplmatrix.hpp
+/** @file math/ReMatrix.hpp
*
* @brief Definitions for 2 dimensional matrices.
*/
+++ /dev/null
-/*
- * ReTCPClient.cpp
- *
- * License: Public Domain
- * You can use and modify this file without any restriction.
- * Do what you want.
- * No warranties and disclaimer of any damages.
- * You also can use this license: http://www.wtfpl.net
- * The latest sources: https://github.com/republib
- */
-#include "base/rebase.hpp"
-#include "math/remath.hpp"
-#include "net/renet.hpp"
-
-enum {
- LOC_1 = LOC_FIRST_OF(LOC_TCPCLIENT), // 10701
- LOC_HANDLE_ERROR_1,
- LOC_SET_REMOTE_ADDRESS_1,
-};
-
-/** @class RplTcpClient rpltcpclient.hpp "rplnet/rpltcpclient.hpp"
- *
- * @brief Implements a TCP client.
- *
- * Use the protocol defined at <code>ReTCPServer</code>.
- */
-/**
- * @brief Constructor.
- *
- * @param configurator some parameters will be get from this configurator
- * @param thread current thread. Used for <code>sleep()</code>
- * @param terminator NULL or for controlled termination
- * @param logger a logger
- */
-RplTcpClient::RplTcpClient(ReConfigurator& configurator, QThread* thread,
- ReTerminator* terminator, ReLogger* logger) :
- m_peer(new ReTCPPeer(configurator, thread, terminator, false, logger)),
- m_logger(logger),
- m_configurator(configurator) {
- QByteArray ip = configurator.asString(ReNetConfig::IP, "localhost");
- int port = configurator.asInt(ReNetConfig::PORT, 12345);
- if (!ip.isEmpty() && port != 0)
- setRemoteAddress(ip.constData(), port);
-}
-
-/**
- * @brief Destructor.
- */
-RplTcpClient::~RplTcpClient() {
- delete m_peer;
- m_peer = NULL;
-}
-
-/**
- * @brief Defines the remote address for a client.
- * @param ip NULL or the ip to connect
- * @param port 0 or the port to connect
- */
-void RplTcpClient::setRemoteAddress(const char* ip, int port) {
- QTcpSocket* socket = (QTcpSocket*) m_peer->getSocket();
- delete socket;
- if (ip == NULL || port == 0)
- m_peer->setSocket(NULL);
- else {
- socket = new QTcpSocket();
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
- SLOT(handleError(QAbstractSocket::SocketError)));
- m_peer->setSocket(socket);
- m_peer->setAddress(ip, port);
- m_logger->logv(LOG_INFO, LOC_SET_REMOTE_ADDRESS_1, "connect with %s:%d",
- ip, port);
- socket->connectToHost(ReString(ip), port);
- socket->waitForConnected();
- }
-}
-
-/**
- * @brief Returns the peer info.
- * @return the peer info
- */
-ReTCPPeer* RplTcpClient::getPeer() const {
- return m_peer;
-}
-
-/**
- * @brief Handles a network error.
- *
- * @param socketError the error code
- */
-void RplTcpClient::handleError(QAbstractSocket::SocketError socketError) {
- if (m_logger != NULL)
- m_logger->logv(LOG_ERROR, LOC_HANDLE_ERROR_1, "Network error %d",
- socketError);
-}
-
-/** @class RplClientThread rpltcpclient.hpp "rplnet/rpltcpclient.hpp"
- *
- * @brief Implements a thread usable for a tcp client.
- *
- * Each <code>ReTCPPeer</code> needs a thread. Therefore this class provides all things
- * needed for a <code>RplTcpClient</code> which uses a <code>ReTCPPeer</code>.
- */
-
-/**
- * @brief Constructor.
- *
- * @param configurator delivers some connection parameters
- * @param logger the logger. If NULL a default logger will be used
- */
-RplClientThread::RplClientThread(ReConfigurator& configurator, ReLogger* logger) :
- m_client(NULL),
- m_logger(logger),
- m_configurator(configurator),
- m_ownsLogger(false) {
- m_client = new RplTcpClient(configurator, this, NULL, logger);
-}
-/**
- * @brief Destructor.
- */
-RplClientThread::~RplClientThread() {
- delete m_client;
- m_client = NULL;
- if (m_ownsLogger) {
- delete m_logger;
- m_logger = NULL;
- }
-}
-/**
- * @brief Returns the peer which can be used for sending and receiving messages.
- *
- * @return the peer
- */
-ReTCPPeer* RplClientThread::getPeer() const {
- return m_client->getPeer();
-}
-
-/**
- * @brief Returns the logger of the thread.
- * @return the logger
- */
-ReLogger* RplClientThread::getLogger() const {
- return m_logger;
-}
-
-/**
- * @brief Contains the main method of the thread.
- *
- * Calls <code>doIt()</code> for the real things.
- */
-void RplClientThread::run() {
- doIt();
-}
+++ /dev/null
-/*
- * ReTCPClient.hpp
- *
- * License: Public Domain
- * You can use and modify this file without any restriction.
- * Do what you want.
- * No warranties and disclaimer of any damages.
- * You also can use this license: http://www.wtfpl.net
- * The latest sources: https://github.com/republib
- */
-#ifndef RETCPCLIENT_HPP
-#define RETCPCLIENT_HPP
-
-#ifndef REBASE_HPP
-#include "base/rebase.hpp"
-#include "math/remath.hpp"
-#include "net/renet.hpp"
-#endif
-
-class ReTCPPeer;
-
-class RplTcpClient: public QObject {
- Q_OBJECT
-public:
- RplTcpClient(ReConfigurator& configurator, QThread* thread,
- ReTerminator* terminator, ReLogger* logger = NULL);
- virtual ~RplTcpClient();
-private:
- // No copy constructor: no implementation!
- RplTcpClient(const RplTcpClient& source);
- // Prohibits assignment operator: no implementation!
- RplTcpClient& operator =(const RplTcpClient& source);
-public:
- ReTCPPeer* getPeer() const;
-private:
- void setRemoteAddress(const char* ip, int port);public slots:
- void handleError(QAbstractSocket::SocketError socketError);
-private:
- ReTCPPeer* m_peer;
- ReLogger* m_logger;
- ReConfigurator& m_configurator;
-};
-
-class RplClientThread: public QThread {
-public:
- RplClientThread(ReConfigurator& configurator, ReLogger* logger = NULL);
- virtual ~RplClientThread();
-private:
- // No copy constructor: no implementation!
- RplClientThread(const RplClientThread& source);
- // Prohibits the assignment operator. Not implemented!
- RplClientThread& operator=(const RplClientThread& source);
-public:
- /**
- * @brief Does the main task of the thread.
- *
- * Will be called from <code>QThread::run()</code>.
- * The implementations of this abstract method should be call <code>getPeer()</code>
- * to send and receive messages.
- */
- virtual void doIt() = 0;
- ReTCPPeer* getPeer() const;
- ReLogger* getLogger() const;
-private:
- virtual void run();
-protected:
- RplTcpClient* m_client;
- ReLogger* m_logger;
- ReConfigurator& m_configurator;
-private:
- bool m_ownsLogger;
-};
-
-#endif // RETCPCLIENT_HPP
static int s_dummy = 0;
-/** @class ReTCPPeer rpltcppeer.hpp "rplnet/rpltcppeer.hpp"
+/** @class ReTCPPeer ReTCPPeer.hpp "net/ReTCPPeer.hpp"
*
* @brief Implements the common things for TCP server and client.
*
LOC_TCP_INCOMING_CONNECTION_1,
};
-/** @class ReTCPThread rpltcpserver.hpp "rplcore/rpltcpserver.hpp"
+/** @class ReTCPThread ReTCPServer.hpp "net/ReTCPServer.hpp"
*
* @brief Serves one connection of a multihreaded TCP server.
*
return m_socketDescriptor;
}
-/** @class ReTCPServer rpltcpserver.hpp "rplcore/rpltcpserver"
+/** @class ReTCPServer ReTCPServer.hpp "base/ReTCPServer.hpp"
*
* @brief Implements a multithreaded TCP server.
*/
thread->start();
}
-/** @class ReTCPThread rpltcpserver.hpp "rplcore/rpltcpserver.hpp"
+/** @class ReTCPThread ReTCPServer.hpp "net/ReTCPServer.hpp"
*
* @brief Defines a function pointer type to create a <code>ReTCPThread</code> instance.
*
*/
-/** @class ReTaskHandler rpltcpserver.hpp "rplcore/rpltcpserver.hpp"
+/** @class ReTaskHandler ReTCPServer.hpp "net/ReTCPServer.hpp"
*
* @brief An abstract base class for an handler processing an data unit.
*
--- /dev/null
+/*
+ * ReTCPClient.cpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+#include "base/rebase.hpp"
+#include "math/remath.hpp"
+#include "net/renet.hpp"
+
+enum {
+ LOC_1 = LOC_FIRST_OF(LOC_TCPCLIENT), // 10701
+ LOC_HANDLE_ERROR_1,
+ LOC_SET_REMOTE_ADDRESS_1,
+};
+
+/** @class RplTcpClient ReTcpClient.hpp "net/ReTcpClient.hpp"
+ *
+ * @brief Implements a TCP client.
+ *
+ * Use the protocol defined at <code>ReTCPServer</code>.
+ */
+/**
+ * @brief Constructor.
+ *
+ * @param configurator some parameters will be get from this configurator
+ * @param thread current thread. Used for <code>sleep()</code>
+ * @param terminator NULL or for controlled termination
+ * @param logger a logger
+ */
+RplTcpClient::RplTcpClient(ReConfigurator& configurator, QThread* thread,
+ ReTerminator* terminator, ReLogger* logger) :
+ m_peer(new ReTCPPeer(configurator, thread, terminator, false, logger)),
+ m_logger(logger),
+ m_configurator(configurator) {
+ QByteArray ip = configurator.asString(ReNetConfig::IP, "localhost");
+ int port = configurator.asInt(ReNetConfig::PORT, 12345);
+ if (!ip.isEmpty() && port != 0)
+ setRemoteAddress(ip.constData(), port);
+}
+
+/**
+ * @brief Destructor.
+ */
+RplTcpClient::~RplTcpClient() {
+ delete m_peer;
+ m_peer = NULL;
+}
+
+/**
+ * @brief Defines the remote address for a client.
+ * @param ip NULL or the ip to connect
+ * @param port 0 or the port to connect
+ */
+void RplTcpClient::setRemoteAddress(const char* ip, int port) {
+ QTcpSocket* socket = (QTcpSocket*) m_peer->getSocket();
+ delete socket;
+ if (ip == NULL || port == 0)
+ m_peer->setSocket(NULL);
+ else {
+ socket = new QTcpSocket();
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
+ SLOT(handleError(QAbstractSocket::SocketError)));
+ m_peer->setSocket(socket);
+ m_peer->setAddress(ip, port);
+ m_logger->logv(LOG_INFO, LOC_SET_REMOTE_ADDRESS_1, "connect with %s:%d",
+ ip, port);
+ socket->connectToHost(ReString(ip), port);
+ socket->waitForConnected();
+ }
+}
+
+/**
+ * @brief Returns the peer info.
+ * @return the peer info
+ */
+ReTCPPeer* RplTcpClient::getPeer() const {
+ return m_peer;
+}
+
+/**
+ * @brief Handles a network error.
+ *
+ * @param socketError the error code
+ */
+void RplTcpClient::handleError(QAbstractSocket::SocketError socketError) {
+ if (m_logger != NULL)
+ m_logger->logv(LOG_ERROR, LOC_HANDLE_ERROR_1, "Network error %d",
+ socketError);
+}
+
+/** @class RplClientThread ReTcpClient.hpp "net/ReTcpClient.hpp"
+ *
+ * @brief Implements a thread usable for a tcp client.
+ *
+ * Each <code>ReTCPPeer</code> needs a thread. Therefore this class provides all things
+ * needed for a <code>RplTcpClient</code> which uses a <code>ReTCPPeer</code>.
+ */
+
+/**
+ * @brief Constructor.
+ *
+ * @param configurator delivers some connection parameters
+ * @param logger the logger. If NULL a default logger will be used
+ */
+RplClientThread::RplClientThread(ReConfigurator& configurator, ReLogger* logger) :
+ m_client(NULL),
+ m_logger(logger),
+ m_configurator(configurator),
+ m_ownsLogger(false) {
+ m_client = new RplTcpClient(configurator, this, NULL, logger);
+}
+/**
+ * @brief Destructor.
+ */
+RplClientThread::~RplClientThread() {
+ delete m_client;
+ m_client = NULL;
+ if (m_ownsLogger) {
+ delete m_logger;
+ m_logger = NULL;
+ }
+}
+/**
+ * @brief Returns the peer which can be used for sending and receiving messages.
+ *
+ * @return the peer
+ */
+ReTCPPeer* RplClientThread::getPeer() const {
+ return m_client->getPeer();
+}
+
+/**
+ * @brief Returns the logger of the thread.
+ * @return the logger
+ */
+ReLogger* RplClientThread::getLogger() const {
+ return m_logger;
+}
+
+/**
+ * @brief Contains the main method of the thread.
+ *
+ * Calls <code>doIt()</code> for the real things.
+ */
+void RplClientThread::run() {
+ doIt();
+}
--- /dev/null
+/*
+ * ReTCPClient.hpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+#ifndef RETCPCLIENT_HPP
+#define RETCPCLIENT_HPP
+
+#ifndef REBASE_HPP
+#include "base/rebase.hpp"
+#include "math/remath.hpp"
+#include "net/renet.hpp"
+#endif
+
+class ReTCPPeer;
+
+class RplTcpClient: public QObject {
+ Q_OBJECT
+public:
+ RplTcpClient(ReConfigurator& configurator, QThread* thread,
+ ReTerminator* terminator, ReLogger* logger = NULL);
+ virtual ~RplTcpClient();
+private:
+ // No copy constructor: no implementation!
+ RplTcpClient(const RplTcpClient& source);
+ // Prohibits assignment operator: no implementation!
+ RplTcpClient& operator =(const RplTcpClient& source);
+public:
+ ReTCPPeer* getPeer() const;
+private:
+ void setRemoteAddress(const char* ip, int port);public slots:
+ void handleError(QAbstractSocket::SocketError socketError);
+private:
+ ReTCPPeer* m_peer;
+ ReLogger* m_logger;
+ ReConfigurator& m_configurator;
+};
+
+class RplClientThread: public QThread {
+public:
+ RplClientThread(ReConfigurator& configurator, ReLogger* logger = NULL);
+ virtual ~RplClientThread();
+private:
+ // No copy constructor: no implementation!
+ RplClientThread(const RplClientThread& source);
+ // Prohibits the assignment operator. Not implemented!
+ RplClientThread& operator=(const RplClientThread& source);
+public:
+ /**
+ * @brief Does the main task of the thread.
+ *
+ * Will be called from <code>QThread::run()</code>.
+ * The implementations of this abstract method should be call <code>getPeer()</code>
+ * to send and receive messages.
+ */
+ virtual void doIt() = 0;
+ ReTCPPeer* getPeer() const;
+ ReLogger* getLogger() const;
+private:
+ virtual void run();
+protected:
+ RplTcpClient* m_client;
+ ReLogger* m_logger;
+ ReConfigurator& m_configurator;
+private:
+ bool m_ownsLogger;
+};
+
+#endif // RETCPCLIENT_HPP
#include "base/rebase.hpp"
#include "os/reos.hpp"
+/**
+ * @file
+ *
+ * Format of a file (on the hosted FS):
+ * <pre> random (8 byte)
+ * checksum (from offset 16) (8 byte, encrypted with resetted random)
+ * marker (2 byte, encrypted with resetted random)
+ * flags (2 byte) see ReFileHeaderOptions
+ * reserved (4 byte)
+ * encrypted file content
+ * checksum of the original file content
+ * </pre>
+ * Checksum: sum_n ^= content_n * FAC + INC,
+ * operands 8 byte signed integer, little endian
+ * missing bytes (to 8 byte boundary) are padded with 0
+ * FAC=0x7b644ac5d1187d25, INC=0x6b85115d6064365b
+ */
enum {
LOC_ADD_ENTRY_1 = LOC_FIRST_OF(LOC_CRYPTFILESYSTEM), // 12301
LOC_REMOVE_ENTRY_1, // 12302
LOC_READ_META_FILE_3, // 12305
LOC_WRITE_META_1, // 12306
LOC_WRITE_META_2, // 12307
+ LOC_MAKE_DIR_1, // 12308
};
const int ReCryptFileSystem::NODE_LENGHT = 44;
-const int ReCryptFileSystem::MARKER_LENGHT = 4;
+const int ReCryptFileSystem::MARKER_LENGHT = 2;
const int ReCryptFileSystem::CHECKSUM_LENGHT = 16;
const int ReCryptFileSystem::HEADER_LENGTH = sizeof(int64_t)
+ ReCryptFileSystem::NODE_LENGHT
*
* @param hostFileSystem the filesystem which does the storage (with
* encrypted names and content
- * @param nameRandom a pseudo random generator for names
* @param contentRandom a pseudo random generator for content
+ * @param logger the logger
*/
ReCryptFileSystem::ReCryptFileSystem(ReFileSystem& hostFileSystem,
ReRandomizer& contentRandom, ReLogger* logger) :
ReCryptFileSystem::~ReCryptFileSystem() {
}
+QString ReCryptFileSystem::canonicalPathOf(const QString& path)
+{
+ return ReFileUtils::cleanPath(path);
+}
+
/** Frees resources like open files.
*/
void ReCryptFileSystem::close()
{
}
+/**
+ * Tests whether a file exists in the current directory.
+ *
+ * @param node filename without path
+ * @param metaInfo OUT: info of the found file. May be NULL
+ * @return
+ */
+bool ReCryptFileSystem::exists(const QString& node, ReFileMetaData* metaInfo) const
+{
+ const ReFileMetaData* info = find(node);
+ bool rc = info != NULL;
+ if (rc && metaInfo != NULL)
+ *metaInfo = *info;
+ return rc;
+}
+
/**
* Fills a list with the items of the current directory.
*
- * @param matcher the matching processor
+ * @param matcher the matching processor for selecting the files
+ * @param list OUT: the list of the found files
+ * @param options options to define what kind of files should be found
* @return the count of the found entries (<code>list.size()</code>)
*/
int ReCryptFileSystem::listInfos(const ReIncludeExcludeMatcher& matcher,
- ReFileMetaDataList& list, ListOptions options) {
- return 0;
+ ReFileMetaDataList& list, ListOptions options) {
+ ReFileMetaDataList::const_iterator it;
+ bool withDirs = (options & LO_DIRS) != 0;
+ bool withFiles = (options & LO_FILES) != 0;
+ bool filterDirs = (options & LO_NAME_FILTER_FOR_DIRS);
+ list.clear();
+ for (it = m_list.cbegin(); it != m_list.cend(); ++it){
+ bool isDir = S_ISDIR(it->m_mode);
+ if ( (isDir && ! withDirs) || (! isDir && ! withFiles))
+ continue;
+ if ((! filterDirs && isDir) || matcher.matches(it->m_node))
+ list.append(*it);
+ }
+ return list.length();
}
/**
* @return EC_SUCCESS or error code
*/
ReFileSystem::ErrorCode ReCryptFileSystem::makeDir(const QString& node) {
- return EC_SUCCESS;
+ ReFileMetaData file;
+ ErrorCode rc = EC_SUCCESS;
+ if (exists(node, &file)){
+ if ((S_ISDIR(file.m_mode)))
+ rc = EC_DIR_ALREADY_EXISTS;
+ else
+ rc = EC_FILE_ALREADY_EXISTS;
+ } else {
+ QDateTime now = QDateTime::currentDateTime();
+ int id = ++m_maxFileId;
+ QString hostName = buildHostedNode(id);
+ ErrorCode rc2 = m_host.makeDir(hostName);
+ if (rc2 != EC_SUCCESS){
+ m_logger2->logv(LOG_ERROR, LOC_MAKE_DIR_1, "cannot create hosted directory %s: %s",
+ hostName.toUtf8().constData(),
+ errorMessage(rc2).toUtf8().constData());
+ rc = EC_REMOTE_MKDIR;
+ } else {
+ m_list.append(ReFileMetaData(node, now, now, m_osPermissions.m_user,
+ m_osPermissions.m_group, m_osPermissions.m_dirMode, 0,
+ id));
+ m_changed = true;
+ }
+ }
+ return rc;
}
/**
/**
* Writes a buffer to a file.
*
- * @param node the file to write (without path, inside the current directory)
+ * @param target the file to write (without path, inside the current directory)
* @param offset first position to write
* @param buffer content to write
* @return EC_SUCCESS or error code
/**
* Constructor
*
- * @param parent the parent filesystem
- * @param logger the logger
+ * @param contentRandom the pseudo random generator uses for encryption
+ * @param parent the hosting filesystem
+ * @param logger the logger
*/
ReCryptDirectory::ReCryptDirectory(ReRandomizer& contentRandom,
ReCryptFileSystem* parent, ReLogger* logger) :
m_list(),
m_parent(parent),
m_changed(false),
- m_logger(logger),
+ m_logger2(logger),
m_currentNode(),
m_fileBuffer(),
m_entryBuffer(),
ReFileMetaDataList m_list;
ReCryptFileSystem* m_parent;
bool m_changed;
- ReLogger* m_logger;
+ // to avoid ambigousity:
+ ReLogger* m_logger2;
QString m_currentNode;
QByteArray m_fileBuffer;
QByteArray m_entryBuffer;
ReRandomizer& contentRandom, ReLogger* logger);
~ReCryptFileSystem();
public:
+ virtual QString canonicalPathOf(const QString& path);
virtual void close();
+ virtual bool exists(const QString& node, ReFileMetaData* metaInfo) const;
virtual int listInfos(const ReIncludeExcludeMatcher& matcher,
ReFileMetaDataList& list, ListOptions options = LO_UNDEF);
virtual ErrorCode makeDir(const QString& node);
* Constructor.
*
* @param name the name of the filesystem
+ * @param logger the logger
*/
ReFileSystem::ReFileSystem(const QString& name, ReLogger* logger) :
m_name(name),
case EC_POSITION:
rc = QObject::tr("cannot set new file position");
break;
- case EC_ALREADY_EXISTS:
+ case EC_FILE_ALREADY_EXISTS:
rc = QObject::tr("file already exists");
break;
case EC_NOT_EXISTS:
case EC_MARKER:
rc = QObject::tr("marker mismatch");
break;
+ case EC_DIR_ALREADY_EXISTS:
+ rc = QObject::tr("directory already exists");
+ break;
+ case EC_REMOTE_MKDIR:
+ rc = QObject::tr("remote directory cannot be built");
+ break;
default:
rc = QObject::tr("unknown error code: ") + QString::number(errorCode);
break;
}
}
+/**
+ * Search a file in the current directory given by name.
+ *
+ * @param node the filename without path
+ * @param metaData OUT: the info of the found file. May be NULL
+ * @return <code>true</code>: the file was found
+ */
+bool ReLocalFileSystem::exists(const QString& node, ReFileMetaData* metaData) const
+{
+ QByteArray full;
+ full.resize(m_directory.length() + 10 + node.length());
+ full = m_directory.toUtf8();
+ full.append(node.toUtf8());
+ struct stat info;
+ bool rc = stat(full.constData(), &info) != 0;
+ if (rc && metaData != NULL){
+ metaData->m_node = node;
+ metaData->m_modified = QDateTime::fromTime_t(info.st_mtime);
+ metaData->m_created = QDateTime::fromTime_t(info.st_ctime);
+ metaData->m_owner = info.st_uid;
+ metaData->m_group = info.st_gid;
+ metaData->m_mode = info.st_mode;
+ metaData->m_size = info.st_size;
+ }
+ return rc;
+}
+
/**
* Fills a list with the items of the current directory.
*
} else if (m_dir.exists(node)) {
m_logger->logv(LOG_ERROR, LOC_MAKE_DIR_2, "node exists already: %s",
fullNameAsUTF8(node).constData());
- rc = EC_ALREADY_EXISTS;
+ rc = EC_FILE_ALREADY_EXISTS;
} else if (!m_dir.mkdir(node)) {
m_logger->logv(LOG_ERROR, LOC_MAKE_DIR_2, "cannot create directory: %s",
fullNameAsUTF8(node).constData());
if (m_dir.exists(source.m_node)) {
if (name.length() == 0)
name = fullNameAsUTF8(target.m_node);
- rc = EC_ALREADY_EXISTS;
+ rc = EC_FILE_ALREADY_EXISTS;
m_logger->logv(LOG_ERROR, LOC_SET_PROPERTIES_2,
"renaming impossible: node exists: %s",
name.constData());
* @param group the group of the file (GID)
* @param mode rights and attributs of the file
* @param size the filesize (0 for directories)
+ * @param id an identifier of the file unique inside the directory
*/
ReFileMetaData::ReFileMetaData(const QString& node, const QDateTime& modified,
const QDateTime& created, int owner, int group, mode_t mode, int64_t size,
EC_NOT_WRITEABLE,
EC_WRITE,
EC_POSITION,
- EC_ALREADY_EXISTS,
+ EC_FILE_ALREADY_EXISTS,
EC_NOT_EXISTS,
EC_RENAME,
EC_HEADER_LENGTH,
EC_MARKER,
+ EC_DIR_ALREADY_EXISTS,
+ EC_REMOTE_MKDIR,
};
public:
* @return the name of the current directory
*/
virtual const QString& directory() const;
+ /** Search a file in the current directory given by name.
+ * @param node the filename without path
+ * @param metaData OUT: the info of the found file. May be NULL
+ * @return <code>true</code>: the file was found
+ */
+ virtual bool exists(const QString& node, ReFileMetaData* metaData = NULL)
+ const = 0;
/** Fills a list with the items of the current directory.
* @param matcher the matching processor
+ * @param list OUT: the found files
* @param options a set (bitmap) of options, e.g. LO_FILES | LO_DIRS
* @return the count of the found entries (<code>list.size()</code>)
*/
virtual int listInfos(const ReIncludeExcludeMatcher& matcher,
- ReFileMetaDataList& list, ListOptions opts
+ ReFileMetaDataList& list, ListOptions options
= ListOptions(LO_FILES | LO_DIRS )) = 0;
/** Creates a directory.
* @param node the name without path (in the current directory)
virtual ErrorCode setProperties(const ReFileMetaData& source,
ReFileMetaData& target, bool force) = 0;
/** Writes a buffer to a file.
- * @param node the file to write (without path, inside the current directory)
+ * @param target the file to write (without path, inside the current directory)
* @param offset first position to write
* @param buffer content to write
* @return EC_SUCCESS or error code
virtual QString canonicalPathOf(const QString& path);
// ReFileSystem interface
virtual void close();
+ virtual bool exists(const QString& node, ReFileMetaData* metaData = NULL) const;
virtual int listInfos(const ReIncludeExcludeMatcher& matcher,
ReFileMetaDataList& list, ListOptions options);
ErrorCode makeDir(const QString& node);
* Tests whether an entry matches the conditions of the filter.
*
* @param entry entry to test
- * @return <true>: the entry matches the conditions of the filter<br>
- * <false>: otherwise
+ * @return <code>true</code>: the entry matches the conditions of the filter<br>
+ * <code>false</code>: otherwise
*/
bool ReDirEntryFilter::match(ReDirStatus_t& entry) {
bool rc = false;
* @param append <code>true</code>: the string will be appended to the buffer<br>
* <code>false</code>: the buffer will be cleared at the beginning
* @param formatFiles the <code>sprintf</code> format for the file count, e.g. "%8d"
- * @param formatSized the <code>sprintf</code> format for the MByte format, e.g. "%12.6f"
- * @param formatFiles the <code>sprintf</code> format for the directory count, e.g. "%6d"
+ * @param formatSizes the <code>sprintf</code> format for the MByte format, e.g. "%12.6f"
+ * @param formatDirs the <code>sprintf</code> format for the directory count, e.g. "%6d"
* @return a human readable string
*/
const char* ReDirTreeStatistic::statisticAsString(ReByteBuffer& buffer,
* Constructor.
*
* @param base the base directory. The traversal starts at this point
+ * @param tracer actor doing the trace
+ * @param logger the logger
*/
ReTraverser::ReTraverser(const char* base, ReTraceUnit* tracer,
ReLogger* logger) :
* @param parent the parent directory of the entry
* @param node the name of the directory belonging to the entry (without path)
* @param level the index of the entry in the stack.<br>
- * If < 0: m_levels and m_path will not be changed
+ * If < 0: m_levels and m_path will not be changed
* @return <code>true</code>: a new file is available<br>
- * <cude>false/code>: findFirstEntry() signals: no entry.
+ * <code>false</code>: findFirstEntry() signals: no entry.
*/
bool ReTraverser::initEntry(const ReByteBuffer& parent, const char* node,
int level) {