mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
extra paremeter book skipEmpty for ZLStringUtil::split()
This commit is contained in:
parent
fed9619767
commit
81e2abe85d
4 changed files with 13 additions and 16 deletions
|
@ -153,14 +153,7 @@ void DocBookReader::handleSeparatorField() {
|
|||
if (utf8String.empty()) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> result = ZLStringUtil::split(utf8String, SPACE_DELIMETER);
|
||||
//TODO split function can returns empty string, maybe fix it
|
||||
std::vector<std::string> split;
|
||||
for (std::size_t i = 0; i < result.size(); ++i) {
|
||||
if (!result.at(i).empty()) {
|
||||
split.push_back(result.at(i));
|
||||
}
|
||||
}
|
||||
std::vector<std::string> split = ZLStringUtil::split(utf8String, SPACE_DELIMETER, true);
|
||||
|
||||
if (!split.empty() && split.at(0) == SEQUENCE) {
|
||||
myReadFieldState = READ_FIELD_TEXT;
|
||||
|
|
|
@ -736,13 +736,11 @@ void XHTMLReader::startElementHandler(const char *tag, const char **attributes)
|
|||
std::vector<std::string> classesList;
|
||||
const char *aClasses = attributeValue(attributes, "class");
|
||||
if (aClasses != 0) {
|
||||
const std::vector<std::string> split = ZLStringUtil::split(aClasses, " ");
|
||||
const std::vector<std::string> split = ZLStringUtil::split(aClasses, " ", true);
|
||||
for (std::vector<std::string>::const_iterator it = split.begin(); it != split.end(); ++it) {
|
||||
if (!it->empty()) {
|
||||
classesList.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool breakBefore = myStyleSheetTable.doBreakBefore(sTag, "");
|
||||
myTagDataStack.back()->PageBreakAfter = myStyleSheetTable.doBreakAfter(sTag, "");
|
||||
|
|
|
@ -96,16 +96,22 @@ void ZLStringUtil::stripWhiteSpaces(std::string &str) {
|
|||
str.erase(r_counter, length - r_counter);
|
||||
}
|
||||
|
||||
std::vector<std::string> ZLStringUtil::split(const std::string &str, const std::string &delimiter) {
|
||||
std::vector<std::string> ZLStringUtil::split(const std::string &str, const std::string &delimiter, bool skipEmpty) {
|
||||
std::vector<std::string> result;
|
||||
std::size_t start = 0;
|
||||
std::size_t index = str.find(delimiter);
|
||||
while (index != std::string::npos) {
|
||||
result.push_back(str.substr(start, index - start));
|
||||
const std::string sub = str.substr(start, index - start);
|
||||
if (!skipEmpty || sub.size() > 0) {
|
||||
result.push_back(sub);
|
||||
}
|
||||
start = index + delimiter.length();
|
||||
index = str.find(delimiter, start);
|
||||
}
|
||||
result.push_back(str.substr(start, index - start));
|
||||
const std::string sub = str.substr(start, index - start);
|
||||
if (!skipEmpty || sub.size() > 0) {
|
||||
result.push_back(sub);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
static void append(std::string &str, const std::vector<std::string> &buffer);
|
||||
static void stripWhiteSpaces(std::string &str);
|
||||
|
||||
static std::vector<std::string> split(const std::string &str, const std::string &delimiter);
|
||||
static std::vector<std::string> split(const std::string &str, const std::string &delimiter, bool skipEmpty);
|
||||
static std::string join(const std::vector<std::string> &data, const std::string &delimiter);
|
||||
|
||||
static std::string printf(const std::string &format, const std::string &arg0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue