Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Philip Trettner
aion
Commits
f946a7bc
Commit
f946a7bc
authored
Aug 10, 2017
by
Philip Trettner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed Qt5 dependency
parent
8e0104c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
47 deletions
+51
-47
CMakeLists.txt
CMakeLists.txt
+1
-4
src/aion/ActionLabel.cc
src/aion/ActionLabel.cc
+13
-16
src/aion/ActionPackage.cc
src/aion/ActionPackage.cc
+1
-4
src/aion/common/NetMessage.cc
src/aion/common/NetMessage.cc
+35
-19
src/aion/common/NetMessage.hh
src/aion/common/NetMessage.hh
+1
-4
No files found.
CMakeLists.txt
View file @
f946a7bc
...
...
@@ -9,10 +9,7 @@ target_include_directories(aion PUBLIC src/)
if
(
MSVC
)
target_compile_options
(
aion PUBLIC /MP
)
else
()
target_compile_options
(
aion PRIVATE -Wall -Werror
)
target_compile_options
(
aion PRIVATE -Wall -Werror
-fPIC
)
target_compile_options
(
aion PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>
)
endif
()
find_package
(
Qt5Core REQUIRED
)
target_link_libraries
(
aion PRIVATE
${
Qt5Core_LIBRARIES
}
)
src/aion/ActionLabel.cc
View file @
f946a7bc
...
...
@@ -2,12 +2,11 @@
#include "common/format.hh"
#include <string>
#include <algorithm>
#include <vector>
#include <mutex>
#include <QString>
#include <QFileInfo>
#include "ActionEntry.hh"
using
namespace
aion
;
...
...
@@ -48,18 +47,15 @@ void writeTime(ActionEntry &e)
std
::
string
ActionLabel
::
shortDesc
()
const
{
auto
filename
=
QFileInfo
(
QString
::
fromStdString
(
mFile
)).
fileName
().
toStdString
();
auto
filename
=
mFile
;
if
(
filename
.
find
(
'/'
)
!=
std
::
string
::
npos
)
filename
=
filename
.
substr
(
filename
.
rfind
(
'/'
)
+
1
);
if
(
filename
.
find
(
'\\'
)
!=
std
::
string
::
npos
)
filename
=
filename
.
substr
(
filename
.
rfind
(
'\\'
)
+
1
);
auto
name
=
mName
;
if
(
name
.
empty
())
{
QString
n
=
QString
::
fromStdString
(
mFunction
);
n
=
n
.
mid
(
0
,
n
.
indexOf
(
'('
));
n
=
n
.
mid
(
n
.
lastIndexOf
(
' '
)
+
1
);
if
(
n
.
contains
(
':'
))
n
=
n
.
mid
(
n
.
lastIndexOf
(
':'
)
+
1
);
name
=
n
.
toStdString
()
+
"()"
;
}
name
=
nameOrFunc
();
else
name
=
"
\"
"
+
name
+
"
\"
"
;
...
...
@@ -71,10 +67,11 @@ std::string ActionLabel::nameOrFunc() const
auto
name
=
mName
;
if
(
name
.
empty
())
{
QString
n
=
QString
::
fromStdString
(
mFunction
);
n
=
n
.
mid
(
0
,
n
.
indexOf
(
'('
));
n
=
n
.
mid
(
n
.
lastIndexOf
(
' '
)
+
1
);
name
=
n
.
toStdString
()
+
"()"
;
name
=
mFunction
;
name
=
name
.
substr
(
0
,
name
.
find
(
'('
));
name
=
name
.
substr
(
name
.
rfind
(
' '
)
+
1
);
// TODO: more special cases
name
+=
"()"
;
}
return
name
;
...
...
src/aion/ActionPackage.cc
View file @
f946a7bc
...
...
@@ -5,9 +5,6 @@
#include "common/NetMessage.hh"
#include <QFileInfo>
#include <QDir>
using
namespace
aion
;
ActionPackage
::
ActionPackage
(
std
::
vector
<
ActionEntry
>
const
&
entries
,
std
::
vector
<
ActionLabel
*>
const
&
labels
)
...
...
@@ -24,7 +21,7 @@ ActionPackage::~ActionPackage()
void
ActionPackage
::
saveToFile
(
const
std
::
string
&
filename
)
const
{
QFileInfo
(
QString
::
fromStdString
(
filename
)).
dir
().
mkpath
(
"."
);
//
QFileInfo(QString::fromStdString(filename)).dir().mkpath(".");
NetMessage
m
;
...
...
src/aion/common/NetMessage.cc
View file @
f946a7bc
...
...
@@ -2,9 +2,7 @@
#include "snappy/snappy.hh"
#include <QIODevice>
#include <QFile>
#include <QByteArray>
#include <fstream>
#include "NetMessageReader.hh"
...
...
@@ -295,10 +293,8 @@ UniqueNetMessage NetMessage::cloneUnique() const
return
UniqueNetMessage
(
clone
());
}
void
NetMessage
::
send
(
QIODevice
*
stream
)
void
NetMessage
::
send
(
std
::
vector
<
char
>
&
output
)
{
assert
(
stream
->
isWritable
());
compress
();
unsigned
int
size
=
(
unsigned
)
mData
.
size
();
...
...
@@ -306,7 +302,8 @@ void NetMessage::send(QIODevice *stream)
// assemble header
// Write type and option byte
stream
->
putChar
(
mOptions
);
output
.
clear
();
output
.
push_back
(
mOptions
);
// decompose size
...
...
@@ -337,7 +334,7 @@ void NetMessage::send(QIODevice *stream)
firstByte
+=
1
<<
7
;
needNextByte
=
true
;
}
stream
->
putChar
(
firstByte
);
output
.
push_back
(
firstByte
);
if
(
needNextByte
)
{
...
...
@@ -351,7 +348,7 @@ void NetMessage::send(QIODevice *stream)
secondByte
+=
1
<<
7
;
needNextByte
=
true
;
}
stream
->
putChar
(
secondByte
);
output
.
push_back
(
secondByte
);
if
(
needNextByte
)
{
...
...
@@ -365,7 +362,7 @@ void NetMessage::send(QIODevice *stream)
thirdByte
+=
1
<<
7
;
needNextByte
=
true
;
}
stream
->
putChar
(
thirdByte
);
output
.
push_back
(
thirdByte
);
if
(
needNextByte
)
{
...
...
@@ -379,7 +376,7 @@ void NetMessage::send(QIODevice *stream)
forthByte
+=
1
<<
7
;
needNextByte
=
true
;
}
stream
->
putChar
(
forthByte
);
output
.
push_back
(
forthByte
);
assert
(
!
needNextByte
);
}
...
...
@@ -388,33 +385,52 @@ void NetMessage::send(QIODevice *stream)
// write actual data
if
(
size
>
0
)
stream
->
write
(
&
mData
[
0
],
size
);
{
auto
hSize
=
output
.
size
();
output
.
resize
(
output
.
size
()
+
size
);
std
::
copy
(
begin
(
mData
),
end
(
mData
),
begin
(
output
)
+
hSize
);
}
}
void
NetMessage
::
writeToFile
(
const
std
::
string
&
filename
)
{
QFile
file
(
QString
::
fromStdString
(
filename
)
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
std
::
ofstream
file
(
filename
);
if
(
!
file
.
good
(
))
{
std
::
cerr
<<
"Unable to open "
<<
filename
<<
" for writing"
<<
std
::
endl
;
return
;
}
send
(
&
file
);
std
::
vector
<
char
>
data
;
send
(
data
);
file
.
write
(
data
.
data
(),
data
.
size
());
}
static
std
::
vector
<
char
>
ReadAllBytes
(
std
::
string
const
&
filename
)
{
std
::
ifstream
ifs
(
filename
,
std
::
ios
::
binary
|
std
::
ios
::
ate
);
std
::
ifstream
::
pos_type
pos
=
ifs
.
tellg
();
std
::
vector
<
char
>
result
(
pos
);
ifs
.
seekg
(
0
,
std
::
ios
::
beg
);
ifs
.
read
(
result
.
data
(),
pos
);
return
result
;
}
SharedNetMessage
NetMessage
::
readFromFile
(
const
std
::
string
&
filename
)
{
QFile
file
(
QString
::
fromStdString
(
filename
));
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
if
(
!
std
::
ifstream
(
filename
).
good
())
{
std
::
cerr
<<
"Unable to open "
<<
filename
<<
" for reading"
<<
std
::
endl
;
return
nullptr
;
}
QByteArray
ba
=
file
.
readAll
(
);
auto
bytes
=
ReadAllBytes
(
filename
);
NetMessageReader
r
;
r
.
pushBytes
(
b
a
.
constData
(),
ba
.
size
());
r
.
pushBytes
(
b
ytes
.
data
(),
bytes
.
size
());
NetMessage
*
m
=
nullptr
;
if
(
!
r
.
receiveMessage
(
m
))
...
...
src/aion/common/NetMessage.hh
View file @
f946a7bc
...
...
@@ -15,9 +15,6 @@
#include "NetMessageFlags.hh"
AION_SHARED
(
class
,
QIODevice
);
namespace
aion
{
#ifdef NETMESSAGE_VALUE_TYPE
...
...
@@ -285,7 +282,7 @@ public:
// TODO: copy ctor, assignment op, create from data
/// Writes a header and the content of this message to a stream
void
send
(
QIODevice
*
stream
);
void
send
(
std
::
vector
<
char
>
&
output
);
void
writeToFile
(
std
::
string
const
&
filename
);
static
SharedNetMessage
readFromFile
(
std
::
string
const
&
filename
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment