summaryrefslogtreecommitdiff
path: root/fxbarcode
diff options
context:
space:
mode:
Diffstat (limited to 'fxbarcode')
-rw-r--r--fxbarcode/BC_UtilCodingConvert.cpp4
-rw-r--r--fxbarcode/datamatrix/BC_Base256Encoder.cpp5
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp3
-rw-r--r--fxbarcode/oned/BC_OnedCodaBarWriter.cpp15
-rw-r--r--fxbarcode/oned/BC_OnedCode128Writer.cpp16
-rw-r--r--fxbarcode/oned/BC_OnedCode39Writer.cpp6
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp12
-rw-r--r--fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp5
8 files changed, 20 insertions, 46 deletions
diff --git a/fxbarcode/BC_UtilCodingConvert.cpp b/fxbarcode/BC_UtilCodingConvert.cpp
index f1dea885c3..f0f497a07b 100644
--- a/fxbarcode/BC_UtilCodingConvert.cpp
+++ b/fxbarcode/BC_UtilCodingConvert.cpp
@@ -25,9 +25,7 @@ void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src,
std::vector<uint8_t>& dst) {
CFX_WideString unicode = CFX_WideString::FromLocal(src.AsStringC());
CFX_ByteString utf8 = unicode.UTF8Encode();
- for (int32_t i = 0; i < utf8.GetLength(); i++) {
- dst.push_back(utf8[i]);
- }
+ dst = std::vector<uint8_t>(utf8.begin(), utf8.end());
}
void CBC_UtilCodingConvert::Utf8ToLocale(const std::vector<uint8_t>& src,
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
index 1b8db85bdd..dd49c8e0f5 100644
--- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
@@ -70,9 +70,8 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) {
return;
}
}
- for (int32_t i = 0, c = buffer.GetLength(); i < c; i++) {
- context.writeCodeword(
- randomize255State(buffer.GetAt(i), context.getCodewordCount() + 1));
+ for (const auto& c : buffer) {
+ context.writeCodeword(randomize255State(c, context.getCodewordCount() + 1));
}
}
wchar_t CBC_Base256Encoder::randomize255State(wchar_t ch,
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 041272ef8c..cce9749749 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -63,8 +63,7 @@ std::vector<uint8_t>& CBC_HighLevelEncoder::getBytesForMessage(
CFX_WideString msg) {
CFX_ByteString bytestr;
CBC_UtilCodingConvert::UnicodeToUTF8(msg, bytestr);
- for (int32_t i = 0; i < bytestr.GetLength(); i++)
- m_bytearray.push_back(bytestr.GetAt(i));
+ m_bytearray.insert(m_bytearray.end(), bytestr.begin(), bytestr.end());
return m_bytearray;
}
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index 6c04cafe7b..d3706ab96d 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -108,18 +108,11 @@ bool CBC_OnedCodaBarWriter::FindChar(wchar_t ch, bool isContent) {
}
bool CBC_OnedCodaBarWriter::CheckContentValidity(
const CFX_WideStringC& contents) {
- wchar_t ch;
- int32_t index = 0;
- for (index = 0; index < contents.GetLength(); index++) {
- ch = contents.GetAt(index);
- if (FindChar(ch, false)) {
- continue;
- } else {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ contents.begin(), contents.end(),
+ [this](const wchar_t& ch) { return this->FindChar(ch, false); });
}
+
CFX_WideString CBC_OnedCodaBarWriter::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
diff --git a/fxbarcode/oned/BC_OnedCode128Writer.cpp b/fxbarcode/oned/BC_OnedCode128Writer.cpp
index 53f4d01449..e2b6823414 100644
--- a/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -113,22 +113,14 @@ CFX_WideString CBC_OnedCode128Writer::FilterContents(
}
CFX_WideString filtercontents;
if (m_codeFormat == BC_CODE128_B) {
- for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) {
- ch = filterChineseChar.GetAt(i);
- if (ch >= 32 && ch <= 126) {
+ for (const auto& ch : filterChineseChar) {
+ if (ch >= 32 && ch <= 126)
filtercontents += ch;
- } else {
- continue;
- }
}
} else if (m_codeFormat == BC_CODE128_C) {
- for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) {
- ch = filterChineseChar.GetAt(i);
- if (ch >= 32 && ch <= 106) {
+ for (const auto& ch : filterChineseChar) {
+ if (ch >= 32 && ch <= 106)
filtercontents += ch;
- } else {
- continue;
- }
}
} else {
filtercontents = contents;
diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp
index bcc64d83bd..b1a56cad40 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp
@@ -163,11 +163,11 @@ char CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString& contents,
}
int32_t checksum = 0;
int32_t len = (int32_t)strlen(ALPHABET_STRING);
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (const auto& c : contents) {
int32_t j = 0;
for (; j < len; j++) {
- if (ALPHABET_STRING[j] == contents[i]) {
- if (contents[i] != '*')
+ if (ALPHABET_STRING[j] == c) {
+ if (c != '*')
checksum += j;
break;
}
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index a11938a4d9..96b51b0570 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -48,17 +48,13 @@ CBC_OnedEAN13Writer::CBC_OnedEAN13Writer() {
m_codeWidth = 3 + (7 * 6) + 5 + (7 * 6) + 3;
}
CBC_OnedEAN13Writer::~CBC_OnedEAN13Writer() {}
+
bool CBC_OnedEAN13Writer::CheckContentValidity(
const CFX_WideStringC& contents) {
- for (int32_t i = 0; i < contents.GetLength(); i++) {
- if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') {
- continue;
- } else {
- return false;
- }
- }
- return true;
+ return std::all_of(contents.begin(), contents.end(),
+ [](const wchar_t& w) { return w >= L'0' && w <= L'9'; });
}
+
CFX_WideString CBC_OnedEAN13Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index ac8b0186f6..f65cfe46ae 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -71,10 +71,7 @@ CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel(
}
msg += ch;
}
- std::vector<uint8_t> byteArr;
- for (int32_t k = 0; k < bytes.GetLength(); k++) {
- byteArr.push_back(bytes.GetAt(k));
- }
+ std::vector<uint8_t> byteArr(bytes.begin(), bytes.end());
CFX_WideString sb;
len = msg.GetLength();
int32_t p = 0;