Implements loading of proto files
This commit is contained in:
6
src/CMakeLists.txt
Normal file
6
src/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
set(assignment_SOURCES
|
||||
main.cpp)
|
||||
|
||||
add_executable(main ${assignment_SOURCES})
|
||||
target_link_libraries(main proto ${PROTOBUF_LIBRARY})
|
40
src/main.cpp
Normal file
40
src/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "protocol_buffers_definitions/recordings.pb.h"
|
||||
|
||||
|
||||
using namespace ::indoors::proto;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Verify that the version of the library that we linked against is
|
||||
// compatible with the version of the headers we compiled against.
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
std::cout << "ESRI C++ code assignment\n";
|
||||
|
||||
Recording recording;
|
||||
Position positions;
|
||||
|
||||
std::fstream input(argv[1], std::ios::in | std::ios::binary);
|
||||
if (!recording.ParseFromIstream(&input)) {
|
||||
std::cerr << "Failed to parse input file.\n";
|
||||
return -1;
|
||||
}
|
||||
std::cout.precision(17);
|
||||
for (int i=0; i < recording.magnetics_size(); i++) {
|
||||
auto const& s = recording.magnetics(i);
|
||||
std::cout << s.t() << ": [" << s.x() << ", " << s.y() << ", " << s.z() << "]\n";
|
||||
}
|
||||
for (int i=0; i < recording.positions_size(); i++) {
|
||||
auto const& s = recording.positions(i);
|
||||
std::cout << s.t() << ": [" << s.x() << ", " << s.y() << "]\n";
|
||||
}
|
||||
|
||||
// Optional: Delete all global objects allocated by libprotobuf.
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user