-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (53 loc) · 1.83 KB
/
main.cpp
File metadata and controls
67 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <fstream>
#include <ctime>
#include <SDRL.h>
#include <locale>
#include <codecvt>
#include <string>
using namespace std;
int main(int argc, const char** argv)
{
std::ios_base::sync_with_stdio(false);
//std::wcout.imbue(std::locale("RU"));
wcout.imbue(locale("rus_rus.866"));
std::wcout << "Test: " << std::locale("").name().c_str() << '\n';
if (argc < 2) {
std::clog << "Try this: ./programm_name \"path to test file\"" << std::endl;
return 0;
}
sdrl::DocDocument document;
document.open(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(argv[1]));
auto sections = document.sectionInfoList();
size_t sectionCount = sections.size();
size_t currentSection = 0;
size_t currentParagraph = 0;
for (const auto& paragraph : document.paragraphList()) {
if ( sectionCount > currentSection
&& sections[currentSection].firstParagraphIndex == currentParagraph ) {
std::wcout << std::endl << "Section " << ++currentSection << std::endl;
}
std::wcout << paragraph << std::endl;
++currentParagraph;
}
const auto& docInfo = document.documentInfo();
std::wcout << std::endl
<< "Document info:" << std::endl
<< "Page count: " << docInfo.pageCount << std::endl
<< "Word count: " << docInfo.wordCount << std::endl
<< "Character count: " << docInfo.characterCount << std::endl
<< "Create time (dd.mm.yyyy hh:mm): "
<< docInfo.createTime.day() << "."
<< docInfo.createTime.month() << "."
<< docInfo.createTime.year() << " "
<< docInfo.createTime.hour() << ":"
<< docInfo.createTime.minute() << std::endl
<< "Last save time (dd.mm.yyyy hh:mm): "
<< docInfo.lastSave.day() << "."
<< docInfo.lastSave.month() << "."
<< docInfo.lastSave.year() << " "
<< docInfo.lastSave.hour() << ":"
<< docInfo.lastSave.minute() << std::endl;
std::cin.get();
return 0;
}