forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogFile.cpp
More file actions
86 lines (72 loc) · 1.88 KB
/
Copy pathLogFile.cpp
File metadata and controls
86 lines (72 loc) · 1.88 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <vector>
#include "CobaltFusion/Str.h"
#include "Win32/Utilities.h"
#include "DebugViewppLib/LogFile.h"
namespace fusion {
namespace debugviewpp {
Message::Message(double time, FILETIME systemTime, DWORD pid, const std::string& processName, const std::string& msg, COLORREF color) :
time(time),
systemTime(systemTime),
processId(pid),
processName(processName),
text(msg),
color(color)
{
}
bool LogFile::Empty() const
{
return m_messages.empty();
}
void LogFile::Clear()
{
m_messages.clear();
m_messages.shrink_to_fit();
m_storage.Clear();
m_storage.shrink_to_fit();
m_processInfo.Clear();
}
void LogFile::Add(const Message& msg)
{
auto props = m_processInfo.GetProcessProperties(msg.processId, WStr(msg.processName).str());
m_messages.emplace_back(InternalMessage(msg.time, msg.systemTime, props.uid));
m_storage.Add(msg.text);
}
int LogFile::BeginIndex() const
{
return 0;
}
int LogFile::EndIndex() const
{
return static_cast<int>(m_messages.size());
}
int LogFile::Count() const
{
return static_cast<int>(m_messages.size());
}
Message LogFile::operator[](int i) const
{
auto& msg = m_messages[i];
auto props = m_processInfo.GetProcessProperties(msg.uid);
return Message(msg.time, msg.systemTime, props.pid, Str(props.name).str(), m_storage[i], props.color);
}
int LogFile::GetHistorySize() const
{
return m_historySize;
}
void LogFile::SetHistorySize(int size)
{
m_historySize = size;
}
void LogFile::Append(const LogFile& logfile, int beginIndex, int endIndex)
{
for (int i = beginIndex; i <= endIndex; ++i)
{
Add(logfile[i]);
}
}
} // namespace debugviewpp
} // namespace fusion