Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
63e71d0d
Commit
63e71d0d
authored
4 years ago
by
Fabian Tërnava
Browse files
Options
Downloads
Patches
Plain Diff
added comparison between new generation and existing file
parent
585af1bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/applications/AronGenerator/main.cpp
+33
-15
33 additions, 15 deletions
source/RobotAPI/applications/AronGenerator/main.cpp
with
33 additions
and
15 deletions
source/RobotAPI/applications/AronGenerator/main.cpp
+
33
−
15
View file @
63e71d0d
...
...
@@ -91,6 +91,11 @@ int main(int argc, char* argv[])
}
std
::
filesystem
::
path
input_file
(
filename
);
if
(
!
std
::
filesystem
::
exists
(
input_file
))
{
std
::
cerr
<<
"The input file does not exist!"
<<
std
::
endl
;
}
if
(
input_file
.
extension
().
string
()
!=
".xml"
)
{
std
::
cerr
<<
"The file you passed has the wrong type."
<<
std
::
endl
;
...
...
@@ -98,6 +103,8 @@ int main(int argc, char* argv[])
std
::
string
new_name_with_extension
=
input_file
.
filename
().
replace_extension
(
""
).
string
();
new_name_with_extension
+=
".aron.generated.h"
;
std
::
string
output_file_path
=
output
+
"/"
+
new_name_with_extension
;
std
::
filesystem
::
path
output_file
(
output_file_path
);
reader
.
parseFile
(
input_file
);
if
(
verbose
)
...
...
@@ -121,14 +128,10 @@ int main(int argc, char* argv[])
std
::
cout
<<
"--> Found "
<<
writer
.
getTypeClasses
().
size
()
<<
" type classes."
<<
std
::
endl
;
}
std
::
ofstream
ofs
;
std
::
string
output_current_file
=
output
+
"/"
+
new_name_with_extension
;
ofs
.
open
(
output_current_file
);
time_t
now
=
time
(
0
);
char
*
dt
=
ctime
(
&
now
);
std
::
stringstream
file_new_content
;
ofs
<<
"/*
\n
\
file_new_content
<<
"\
/*
\n
\
* This file is part of ArmarX.
\n
\
*
\n
\
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
\n
\
...
...
@@ -151,7 +154,6 @@ int main(int argc, char* argv[])
*************************************************************************
\n
\
* WARNING: This file is autogenerated.
\n
\
* Original file: "
+
filename
+
"
\n
\
* Timestamp of generation: "
+
dt
+
"\
* Please do not edit since your changes may be overwritten on the next generation
\n
\
* If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
\n
\
*************************************************************************
\n
\
...
...
@@ -169,7 +171,7 @@ int main(int argc, char* argv[])
CppWriterPtr
w
=
CppWriterPtr
(
new
CppWriter
());
c
->
writeCpp
(
w
);
ofs
<<
w
->
getString
();
file_new_content
<<
w
->
getString
();
if
(
verbose
)
{
...
...
@@ -178,17 +180,33 @@ int main(int argc, char* argv[])
if
(
i
!=
writer
.
getTypeClasses
().
size
())
{
ofs
<<
"
\n
"
;
ofs
<<
"// *************
\n
"
;
ofs
<<
"// Here comes another auto-generated class. Don't mind the duplicated includes - everything is guarded!
\n
"
;
ofs
<<
"// *************
\n
"
;
ofs
<<
"
\n
"
;
file_new_content
<<
"
\n
"
;
file_new_content
<<
"// *************
\n
"
;
file_new_content
<<
"// Here comes another auto-generated class. Don't mind the duplicated includes - everything is guarded!
\n
"
;
file_new_content
<<
"// *************
\n
"
;
file_new_content
<<
"
\n
"
;
}
}
// check if file already exists
if
(
std
::
filesystem
::
exists
(
output_file
))
{
std
::
ifstream
ifs
(
output_file_path
);
std
::
string
file_content
((
std
::
istreambuf_iterator
<
char
>
(
ifs
)),
(
std
::
istreambuf_iterator
<
char
>
()));
if
(
file_content
==
file_new_content
.
str
())
{
std
::
cout
<<
"File content not changed for <"
+
output_file_path
+
">"
<<
std
::
endl
;
exit
(
0
);
}
}
std
::
ofstream
ofs
;
ofs
.
open
(
output_file_path
);
ofs
<<
file_new_content
.
str
();
ofs
.
close
();
std
::
cout
<<
"Finished generating <"
+
output_
current_file
+
">"
<<
std
::
endl
;
std
::
cout
<<
"Finished generating <"
+
output_
file_path
+
">"
<<
std
::
endl
;
}
catch
(
const
cxxopts
::
OptionException
&
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment