Website Summary Files Commits Branches @commit @diff @stats
path: root / Utils / Kindle / Page.cpp
diff options
context:
space:
mode:
Commit40f7cc8f54d0c221a391457fd38a44d0633aa088 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2022-05-16 14:05:08 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2022-05-16 14:05:08 +0300
Files29fecbef2da1e832f3f8e9e23db6fffe35d7ddc6 /Utils/Kindle/Page.cpp
Object-oriented_programming_FMI-40f7cc8f54d0c221a391457fd38a44d0633aa088.tar
Object-oriented_programming_FMI-40f7cc8f54d0c221a391457fd38a44d0633aa088.tar.gz
Object-oriented_programming_FMI-40f7cc8f54d0c221a391457fd38a44d0633aa088.zip
Parentde7b4d3f7ac3ecd42ca336b0d477712a462d27ee (diff)
fixed typo in folder name
1 files changed, 37 insertions, 0 deletions
-rw-r--r--Utils/Kindle/Page.cpp37
diff --git a/Utils/Kindle/Page.cpp b/Utils/Kindle/Page.cpp
new file mode 100644
index 0000000..b663f4c
--- /dev/null
+++ b/Utils/Kindle/Page.cpp
@@ -0,0 +1,37 @@
+#include "Page.h"
+
+void Page::write(unsigned linesCount) {
+ if (linesCount > MAX_LINES_IN_PAGE)
+ linesCount = MAX_LINES_IN_PAGE;
+
+
+ for (size_t i = 0; i < linesCount; i++) {
+ std::cout << i + 1 << " ";
+ lines.pushBack(string());
+
+ lines[i].getLine(std::cin);
+ }
+}
+
+void Page::displayPage() const {
+ for (size_t i = 0; i < lines.getSize(); i++)
+ std::cout << lines[i] << std::endl;
+}
+
+void Page::writeToFile(std::ofstream& outFile) const {
+ int len = lines.getSize();
+ outFile.write((const char*)&len, sizeof(len));
+
+ for (size_t i = 0; i < len; i++)
+ writeString(outFile, lines[i]);
+}
+
+void Page::readFromFile(std::ifstream& inFile) {
+ int len = 0;
+ inFile.read((char*)&len, sizeof(len));
+
+ for (size_t i = 0; i < len; i++) {
+ string s = readString(inFile);
+ lines.pushBack(std::move(s));
+ }
+}