Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mytests
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songxinkai
mytests
Commits
ed5434c0
Commit
ed5434c0
authored
Jan 15, 2020
by
songxinkai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish CMakeLists.txt in c++/protobuf
parent
8d19ba6f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
20 deletions
+38
-20
c++/protobuf/CMakeLists.txt
+7
-19
c++/protobuf/pigs.pt
+3
-0
c++/protobuf/test_0.cpp
+28
-1
No files found.
c++/protobuf/CMakeLists.txt
View file @
ed5434c0
cmake_minimum_required
(
VERSION 3.1
)
cmake_minimum_required
(
VERSION 3.1
)
set
(
CMAKE_CXX_COMPILER
"/home/songxinkai/user/local/bin/g++"
)
project
(
test_0
)
project
(
test_0
)
set
(
CMAKE_BUILD_TYPE
Debug
)
set
(
CMAKE_BUILD_TYPE
Release
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
--std=c++11 -
g -O0
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
--std=c++11 -
pthread
"
)
set
(
protobuf_exec
"/home/songxinkai/protobuf-3.11.2/build/bin/protoc"
)
set
(
protobuf_include_dir
"/home/songxinkai/protobuf-3.11.2/src"
)
set
(
protobuf_include_dir
"/home/songxinkai/protobuf-3.11.2/build"
)
set
(
protobuf_library
"
${
protobuf_library
}
/home/songxinkai/protobuf-3.11.2/src/.libs/libprotoc.so"
)
set
(
protobuf_library
"/home/songxinkai/protobuf-3.11.2/build/lib/libprotobuf.so"
)
set
(
protobuf_library
"
${
protobuf_library
}
/home/songxinkai/protobuf-3.11.2/src/.libs/libprotobuf.so"
)
# set(eden_include "eden.ph.h")
# set(eden_src "eden.pb.cc")
# add_custom_command(OUTPUT eden_include eden_src
# COMMAND "protoc eden.proto --cpp_out=."
# )
#
# message("=========== ===========")
# message("${eden_include} ${eden_src}")
# message("=========== ===========")
set
(
test_src
"
${
PROJECT_SOURCE_DIR
}
/test_0.cpp"
)
set
(
test_src
"
${
PROJECT_SOURCE_DIR
}
/test_0.cpp"
)
set
(
eden_src
"
${
PROJECT_SOURCE_DIR
}
/eden.pb.cc"
)
set
(
eden_src
"
${
PROJECT_SOURCE_DIR
}
/eden.pb.cc"
)
add_executable
(
test
"
${
test_src
}
"
"
${
eden_src
}
"
)
add_executable
(
test
_exec
"
${
test_src
}
"
"
${
eden_src
}
"
"eden.pb.h
"
)
include_directories
(
"
${
protobuf_include_dir
}
"
"
${
PROJECT_SOURCE_DIR
}
"
)
include_directories
(
"
${
protobuf_include_dir
}
"
"
${
PROJECT_SOURCE_DIR
}
"
)
target_link_libraries
(
test
"
${
protobuf_library
}
"
)
target_link_libraries
(
test
_exec
"/home/songxinkai/protobuf-3.11.2/src/.libs/libprotoc.so"
"/home/songxinkai/protobuf-3.11.2/src/.libs/libprotobuf.so"
"/home/songxinkai/protobuf-3.11.2/src/.libs/libprotobuf-lite.so
"
)
c++/protobuf/pigs.pt
0 → 100644
View file @
ed5434c0
count: 1
speed: 3.3
sight: 5.5
c++/protobuf/test_0.cpp
View file @
ed5434c0
#include <iostream>
#include <iostream>
#include "eden.ph.h"
#include "eden.pb.h"
#include <fstream>
#include <sstream>
#include <string>
#include "google/protobuf/text_format.h"
using
namespace
std
;
using
namespace
std
;
int
main
(){
int
main
(){
cout
<<
"Hello!"
<<
endl
;
eden
::
pigs
Pigs
;
Pigs
.
set_count
(
10
);
string
str
;
cout
<<
"0"
<<
endl
;
google
::
protobuf
::
TextFormat
::
PrintToString
(
Pigs
,
&
str
);
cout
<<
str
<<
endl
;
// fstream input("../pigs.pt", ios::in | ios::binary);
// if (!input) {
// cout << "pigs.pt" << ": File not found. Creating a new file." << endl;
// } else if (!Pigs->ParseFromIstream(&input)) {
// cerr << "Failed to parse pigs." << endl;
// }
cout
<<
"1"
<<
endl
;
std
::
ostringstream
conf_ss
;
conf_ss
<<
std
::
ifstream
(
"../pigs.pt"
).
rdbuf
();
cout
<<
"2"
<<
endl
;
google
::
protobuf
::
TextFormat
::
ParseFromString
(
conf_ss
.
str
(),
&
Pigs
);
cout
<<
"3"
<<
endl
;
cout
<<
Pigs
.
count
()
<<
endl
;
return
0
;
return
0
;
}
}
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