mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
formatting
This commit is contained in:
parent
dde4be579e
commit
a7fa712e03
28 changed files with 92 additions and 92 deletions
|
@ -48,7 +48,7 @@ BookModel::~BookModel() {
|
||||||
void BookModel::setHyperlinkMatcher(shared_ptr<HyperlinkMatcher> matcher) {
|
void BookModel::setHyperlinkMatcher(shared_ptr<HyperlinkMatcher> matcher) {
|
||||||
myHyperlinkMatcher = matcher;
|
myHyperlinkMatcher = matcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
BookModel::Label BookModel::label(const std::string &id) const {
|
BookModel::Label BookModel::label(const std::string &id) const {
|
||||||
if (!myHyperlinkMatcher.isNull()) {
|
if (!myHyperlinkMatcher.isNull()) {
|
||||||
return myHyperlinkMatcher->match(myInternalHyperlinks, id);
|
return myHyperlinkMatcher->match(myInternalHyperlinks, id);
|
||||||
|
|
|
@ -297,7 +297,7 @@ void StyleSheetMultiStyleParser::processAtRule(const std::string &name, const St
|
||||||
for (std::vector<std::string>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
for (std::vector<std::string>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
||||||
if (ZLStringUtil::stringStartsWith(*jt, "url(") &&
|
if (ZLStringUtil::stringStartsWith(*jt, "url(") &&
|
||||||
ZLStringUtil::stringEndsWith(*jt, ")")) {
|
ZLStringUtil::stringEndsWith(*jt, ")")) {
|
||||||
path = ZLFile(url2FullPath(*jt)).path();
|
path = ZLFile(url2FullPath(*jt)).path();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ void StyleSheetParserWithCache::importCSS(const std::string &path) {
|
||||||
StyleSheetParserWithCache importParser(fileToImport, myPathPrefix, myFontMap, myEncryptionMap);
|
StyleSheetParserWithCache importParser(fileToImport, myPathPrefix, myFontMap, myEncryptionMap);
|
||||||
importParser.myProcessedFiles.insert(myProcessedFiles.begin(), myProcessedFiles.end());
|
importParser.myProcessedFiles.insert(myProcessedFiles.begin(), myProcessedFiles.end());
|
||||||
importParser.parseStream(stream);
|
importParser.parseStream(stream);
|
||||||
myEntries.insert(myEntries.end(), importParser.myEntries.begin(), importParser.myEntries.end());
|
myEntries.insert(myEntries.end(), importParser.myEntries.begin(), importParser.myEntries.end());
|
||||||
}
|
}
|
||||||
myProcessedFiles.insert(fileToImport.path());
|
myProcessedFiles.insert(fileToImport.path());
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
||||||
|
|
||||||
const std::string &fontSize = value(styles, "font-size");
|
const std::string &fontSize = value(styles, "font-size");
|
||||||
if (!fontSize.empty()) {
|
if (!fontSize.empty()) {
|
||||||
bool doSetFontSize = true;
|
bool doSetFontSize = true;
|
||||||
short size = 100;
|
short size = 100;
|
||||||
ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PERCENT;
|
ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PERCENT;
|
||||||
if (fontSize == "xx-small") {
|
if (fontSize == "xx-small") {
|
||||||
|
|
|
@ -123,7 +123,7 @@ void HtmlReader::readDocument(ZLInputStream &stream) {
|
||||||
int quotationCounter = 0;
|
int quotationCounter = 0;
|
||||||
HtmlTag currentTag;
|
HtmlTag currentTag;
|
||||||
char endOfComment[2] = "\0";
|
char endOfComment[2] = "\0";
|
||||||
|
|
||||||
const std::size_t BUFSIZE = 2048;
|
const std::size_t BUFSIZE = 2048;
|
||||||
char *buffer = new char[BUFSIZE];
|
char *buffer = new char[BUFSIZE];
|
||||||
std::size_t length;
|
std::size_t length;
|
||||||
|
@ -362,7 +362,7 @@ void HtmlReader::readDocument(ZLInputStream &stream) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset += length;
|
offset += length;
|
||||||
} while (length == BUFSIZE);
|
} while (length == BUFSIZE);
|
||||||
endOfProcessing:
|
endOfProcessing:
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
|
|
@ -134,7 +134,7 @@ void OEBBookReader::startElementHandler(const char *tag, const char **xmlattribu
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OEBBookReader::coverIsSingleImage() const {
|
bool OEBBookReader::coverIsSingleImage() const {
|
||||||
return
|
return
|
||||||
COVER_IMAGE == myCoverFileType ||
|
COVER_IMAGE == myCoverFileType ||
|
||||||
(COVER == myCoverFileType &&
|
(COVER == myCoverFileType &&
|
||||||
ZLStringUtil::stringStartsWith(myCoverMimeType, "image/"));
|
ZLStringUtil::stringStartsWith(myCoverMimeType, "image/"));
|
||||||
|
|
|
@ -67,7 +67,7 @@ protected:
|
||||||
FONT_ITALIC,
|
FONT_ITALIC,
|
||||||
FONT_UNDERLINED
|
FONT_UNDERLINED
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void addCharData(const char *data, std::size_t len, bool convert) = 0;
|
virtual void addCharData(const char *data, std::size_t len, bool convert) = 0;
|
||||||
virtual void insertImage(const std::string &mimeType, const std::string &fileName, std::size_t startOffset, std::size_t size) = 0;
|
virtual void insertImage(const std::string &mimeType, const std::string &fileName, std::size_t startOffset, std::size_t size) = 0;
|
||||||
virtual void setEncoding(int code) = 0;
|
virtual void setEncoding(int code) = 0;
|
||||||
|
@ -91,7 +91,7 @@ protected:
|
||||||
bool Underlined;
|
bool Underlined;
|
||||||
ZLTextAlignmentType Alignment;
|
ZLTextAlignmentType Alignment;
|
||||||
DestinationType Destination;
|
DestinationType Destination;
|
||||||
|
|
||||||
bool ReadDataAsHex;
|
bool ReadDataAsHex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ private:
|
||||||
int myBinaryDataSize;
|
int myBinaryDataSize;
|
||||||
std::string myNextImageMimeType;
|
std::string myNextImageMimeType;
|
||||||
|
|
||||||
int myIsInterrupted;
|
int myIsInterrupted;
|
||||||
|
|
||||||
friend class RtfNewParagraphCommand;
|
friend class RtfNewParagraphCommand;
|
||||||
friend class RtfFontPropertyCommand;
|
friend class RtfFontPropertyCommand;
|
||||||
|
|
|
@ -97,7 +97,7 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
|
||||||
unsigned int currentLineLength = 0;
|
unsigned int currentLineLength = 0;
|
||||||
unsigned int currentLineIndent = 0;
|
unsigned int currentLineIndent = 0;
|
||||||
int currentNumberOfEmptyLines = -1;
|
int currentNumberOfEmptyLines = -1;
|
||||||
|
|
||||||
char *buffer = new char[BUFFER_SIZE];
|
char *buffer = new char[BUFFER_SIZE];
|
||||||
int length;
|
int length;
|
||||||
char previous = 0;
|
char previous = 0;
|
||||||
|
@ -127,7 +127,7 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
|
||||||
if (!currentLineIsEmpty) {
|
if (!currentLineIsEmpty) {
|
||||||
stringIndentTable[std::min(currentLineIndent, tableSize - 1)]++;
|
stringIndentTable[std::min(currentLineIndent, tableSize - 1)]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLineIsEmpty = true;
|
currentLineIsEmpty = true;
|
||||||
currentLineLength = 0;
|
currentLineLength = 0;
|
||||||
currentLineIndent = 0;
|
currentLineIndent = 0;
|
||||||
|
@ -182,8 +182,8 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
|
||||||
}
|
}
|
||||||
if (emptyLinesBeforeNewSection > 0) {
|
if (emptyLinesBeforeNewSection > 0) {
|
||||||
for (index = tableSize - 1; index > 0; --index) {
|
for (index = tableSize - 1; index > 0; --index) {
|
||||||
emptyLinesTable[index - 1] += emptyLinesTable[index];
|
emptyLinesTable[index - 1] += emptyLinesTable[index];
|
||||||
emptyLinesBeforeShortStringTable[index - 1] += emptyLinesBeforeShortStringTable[index];
|
emptyLinesBeforeShortStringTable[index - 1] += emptyLinesBeforeShortStringTable[index];
|
||||||
}
|
}
|
||||||
for (index = emptyLinesBeforeNewSection; index < tableSize; ++index) {
|
for (index = emptyLinesBeforeNewSection; index < tableSize; ++index) {
|
||||||
if ((emptyLinesBeforeShortStringTable[index] > 2) &&
|
if ((emptyLinesBeforeShortStringTable[index] > 2) &&
|
||||||
|
|
|
@ -24,5 +24,5 @@ const std::vector<std::string> &EntityFilesCollector::xhtmlDTDs() {
|
||||||
if (DTDs.empty()) {
|
if (DTDs.empty()) {
|
||||||
DTDs.push_back("formats/xhtml/xhtml-merged.ent");
|
DTDs.push_back("formats/xhtml/xhtml-merged.ent");
|
||||||
}
|
}
|
||||||
return DTDs;
|
return DTDs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,14 +50,14 @@ class XHTMLTagAction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~XHTMLTagAction();
|
virtual ~XHTMLTagAction();
|
||||||
|
|
||||||
virtual void doAtStart(XHTMLReader &reader, const char **xmlattributes) = 0;
|
virtual void doAtStart(XHTMLReader &reader, const char **xmlattributes) = 0;
|
||||||
virtual void doAtEnd(XHTMLReader &reader) = 0;
|
virtual void doAtEnd(XHTMLReader &reader) = 0;
|
||||||
virtual bool isEnabled(XHTMLReadingState state) = 0;
|
virtual bool isEnabled(XHTMLReadingState state) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static BookReader &bookReader(XHTMLReader &reader);
|
static BookReader &bookReader(XHTMLReader &reader);
|
||||||
static const std::string &pathPrefix(XHTMLReader &reader);
|
static const std::string &pathPrefix(XHTMLReader &reader);
|
||||||
static void beginParagraph(XHTMLReader &reader);
|
static void beginParagraph(XHTMLReader &reader);
|
||||||
static void endParagraph(XHTMLReader &reader);
|
static void endParagraph(XHTMLReader &reader);
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ shared_ptr<Book> Book::loadFromFile(const ZLFile &file) {
|
||||||
|
|
||||||
shared_ptr<Book> book = new Book(file, 0);
|
shared_ptr<Book> book = new Book(file, 0);
|
||||||
if (!plugin->readMetainfo(*book)) {
|
if (!plugin->readMetainfo(*book)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (book->title().empty()) {
|
if (book->title().empty()) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ shared_ptr<Tag> Tag::cloneSubTag(shared_ptr<Tag> tag, shared_ptr<Tag> oldparent,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levels.empty()) {
|
if (levels.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Tag> res = newparent;
|
shared_ptr<Tag> res = newparent;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
static void setTagId(shared_ptr<Tag>, int tagId);
|
static void setTagId(shared_ptr<Tag>, int tagId);
|
||||||
|
|
||||||
static shared_ptr<Tag> cloneSubTag(shared_ptr<Tag> tag, shared_ptr<Tag> oldparent, shared_ptr<Tag> newparent);
|
static shared_ptr<Tag> cloneSubTag(shared_ptr<Tag> tag, shared_ptr<Tag> oldparent, shared_ptr<Tag> newparent);
|
||||||
|
|
||||||
static void collectAncestors(shared_ptr<Tag> tag, TagList &parents);
|
static void collectAncestors(shared_ptr<Tag> tag, TagList &parents);
|
||||||
|
|
||||||
static void collectTagNames(std::vector<std::string> &tags);
|
static void collectTagNames(std::vector<std::string> &tags);
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
int tagId() const;
|
int tagId() const;
|
||||||
std::size_t level() const;
|
std::size_t level() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string myName;
|
const std::string myName;
|
||||||
mutable std::string myFullName;
|
mutable std::string myFullName;
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
shared_ptr<Tag> myParent;
|
shared_ptr<Tag> myParent;
|
||||||
TagList myChildren;
|
TagList myChildren;
|
||||||
const std::size_t myLevel;
|
const std::size_t myLevel;
|
||||||
|
|
||||||
int myTagId;
|
int myTagId;
|
||||||
|
|
||||||
mutable jobject myJavaTag;
|
mutable jobject myJavaTag;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::string delimiter() const = 0;
|
virtual std::string delimiter() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string myPath;
|
std::string myPath;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "ZLDir.h"
|
#include "ZLDir.h"
|
||||||
|
|
||||||
class ZLFSDir : public ZLDir {
|
class ZLFSDir : public ZLDir {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ZLFSDir(const std::string &path);
|
ZLFSDir(const std::string &path);
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static ZLFSManager *ourInstance;
|
static ZLFSManager *ourInstance;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ZLFSManager();
|
ZLFSManager();
|
||||||
virtual ~ZLFSManager();
|
virtual ~ZLFSManager();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void normalize(std::string &path) const;
|
void normalize(std::string &path) const;
|
||||||
virtual std::string resolveSymlink(const std::string &path) const = 0;
|
virtual std::string resolveSymlink(const std::string &path) const = 0;
|
||||||
|
|
|
@ -29,7 +29,7 @@ ZLCharSequence::ZLCharSequence(const char *ptr, std::size_t size) : mySize(size)
|
||||||
myHead = new char[mySize];
|
myHead = new char[mySize];
|
||||||
for (std::size_t count = 0; count < mySize; ++count){
|
for (std::size_t count = 0; count < mySize; ++count){
|
||||||
myHead[count] = ptr[count];
|
myHead[count] = ptr[count];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZLCharSequence::ZLCharSequence(const ZLCharSequence& other) : mySize(other.mySize) {
|
ZLCharSequence::ZLCharSequence(const ZLCharSequence& other) : mySize(other.mySize) {
|
||||||
|
@ -48,11 +48,11 @@ ZLCharSequence::ZLCharSequence(const std::string &hexSequence) {
|
||||||
myHead = new char[mySize];
|
myHead = new char[mySize];
|
||||||
for (std::size_t count = 0; count < mySize; ++count){
|
for (std::size_t count = 0; count < mySize; ++count){
|
||||||
char a = hexSequence[count * 5 + 2];
|
char a = hexSequence[count * 5 + 2];
|
||||||
char b = hexSequence[count * 5 + 3];
|
char b = hexSequence[count * 5 + 3];
|
||||||
a -= (a >= 97) ? 87 : 48;
|
a -= (a >= 97) ? 87 : 48;
|
||||||
b -= (b >= 97) ? 87 : 48;
|
b -= (b >= 97) ? 87 : 48;
|
||||||
myHead[count] = a*16 + b;
|
myHead[count] = a*16 + b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZLCharSequence& ZLCharSequence::operator= (const ZLCharSequence& other) {
|
ZLCharSequence& ZLCharSequence::operator= (const ZLCharSequence& other) {
|
||||||
|
@ -72,20 +72,20 @@ ZLCharSequence& ZLCharSequence::operator= (const ZLCharSequence& other) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ZLCharSequence::toHexSequence() const {
|
std::string ZLCharSequence::toHexSequence() const {
|
||||||
std::string result;
|
std::string result;
|
||||||
static const char table[] = "0123456789abcdef";
|
static const char table[] = "0123456789abcdef";
|
||||||
for (std::size_t count = 0;; ++count) {
|
for (std::size_t count = 0;; ++count) {
|
||||||
result += "0x";
|
result += "0x";
|
||||||
result += table[(myHead[count] >> 4) & 0x0F];
|
result += table[(myHead[count] >> 4) & 0x0F];
|
||||||
result += table[myHead[count] & 0x0F];
|
result += table[myHead[count] & 0x0F];
|
||||||
if (count == mySize-1) {
|
if (count == mySize-1) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result += " ";
|
result += " ";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,17 @@
|
||||||
class ZLCharSequence {
|
class ZLCharSequence {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZLCharSequence();
|
ZLCharSequence();
|
||||||
ZLCharSequence(const char *ptr, std::size_t size);
|
ZLCharSequence(const char *ptr, std::size_t size);
|
||||||
ZLCharSequence(const std::string &hexSequence);
|
ZLCharSequence(const std::string &hexSequence);
|
||||||
ZLCharSequence(const ZLCharSequence &other);
|
ZLCharSequence(const ZLCharSequence &other);
|
||||||
~ZLCharSequence();
|
~ZLCharSequence();
|
||||||
|
|
||||||
std::size_t getSize() const;
|
std::size_t getSize() const;
|
||||||
const char &operator [] (std::size_t index) const;
|
const char &operator [] (std::size_t index) const;
|
||||||
ZLCharSequence &operator = (const ZLCharSequence& other);
|
ZLCharSequence &operator = (const ZLCharSequence& other);
|
||||||
|
|
||||||
std::string toHexSequence() const;
|
std::string toHexSequence() const;
|
||||||
|
|
||||||
// returns
|
// returns
|
||||||
// an integer < 0 if the sequence is less than other
|
// an integer < 0 if the sequence is less than other
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
// 0 if the sequence is equal to other
|
// 0 if the sequence is equal to other
|
||||||
int compareTo(const ZLCharSequence &other) const;
|
int compareTo(const ZLCharSequence &other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::size_t mySize;
|
std::size_t mySize;
|
||||||
char *myHead;
|
char *myHead;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,15 +80,15 @@ int ZLStatistics::correlation(const ZLStatistics& candidate, const ZLStatistics&
|
||||||
const unsigned long long patternSum = pattern.getVolume();
|
const unsigned long long patternSum = pattern.getVolume();
|
||||||
const unsigned long long candidateSum2 = candidate.getSquaresVolume();
|
const unsigned long long candidateSum2 = candidate.getSquaresVolume();
|
||||||
const unsigned long long patternSum2 = pattern.getSquaresVolume();
|
const unsigned long long patternSum2 = pattern.getSquaresVolume();
|
||||||
|
|
||||||
shared_ptr<ZLStatisticsItem> ptrA = candidate.begin();
|
shared_ptr<ZLStatisticsItem> ptrA = candidate.begin();
|
||||||
shared_ptr<ZLStatisticsItem> ptrB = pattern.begin();
|
shared_ptr<ZLStatisticsItem> ptrB = pattern.begin();
|
||||||
const shared_ptr<ZLStatisticsItem> endA = candidate.end();
|
const shared_ptr<ZLStatisticsItem> endA = candidate.end();
|
||||||
const shared_ptr<ZLStatisticsItem> endB = pattern.end();
|
const shared_ptr<ZLStatisticsItem> endB = pattern.end();
|
||||||
|
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
long long correlationSum = 0;
|
long long correlationSum = 0;
|
||||||
while ((*ptrA != *endA) && (*ptrB != *endB)) {
|
while ((*ptrA != *endA) && (*ptrB != *endB)) {
|
||||||
++count;
|
++count;
|
||||||
const int comparison = ptrA->sequence().compareTo(ptrB->sequence());
|
const int comparison = ptrA->sequence().compareTo(ptrB->sequence());
|
||||||
if (comparison < 0) {
|
if (comparison < 0) {
|
||||||
|
@ -141,10 +141,10 @@ int ZLStatistics::correlation(const ZLStatistics& candidate, const ZLStatistics&
|
||||||
}
|
}
|
||||||
int candidateMult = 1000000 / patternMult;
|
int candidateMult = 1000000 / patternMult;
|
||||||
|
|
||||||
const long long quotient1 = (patternMult * numerator / patternDispersion);
|
const long long quotient1 = (patternMult * numerator / patternDispersion);
|
||||||
const long long quotient2 = (candidateMult * numerator / candidateDispersion);
|
const long long quotient2 = (candidateMult * numerator / candidateDispersion);
|
||||||
const int sign = (numerator >= 0) ? 1 : -1;
|
const int sign = (numerator >= 0) ? 1 : -1;
|
||||||
|
|
||||||
return sign * quotient1 * quotient2;
|
return sign * quotient1 * quotient2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ ZLMapBasedStatistics::ZLMapBasedStatistics() : ZLStatistics() {
|
||||||
ZLMapBasedStatistics::ZLMapBasedStatistics(const Dictionary &dictionary) {
|
ZLMapBasedStatistics::ZLMapBasedStatistics(const Dictionary &dictionary) {
|
||||||
if (!dictionary.empty()) {
|
if (!dictionary.empty()) {
|
||||||
myCharSequenceSize = dictionary.begin()->first.getSize();
|
myCharSequenceSize = dictionary.begin()->first.getSize();
|
||||||
myVolumesAreUpToDate = false;
|
myVolumesAreUpToDate = false;
|
||||||
myDictionary = dictionary;
|
myDictionary = dictionary;
|
||||||
} else {
|
} else {
|
||||||
myCharSequenceSize = 0;
|
myCharSequenceSize = 0;
|
||||||
|
@ -191,7 +191,7 @@ ZLMapBasedStatistics ZLMapBasedStatistics::top(std::size_t amount) const {
|
||||||
tempVector.resize(myDictionary.size());
|
tempVector.resize(myDictionary.size());
|
||||||
std::copy(myDictionary.begin(), myDictionary.end(), tempVector.begin());
|
std::copy(myDictionary.begin(), myDictionary.end(), tempVector.begin());
|
||||||
std::sort(tempVector.rbegin(), tempVector.rend(), LessFrequency());
|
std::sort(tempVector.rbegin(), tempVector.rend(), LessFrequency());
|
||||||
Vector::const_iterator it = tempVector.begin();
|
Vector::const_iterator it = tempVector.begin();
|
||||||
while (amount != 0) {
|
while (amount != 0) {
|
||||||
dictionary[it->first] = it->second;
|
dictionary[it->first] = it->second;
|
||||||
++it;
|
++it;
|
||||||
|
@ -213,7 +213,7 @@ void ZLMapBasedStatistics::retain(const ZLMapBasedStatistics &other) {
|
||||||
const Dictionary::iterator endA = myDictionary.end();
|
const Dictionary::iterator endA = myDictionary.end();
|
||||||
const Dictionary::const_iterator endB = other.myDictionary.end();
|
const Dictionary::const_iterator endB = other.myDictionary.end();
|
||||||
|
|
||||||
while ((itA != endA) && (itB != endB)) {
|
while ((itA != endA) && (itB != endB)) {
|
||||||
const int comparison = itA->first.compareTo(itB->first);
|
const int comparison = itA->first.compareTo(itB->first);
|
||||||
if (comparison < 0) {
|
if (comparison < 0) {
|
||||||
myDictionary.erase(itA++);
|
myDictionary.erase(itA++);
|
||||||
|
@ -230,7 +230,7 @@ void ZLMapBasedStatistics::retain(const ZLMapBasedStatistics &other) {
|
||||||
if (itA != endA) {
|
if (itA != endA) {
|
||||||
myDictionary.erase(itA, endA);
|
myDictionary.erase(itA, endA);
|
||||||
}
|
}
|
||||||
myVolumesAreUpToDate = true;
|
myVolumesAreUpToDate = true;
|
||||||
} else {
|
} else {
|
||||||
*this = ZLMapBasedStatistics();
|
*this = ZLMapBasedStatistics();
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ void ZLMapBasedStatistics::scaleToShort() {
|
||||||
const std::size_t maxShort = 65535;
|
const std::size_t maxShort = 65535;
|
||||||
if (maxFrequency > maxShort) {
|
if (maxFrequency > maxShort) {
|
||||||
const std::size_t devider = maxFrequency / maxShort + 1;
|
const std::size_t devider = maxFrequency / maxShort + 1;
|
||||||
Dictionary::iterator it = myDictionary.begin();
|
Dictionary::iterator it = myDictionary.begin();
|
||||||
const Dictionary::iterator end = myDictionary.end();
|
const Dictionary::iterator end = myDictionary.end();
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
if (it->second < devider) {
|
if (it->second < devider) {
|
||||||
|
@ -272,7 +272,7 @@ ZLArrayBasedStatistics::ZLArrayBasedStatistics(std::size_t charSequenceSize, std
|
||||||
mySequences = new char[myCharSequenceSize * size];
|
mySequences = new char[myCharSequenceSize * size];
|
||||||
myFrequencies = new unsigned short[size];
|
myFrequencies = new unsigned short[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
ZLArrayBasedStatistics::~ZLArrayBasedStatistics() {
|
ZLArrayBasedStatistics::~ZLArrayBasedStatistics() {
|
||||||
if (mySequences != 0) {
|
if (mySequences != 0) {
|
||||||
delete[] mySequences;
|
delete[] mySequences;
|
||||||
|
@ -285,7 +285,7 @@ void ZLArrayBasedStatistics::insert(const ZLCharSequence &charSequence, std::siz
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (std::size_t i = 0; i < myCharSequenceSize; ++i) {
|
for (std::size_t i = 0; i < myCharSequenceSize; ++i) {
|
||||||
mySequences[myBack * myCharSequenceSize + i] = charSequence[i];
|
mySequences[myBack * myCharSequenceSize + i] = charSequence[i];
|
||||||
}
|
}
|
||||||
myFrequencies[myBack] = (unsigned short) frequency;
|
myFrequencies[myBack] = (unsigned short) frequency;
|
||||||
++myBack;
|
++myBack;
|
||||||
|
@ -334,6 +334,6 @@ ZLArrayBasedStatistics& ZLArrayBasedStatistics::operator= (const ZLArrayBasedSta
|
||||||
} else {
|
} else {
|
||||||
mySequences = 0;
|
mySequences = 0;
|
||||||
myFrequencies = 0;
|
myFrequencies = 0;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
std::size_t getVolume() const;
|
std::size_t getVolume() const;
|
||||||
unsigned long long getSquaresVolume() const;
|
unsigned long long getSquaresVolume() const;
|
||||||
std::size_t getCharSequenceSize() const;
|
std::size_t getCharSequenceSize() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual shared_ptr<ZLStatisticsItem> begin() const = 0;
|
virtual shared_ptr<ZLStatisticsItem> begin() const = 0;
|
||||||
virtual shared_ptr<ZLStatisticsItem> end() const = 0;
|
virtual shared_ptr<ZLStatisticsItem> end() const = 0;
|
||||||
|
@ -60,27 +60,27 @@ protected:
|
||||||
class ZLMapBasedStatistics : public ZLStatistics {
|
class ZLMapBasedStatistics : public ZLStatistics {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<std::pair<ZLCharSequence, std::size_t> > Vector;
|
typedef std::vector<std::pair<ZLCharSequence, std::size_t> > Vector;
|
||||||
typedef std::map<ZLCharSequence, std::size_t> Dictionary;
|
typedef std::map<ZLCharSequence, std::size_t> Dictionary;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZLMapBasedStatistics();
|
ZLMapBasedStatistics();
|
||||||
ZLMapBasedStatistics(const Dictionary &dictionary);
|
ZLMapBasedStatistics(const Dictionary &dictionary);
|
||||||
~ZLMapBasedStatistics();
|
~ZLMapBasedStatistics();
|
||||||
|
|
||||||
std::size_t getSize() const;
|
std::size_t getSize() const;
|
||||||
|
|
||||||
ZLMapBasedStatistics top(std::size_t amount) const;
|
ZLMapBasedStatistics top(std::size_t amount) const;
|
||||||
|
|
||||||
void scaleToShort();
|
void scaleToShort();
|
||||||
void retain(const ZLMapBasedStatistics &other);
|
void retain(const ZLMapBasedStatistics &other);
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
virtual shared_ptr<ZLStatisticsItem> begin() const;
|
virtual shared_ptr<ZLStatisticsItem> begin() const;
|
||||||
virtual shared_ptr<ZLStatisticsItem> end() const;
|
virtual shared_ptr<ZLStatisticsItem> end() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void calculateVolumes() const;
|
void calculateVolumes() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -97,12 +97,12 @@ private:
|
||||||
class ZLArrayBasedStatistics : public ZLStatistics {
|
class ZLArrayBasedStatistics : public ZLStatistics {
|
||||||
public:
|
public:
|
||||||
ZLArrayBasedStatistics();
|
ZLArrayBasedStatistics();
|
||||||
ZLArrayBasedStatistics(std::size_t charSequenceSize, std::size_t size, std::size_t volume, unsigned long long squaresVolume);
|
ZLArrayBasedStatistics(std::size_t charSequenceSize, std::size_t size, std::size_t volume, unsigned long long squaresVolume);
|
||||||
~ZLArrayBasedStatistics();
|
~ZLArrayBasedStatistics();
|
||||||
|
|
||||||
ZLArrayBasedStatistics &operator = (const ZLArrayBasedStatistics &other);
|
ZLArrayBasedStatistics &operator = (const ZLArrayBasedStatistics &other);
|
||||||
void insert(const ZLCharSequence &charSequence, std::size_t frequency);
|
void insert(const ZLCharSequence &charSequence, std::size_t frequency);
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
virtual shared_ptr<ZLStatisticsItem> begin() const;
|
virtual shared_ptr<ZLStatisticsItem> begin() const;
|
||||||
|
@ -113,7 +113,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::size_t myCapacity;
|
std::size_t myCapacity;
|
||||||
std::size_t myBack;
|
std::size_t myBack;
|
||||||
char* mySequences;
|
char* mySequences;
|
||||||
unsigned short* myFrequencies;
|
unsigned short* myFrequencies;
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "ZLStatisticsItem.h"
|
#include "ZLStatisticsItem.h"
|
||||||
|
|
||||||
ZLMapBasedStatisticsItem::ZLMapBasedStatisticsItem(const std::map<ZLCharSequence, std::size_t>::const_iterator it, std::size_t index) : ZLStatisticsItem(index),
|
ZLMapBasedStatisticsItem::ZLMapBasedStatisticsItem(const std::map<ZLCharSequence, std::size_t>::const_iterator it, std::size_t index) : ZLStatisticsItem(index),
|
||||||
myIterator(it) {
|
myIterator(it) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <ZLFile.h>
|
#include <ZLFile.h>
|
||||||
#include <ZLInputStream.h>
|
#include <ZLInputStream.h>
|
||||||
|
|
||||||
#include "ZLCharSequence.h"
|
#include "ZLCharSequence.h"
|
||||||
#include "ZLStatistics.h"
|
#include "ZLStatistics.h"
|
||||||
|
@ -64,5 +64,5 @@ shared_ptr<ZLArrayBasedStatistics> ZLStatisticsXMLReader::readStatistics(const s
|
||||||
|
|
||||||
statisticsMap.insert(std::make_pair(fileName, myStatisticsPtr));
|
statisticsMap.insert(std::make_pair(fileName, myStatisticsPtr));
|
||||||
|
|
||||||
return myStatisticsPtr;
|
return myStatisticsPtr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_ptr<ZLArrayBasedStatistics> myStatisticsPtr;
|
shared_ptr<ZLArrayBasedStatistics> myStatisticsPtr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string ITEM_TAG;
|
static const std::string ITEM_TAG;
|
||||||
static const std::string STATISTICS_TAG;
|
static const std::string STATISTICS_TAG;
|
||||||
|
|
|
@ -35,7 +35,7 @@ const std::string ZLibrary::PathDelimiter(":");
|
||||||
const std::string ZLibrary::EndOfLine("\n");
|
const std::string ZLibrary::EndOfLine("\n");
|
||||||
|
|
||||||
/*void ZLibrary::initLocale() {
|
/*void ZLibrary::initLocale() {
|
||||||
const char *locale = setlocale(LC_MESSAGES, "");
|
const char *locale = setlocale(LC_MESSAGES, "");
|
||||||
if (locale != 0) {
|
if (locale != 0) {
|
||||||
std::string sLocale = locale;
|
std::string sLocale = locale;
|
||||||
const int dotIndex = sLocale.find('.');
|
const int dotIndex = sLocale.find('.');
|
||||||
|
|
|
@ -436,23 +436,23 @@ ZLUnicodeUtil::Breakable ZLUnicodeUtil::isBreakable(Ucs4Char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((c >= 0x201A) && (c <= 0x201C)) ||
|
if (((c >= 0x201A) && (c <= 0x201C)) ||
|
||||||
((c >= 0x201E) && (c <= 0x201F))) {
|
((c >= 0x201E) && (c <= 0x201F))) {
|
||||||
return BREAKABLE_BEFORE;
|
return BREAKABLE_BEFORE;
|
||||||
|
}
|
||||||
|
switch (c) {
|
||||||
|
case 0x2018: case 0x2039: case 0x2045:
|
||||||
|
case 0x207D: case 0x208D: case 0x2329:
|
||||||
|
case 0x3008: case 0x300A: case 0x300C:
|
||||||
|
case 0x300E: case 0x3010: case 0x3014:
|
||||||
|
case 0x3016: case 0x3018: case 0x301A:
|
||||||
|
case 0x301D: case 0xFD3E: case 0xFE35:
|
||||||
|
case 0xFE37: case 0xFE39: case 0xFE3B:
|
||||||
|
case 0xFE3D: case 0xFE3F: case 0xFE41:
|
||||||
|
case 0xFE43: case 0xFE59: case 0xFE5B:
|
||||||
|
case 0xFE5D: case 0xFF08: case 0xFF3B:
|
||||||
|
case 0xFF5B: case 0xFF62:
|
||||||
|
return BREAKABLE_BEFORE;
|
||||||
}
|
}
|
||||||
switch (c) {
|
|
||||||
case 0x2018: case 0x2039: case 0x2045:
|
|
||||||
case 0x207D: case 0x208D: case 0x2329:
|
|
||||||
case 0x3008: case 0x300A: case 0x300C:
|
|
||||||
case 0x300E: case 0x3010: case 0x3014:
|
|
||||||
case 0x3016: case 0x3018: case 0x301A:
|
|
||||||
case 0x301D: case 0xFD3E: case 0xFE35:
|
|
||||||
case 0xFE37: case 0xFE39: case 0xFE3B:
|
|
||||||
case 0xFE3D: case 0xFE3F: case 0xFE41:
|
|
||||||
case 0xFE43: case 0xFE59: case 0xFE5B:
|
|
||||||
case 0xFE5D: case 0xFF08: case 0xFF3B:
|
|
||||||
case 0xFF5B: case 0xFF62:
|
|
||||||
return BREAKABLE_BEFORE;
|
|
||||||
}
|
|
||||||
return BREAKABLE_AFTER;
|
return BREAKABLE_AFTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
BREAKABLE_BEFORE,
|
BREAKABLE_BEFORE,
|
||||||
BREAKABLE_AFTER
|
BREAKABLE_AFTER
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool isUtf8String(const char *str, int len);
|
static bool isUtf8String(const char *str, int len);
|
||||||
static bool isUtf8String(const std::string &str);
|
static bool isUtf8String(const std::string &str);
|
||||||
static void cleanUtf8String(std::string &str);
|
static void cleanUtf8String(std::string &str);
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
bool myInitialized;
|
bool myInitialized;
|
||||||
bool myEof;
|
bool myEof;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disable copying
|
// disable copying
|
||||||
ZLAsynchronousInputStream(const ZLAsynchronousInputStream &);
|
ZLAsynchronousInputStream(const ZLAsynchronousInputStream &);
|
||||||
const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &);
|
const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool processInputInternal(Handler &handler);
|
bool processInputInternal(Handler &handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disable copying
|
// disable copying
|
||||||
ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &);
|
ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &);
|
||||||
const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &);
|
const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &);
|
||||||
|
|
|
@ -363,7 +363,7 @@ void ZLTextModel::addVideoEntry(const ZLVideoEntry &entry) {
|
||||||
|
|
||||||
std::size_t len = 4;
|
std::size_t len = 4;
|
||||||
for (std::map<std::string,std::string>::const_iterator it = sources.begin(); it != sources.end(); ++it) {
|
for (std::map<std::string,std::string>::const_iterator it = sources.begin(); it != sources.end(); ++it) {
|
||||||
len += 2 * (ZLUnicodeUtil::utf8Length(it->first) + ZLUnicodeUtil::utf8Length(it->second)) + 4;
|
len += 2 * (ZLUnicodeUtil::utf8Length(it->first) + ZLUnicodeUtil::utf8Length(it->second)) + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
myLastEntryStart = myAllocator->allocate(len);
|
myLastEntryStart = myAllocator->allocate(len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue