Clean up CBC_BarcodeRow.
- Rename methods and members to Google style.
- Change index member to size_t and initialize it in the header.
Change-Id: I331796e23872051f9d68a4c080471eee6c86737b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79534
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp
index 0048175..3b528ac 100644
--- a/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/fxbarcode/pdf417/BC_PDF417.cpp
@@ -432,19 +432,19 @@
CBC_BarcodeRow* logic) {
int32_t map = 1 << (len - 1);
bool last = ((pattern & map) != 0);
- int32_t width = 0;
+ size_t width = 0;
for (int32_t i = 0; i < len; i++) {
bool black = ((pattern & map) != 0);
if (last == black) {
width++;
} else {
- logic->addBar(last, width);
+ logic->AddBar(last, width);
last = black;
width = 1;
}
map >>= 1;
}
- logic->addBar(last, width);
+ logic->AddBar(last, width);
}
void CBC_PDF417::encodeLowLevel(WideString fullCodewords,
diff --git a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
index 3e712ae..7a48353 100644
--- a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
+++ b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
@@ -36,7 +36,7 @@
CBC_BarcodeMatrix::toBitArray() {
std::vector<uint8_t, FxAllocAllocator<uint8_t>> bitArray(m_width * m_height);
for (size_t i = 0; i < m_height; ++i) {
- const auto& bytearray = m_matrix[i]->getRow();
+ const auto& bytearray = m_matrix[i]->GetRow();
for (size_t j = 0; j < m_width; ++j)
bitArray[i * m_width + j] = bytearray[j];
}
diff --git a/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp b/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp
index 1202d17..4a1f6dd 100644
--- a/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp
+++ b/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp
@@ -24,12 +24,11 @@
#include <algorithm>
-CBC_BarcodeRow::CBC_BarcodeRow(size_t width)
- : m_row(width), m_currentLocation(0) {}
+CBC_BarcodeRow::CBC_BarcodeRow(size_t width) : row_(width) {}
CBC_BarcodeRow::~CBC_BarcodeRow() = default;
-void CBC_BarcodeRow::addBar(bool black, int32_t width) {
- std::fill_n(m_row.begin() + m_currentLocation, width, black ? 1 : 0);
- m_currentLocation += width;
+void CBC_BarcodeRow::AddBar(bool black, size_t width) {
+ std::fill_n(row_.begin() + offset_, width, black ? 1 : 0);
+ offset_ += width;
}
diff --git a/fxbarcode/pdf417/BC_PDF417BarcodeRow.h b/fxbarcode/pdf417/BC_PDF417BarcodeRow.h
index e3bdb44..280a79c 100644
--- a/fxbarcode/pdf417/BC_PDF417BarcodeRow.h
+++ b/fxbarcode/pdf417/BC_PDF417BarcodeRow.h
@@ -18,14 +18,14 @@
explicit CBC_BarcodeRow(size_t width);
~CBC_BarcodeRow();
- void addBar(bool black, int32_t width);
- const std::vector<uint8_t, FxAllocAllocator<uint8_t>>& getRow() const {
- return m_row;
+ void AddBar(bool black, size_t width);
+ const std::vector<uint8_t, FxAllocAllocator<uint8_t>>& GetRow() const {
+ return row_;
}
private:
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_row;
- int32_t m_currentLocation;
+ std::vector<uint8_t, FxAllocAllocator<uint8_t>> row_;
+ size_t offset_ = 0;
};
#endif // FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_