{"id":327999,"date":"2022-01-14T09:00:42","date_gmt":"2022-01-14T09:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=327999"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=327999","title":{"rendered":"<span>\u0420\u0430\u0437\u0431\u043e\u0440 Protobuf \u0432 Visual Studio \u043f\u043e\u0434 \u0421++<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Protobuf \u043d\u0430 \u0421++ \u0432 VS<\/h3>\n<p>Protobuf \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043e \u0441 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Protobuf, \u0430 \u0442\u0430\u043a \u0436\u0435, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u0430\u043c\u0438\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 protobuf \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041a\u043b\u044e\u0447\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u043c\u0435\u0440\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 .proto \u0438 \u043a\u043e\u0434\u0430 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0424\u0430\u0439\u043b .proto \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u0430\u043c \u0444\u0430\u0439\u043b .proto \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u044b, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 protobuf<\/h3>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u0438\u043a\u0431\u0435\u0437 \u043f\u0440\u043e\u0448\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0430 \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043f\u043e\u043a\u043e\u0432\u044b\u0440\u044f\u0442\u044c protobuf. \u0410 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>CMake<\/p>\n<\/li>\n<li>\n<p>VS 2019<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 Protobuf<\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Protobuf \u0441 github<\/h4>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0430\u0435\u043c Protobuf \u0441 <a href=\"https:\/\/github.com\/protocolbuffers\/protobuf\" rel=\"noopener noreferrer nofollow\">github<\/a>. \u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Release \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0430 protobuf-cpp-version.zip. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u044f 3.19.0, \u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442. <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0430\u0440\u0445\u0438\u0432, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 vs, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 &#8212; \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0442\u0435\u0445, \u0443 \u043a\u043e\u0433\u043e \u043b\u0430\u043f\u043a\u0438. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u0441\u0431\u043e\u0440\u043a\u0443 protobuf \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b  readme  \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/protocolbuffers\/protobuf\/blob\/master\/cmake\/README.md\" rel=\"noopener noreferrer nofollow\">protobuf\/cmake\/README.md<\/a>, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432\u044b\u0436\u0438\u043c\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b\u0445 \u043d\u0438\u0436\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043e\u0442 VS. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c <em>x86_x64 Cross Tools Command Promt for VS 2019<\/em>. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043b\u0438\u0448\u043d\u0438\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u043d\u0430\u0448\u0438\u043c \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u043c protobuf.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  C:\\Path\\to\\ &#8212; \u0430\u0434\u0440\u0435\u0441 \u0434\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u0432 \u0441\u0430\u043c\u043e\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0436\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u0442\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"bash\"> C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community>E:  E:\\><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437 readme. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0421Make, \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 path \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u043c\u0443 cmake, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">E:\\AllWs\\vs\\protoExample\\proto_settings> cmake --version cmake version 3.17.0-rc1<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\"> C:\\Path\\to\\protobuf\\cmake>mkdir build &amp; cd build  C:\\Path\\to\\protobuf\\cmake\\build>  C:\\Path\\to\\protobuf\\cmake\\build>mkdir solution &amp; cd solution  C:\\Path\\to\\protobuf\\cmake\\build\\solution>cmake -G \"Visual Studio 16 2019\" ^  -DCMAKE_INSTALL_PREFIX=..\/..\/..\/..\/install ^  ..\/..<\/code><\/pre>\n<p>\u0427\u0430\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u043b\u0438 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 VS19. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443 \u0441\u0435\u0431\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 solution \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432, \u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b *.sln. \u041e\u0442\u043a\u0440\u044b\u0432 \u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c: <\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"355\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/620\/a52\/903\/620a529035a7b5d3241a16e82ebbb9f2.png\" data-width=\"327\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c INSTALL. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d \u0430\u0440\u0445\u0438\u0432 \u0441 Protobuf, \u0442\u0430\u043c \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 install, \u0438 \u0442\u0430\u043c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438: <\/p>\n<ul>\n<li>\n<p>bin<\/p>\n<\/li>\n<li>\n<p>include<\/p>\n<\/li>\n<li>\n<p>lib<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 release \u0438 debug \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b lib:<\/p>\n<ul>\n<li>\n<p>libprotobuf.lib<\/p>\n<\/li>\n<li>\n<p>libprotobufd.lib<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 VS \u043f\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 protobuf<\/h4>\n<p>\u0414\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 protobuf \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c *.proto. \u041e\u0434\u043d\u0430\u043a\u043e, \u0444\u0430\u0439\u043b \u0441 \u0442\u0430\u043a\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e\u0433\u043e \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u0444\u0430\u0439\u043b\u0430, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 bin, \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c protoc.exe. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043a\u0438\u043d\u0435\u043c protoc.exe. \u0422\u0443\u0434\u0430 \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c: <\/p>\n<details class=\"spoiler\">\n<summary>addressbook.proto<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"powershell\">syntax = \"proto2\";  package tutorial;  message Person {   optional string name = 1;   optional int32 id = 2;   optional string email = 3;    enum PhoneType {     MOBILE = 0;     HOME = 1;     WORK = 2;   }    message PhoneNumber {     optional string number = 1;     optional PhoneType type = 2 [default = HOME];   }    repeated PhoneNumber phones = 4; }  message AddressBook {   repeated Person people = 1; }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 addressbook.proto \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"bash\">protoc_path\\protoc.exe --cpp_out=. addressbook.proto<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0443 \u043b\u0435\u043d\u044c, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 *.bat, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"bash\">@set file_name=addressbook @set mypath=%cd% @if exist %file_name%.proto (  %mypath%\\protoc.exe --cpp_out=. %file_name%.proto @echo %file_name%.pb.cc and %file_name%.pb.h created) @pause<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f <a href=\"http:\/\/addressbook.pb.cc\" rel=\"noopener noreferrer nofollow\">addressbook.pb.cc<\/a> \u0438 addressbook.pb.h.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f \u0443 \u043d\u0430\u0441 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d. \u0423 \u043d\u0430\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/developers.google.com\/protocol-buffers\/docs\/cpptutorial\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043c\u044b \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 VS, \u0432 main \u0444\u0430\u0439\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0434. \u042f \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>main.cpp<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;iostream> #include &lt;fstream> #include &lt;string> #include \"addressbook.pb.h\" using namespace std; #define READ_EXAMPLE 1 #define WRITE_EXAMPLE 2 #define TYPE_EXAMPLE WRITE_EXAMPLE  \/\/ This function fills in a Person message based on user input. void PromptForAddress(tutorial::Person* person) {     cout &lt;&lt; \"Enter person ID number: \";     int id;     cin >> id;     person->set_id(id);     cin.ignore(256, '\\n');      cout &lt;&lt; \"Enter name: \";     getline(cin, *person->mutable_name());      cout &lt;&lt; \"Enter email address (blank for none): \";     string email;     getline(cin, email);     if (!email.empty()) {         person->set_email(email);     }      while (true) {         cout &lt;&lt; \"Enter a phone number (or leave blank to finish): \";         string number;         getline(cin, number);         if (number.empty()) {             break;         }          tutorial::Person::PhoneNumber* phone_number = person->add_phones();         phone_number->set_number(number);          cout &lt;&lt; \"Is this a mobile, home, or work phone? \";         string type;         getline(cin, type);         if (type == \"mobile\") {             phone_number->set_type(tutorial::Person::MOBILE);         }         else if (type == \"home\") {             phone_number->set_type(tutorial::Person::HOME);         }         else if (type == \"work\") {             phone_number->set_type(tutorial::Person::WORK);         }         else {             cout &lt;&lt; \"Unknown phone type.  Using default.\" &lt;&lt; endl;         }     }  }  \/\/ Iterates though all people in the AddressBook and prints info about them. void ListPeople(const tutorial::AddressBook&amp; address_book) {     for (int i = 0; i &lt; address_book.people_size(); i++) {         const tutorial::Person&amp; person = address_book.people(i);          cout &lt;&lt; \"Person ID: \" &lt;&lt; person.id() &lt;&lt; endl;         cout &lt;&lt; \"  Name: \" &lt;&lt; person.name() &lt;&lt; endl;         if (person.has_email()) {             cout &lt;&lt; \"  E-mail address: \" &lt;&lt; person.email() &lt;&lt; endl;         }          for (int j = 0; j &lt; person.phones_size(); j++) {             const tutorial::Person::PhoneNumber&amp; phone_number = person.phones(j);              switch (phone_number.type()) {             case tutorial::Person::MOBILE:                 cout &lt;&lt; \"  Mobile phone #: \";                 break;             case tutorial::Person::HOME:                 cout &lt;&lt; \"  Home phone #: \";                 break;             case tutorial::Person::WORK:                 cout &lt;&lt; \"  Work phone #: \";                 break;             }             cout &lt;&lt; phone_number.number() &lt;&lt; endl;         }     } }   \/\/ Main function:  Reads the entire address book from a file, \/\/   adds one person based on user input, then writes it back out to the same \/\/   file. 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;      if (argc != 2) {         cerr &lt;&lt; \"Usage:  \" &lt;&lt; argv[0] &lt;&lt; \" ADDRESS_BOOK_FILE\" &lt;&lt; endl;         return -1;     }      tutorial::AddressBook address_book;  #if(TYPE_EXAMPLE == WRITE_EXAMPLE)     {         \/\/ Read the existing address book.         fstream input(argv[1], ios::in | ios::binary);         if (!input) {             cout &lt;&lt; argv[1] &lt;&lt; \": File not found.  Creating a new file.\" &lt;&lt; endl;         }         else if (!address_book.ParseFromIstream(&amp;input)) {             cerr &lt;&lt; \"Failed to parse address book.\" &lt;&lt; endl;             return -1;         }     }      \/\/ Add an address.     PromptForAddress(address_book.add_people());     PromptForAddress(address_book.add_people());      {         \/\/ Write the new address book back to disk.         fstream output(argv[1], ios::out | ios::trunc | ios::binary);         if (!address_book.SerializeToOstream(&amp;output)) {             cerr &lt;&lt; \"Failed to write address book.\" &lt;&lt; endl;             return -1;         }     }  #elif(TYPE_EXAMPLE == READ_EXAMPLE)      {         \/\/ Read the existing address book.         fstream input(argv[1], ios::in | ios::binary);         if (!address_book.ParseFromIstream(&amp;input)) {             cerr &lt;&lt; \"Failed to parse address book.\" &lt;&lt; endl;             return -1;         }     }      ListPeople(address_book);  #endif     \/\/ Optional:  Delete all global objects allocated by libprotobuf.     google::protobuf::ShutdownProtobufLibrary();      return 0; }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e protoc.exe. \u041c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u043a\u043b\u0430\u0432\u0438\u0448 Alt+Shift+A. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0430\u0448\u0438 \u0444\u0430\u0439\u043b\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0442\u0443\u0442 \u043c\u044b \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u043f\u043a\u0430\u043c inclune \u0438 lib. \u0412 \u043f\u0430\u043f\u043a\u0435 lib \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 libprotobuf.lib (\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 Release) \u0438\u043b\u0438 libprotobufd.lib (\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 debug), \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 include. \u041f\u0440\u043e\u0441\u0442\u043e \u043a\u0438\u0434\u0430\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0430\u043f\u043a\u0443 include, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 &#171;<strong><em>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2192 \u0421\/\u0421++ \u2192 \u041e\u0431\u0449\u0438\u0435 \u2192 \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/em><\/strong>&#187; \u043f\u0443\u0442\u044c \u0434\u043e \u043f\u0430\u043f\u043a\u0438 include.<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f main \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437 \u0441\u0440\u0435\u0434\u044b, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <strong>&#171;<em>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2192 \u041e\u0442\u043b\u0430\u0434\u043a\u0430<\/em>&#171;<\/strong> \u0432 \u043f\u043e\u043b\u0435 <strong>&#171;<em>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/em>&#171;<\/strong> \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u044f \u043e\u0431\u043e\u0437\u0432\u0430\u043b \u0435\u0433\u043e \u043a\u0430\u043a &#171;addressbook.bin&#187;.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0430\u043c\u043e\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <strong>&#171;<em>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2192 \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/em>&#171;<\/strong> \u0432 \u043f\u043e\u043b\u0435 <strong>&#171;<em>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/em>&#171;<\/strong> \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c &#171;<strong><em>\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u0430\u044f\/\u041c\u0422<\/em><\/strong>&#171;. \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<h3>\u0420\u0430\u0437\u0431\u043e\u0440 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/h3>\n<p>\u0412\u043e\u0442, \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<h4>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 *.proto<\/h4>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 protobuf, \u043c\u044b \u043d\u0435 \u0432\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044c \u044d\u0442\u0443 \u0442\u0435\u043c\u0443. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043f\u043e\u043b\u0435 <code>optional int32 id = 2;<\/code>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0439\u0434\u0451\u043c \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u0438\u043a, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">\/\/ optional int32 id = 2; inline bool Person::_internal_has_id() const; inline bool Person::has_id() const; inline void Person::clear_id(); inline int32_t Person::_internal_id() const; inline int32_t Person::id() const; inline void Person::_internal_set_id(int32_t value); inline void Person::set_id(int32_t value);<\/code><\/pre>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u044f \u0441\u043a\u0440\u044b\u043b, \u0437\u0430 \u043d\u0435\u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0418\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 repeated, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 add_variableName(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043c\u0435\u0442\u043e\u0434 \u043e\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 _size, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>range based for<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">    tutorial::Person person;     person.add_phones()->set_number(\"numb1\");     person.add_phones()->set_number(\"numb2\");     for (auto&amp; phone : pers.phones())     {         std::cout &lt;&lt; phone.number() &lt;&lt; std::endl;     }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u043b\u0430\u0441\u0441 Person \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d tutorial. \u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0432 \u0444\u0430\u0439\u043b\u0435 *.proto \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 <code>package tutorial<\/code>. \u042d\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b \u0442\u043e\u0433\u0434\u0430 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>\u0421 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 string \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 set, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 *mutable \u043c\u0435\u0442\u043e\u0434\u044b. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">        tutorial::Person person;         person.set_name(\"name\");         *person.mutable_name() += \" surname \";         std::cout &lt;&lt; person.name();<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Message<\/code>. \u0412 \u043d\u0451\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0438\u043c\u0435\u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 Serialize, \u0430 \u0434\u043b\u044f \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441 Pasre, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code>    tutorial::AddressBook addr_book1;     addr_book1.add_people()->set_email(\"555-555-555\");     std::string Serialized = addr_book1.SerializeAsString();          tutorial::AddressBook addr_book2;     addr_book2.ParseFromString(Serialized);<\/code><\/pre>\n<h4>\u0420\u0430\u0437\u0431\u043e\u0440 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442<\/p>\n<pre><code class=\"cpp\">#define TYPE_EXAMPLE WRITE_EXAMPLE<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0434\u0432\u0443\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0432\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438.<\/p>\n<pre><code>Enter person ID number: 170 Enter name: name1 Enter email address (blank for none): mail1 Enter a phone number (or leave blank to finish): 1234567 Is this a mobile, home, or work phone? mobile Enter a phone number (or leave blank to finish): Enter person ID number: 85 Enter name: name2 Enter email address (blank for none): mail2 Enter a phone number (or leave blank to finish): 7654321 Is this a mobile, home, or work phone? mobile Enter a phone number (or leave blank to finish):<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"128\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1d8\/2a0\/379\/1d82a0379c41c6aacbb7d06945cc1a47.png\" data-width=\"852\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a\u0430\u044f-\u0442\u043e \u0430\u0431\u0440\u0430\u043a\u0430\u0434\u0430\u0431\u0440\u0430 \u0432 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435, \u0437\u0430\u0442\u043e \u0432 hex \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f \u0432\u044b\u0431\u0440\u0430\u043b 170 \u0438 85 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 id, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u043b\u0435\u0433\u0447\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0434\u0430 \u0438 int32 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b. \u0412 hex \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a AA \u0438 55. \u0412 protobuf \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043a\u043b\u044e\u0447 &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041a\u043b\u044e\u0447 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"(fieldNumber &lt;&lt; 3) | wireType. \" alt=\"(fieldNumber &lt;&lt; 3) | wireType. \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e9\/d3c\/709\/6e9d3c709a9998d664cdd017cc426c0d.svg\" width=\"269\" height=\"22\"\/><\/p>\n<p>field_number &#8212; \u043d\u043e\u043c\u0435\u0440 \u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b\u0435 *.proto. wire_type \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435 <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"116\" width=\"116\">\n<p>Wire_type<\/p>\n<\/th>\n<th data-colwidth=\"172\" width=\"172\">\n<p> Meaning  <\/p>\n<\/th>\n<th>\n<p>Used for<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>0<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>Varint<\/p>\n<\/td>\n<td>\n<p>int32, int64, uint32, uint64, sint32, sint64, bool, enum<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>1<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>64-bit<\/p>\n<\/td>\n<td>\n<p>fixed64, sfixed64, double<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>2<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>Length-delimited<\/p>\n<\/td>\n<td>\n<p>string, bytes, embedded messages, packed repeated fields<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>3<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>Start group<\/p>\n<\/td>\n<td>\n<p>groups (deprecated)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>4<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>End group<\/p>\n<\/td>\n<td>\n<p>groups (deprecated)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"116\" width=\"116\">\n<p>5<\/p>\n<\/td>\n<td data-colwidth=\"172\" width=\"172\">\n<p>32-bit<\/p>\n<\/td>\n<td>\n<p>fixed32, sfixed32, float<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439 \u0432\u044b\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u043a\u0430\u043a\u043e\u0439 \u043a\u043b\u044e\u0447 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 id <code>key = 2 &lt;&lt; 3 | 0 = 0x0010<\/code><\/p>\n<p>\u042d\u0442\u043e \u0436\u0435 \u0447\u0438\u0441\u043b\u043e \u043c\u044b \u0438 \u0432\u0438\u0434\u0438\u043c \u0432 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430 string, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435 name. \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 <code>1 &lt;&lt; 3 | 2 = 0x0A<\/code>. \u0417\u0430\u043c\u0435\u0447\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 name1 \u0438 name2 (0x04 \u0438 0x24 \u0431\u0430\u0439\u0442) \u0441\u0442\u043e\u0438\u0442 \u043d\u0435 0x0A \u0430 0x05. \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u0432\u043e\u0442 0x05 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u043d\u0430 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0434\u0451\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043b\u044e\u0447, \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">#define TYPE_EXAMPLE READ_EXAMPLE<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c protobuf \u0441  \u0441++.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/645505\/\"> https:\/\/habr.com\/ru\/post\/645505\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Protobuf \u043d\u0430 \u0421++ \u0432 VS<\/h3>\n<p>Protobuf \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0447\u0435\u0433\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043e \u0441 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Protobuf, \u0430 \u0442\u0430\u043a \u0436\u0435, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u0430\u043c\u0438\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 protobuf \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041a\u043b\u044e\u0447\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u043c\u0435\u0440\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 .proto \u0438 \u043a\u043e\u0434\u0430 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0424\u0430\u0439\u043b .proto \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u0430\u043c \u0444\u0430\u0439\u043b .proto \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u044b, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 protobuf<\/h3>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u0438\u043a\u0431\u0435\u0437 \u043f\u0440\u043e\u0448\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0430 \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043f\u043e\u043a\u043e\u0432\u044b\u0440\u044f\u0442\u044c protobuf. \u0410 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>CMake<\/p>\n<\/li>\n<li>\n<p>VS 2019<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 Protobuf<\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Protobuf \u0441 github<\/h4>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0430\u0435\u043c Protobuf \u0441 <a href=\"https:\/\/github.com\/protocolbuffers\/protobuf\" rel=\"noopener noreferrer nofollow\">github<\/a>. \u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Release \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u0432\u0438\u0434\u0430 protobuf-cpp-version.zip. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u044f 3.19.0, \u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442. <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0430\u0440\u0445\u0438\u0432, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 vs, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 &#8212; \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0442\u0435\u0445, \u0443 \u043a\u043e\u0433\u043e \u043b\u0430\u043f\u043a\u0438. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u0441\u0431\u043e\u0440\u043a\u0443 protobuf \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b  readme  \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/protocolbuffers\/protobuf\/blob\/master\/cmake\/README.md\" rel=\"noopener noreferrer nofollow\">protobuf\/cmake\/README.md<\/a>, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432\u044b\u0436\u0438\u043c\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b\u0445 \u043d\u0438\u0436\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043e\u0442 VS. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c <em>x86_x64 Cross Tools Command Promt for VS 2019<\/em>. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043b\u0438\u0448\u043d\u0438\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u043d\u0430\u0448\u0438\u043c \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u043c protobuf.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  C:\\Path\\to\\ &#8212; \u0430\u0434\u0440\u0435\u0441 \u0434\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u0442 \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u0432 \u0441\u0430\u043c\u043e\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0436\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u0442\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"bash\"> C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community>E:  E:\\><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437 readme. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0421Make, \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 path \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u043c\u0443 cmake, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">E:\\AllWs\\vs\\protoExample\\proto_settings> cmake --version cmake version 3.17.0-rc1<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\"> C:\\Path\\to\\protobuf\\cmake>mkdir build &amp; cd build  C:\\Path\\to\\protobuf\\cmake\\build>  C:\\Path\\to\\protobuf\\cmake\\build>mkdir solution &amp; cd solution  C:\\Path\\to\\protobuf\\cmake\\build\\solution>cmake -G \"Visual Studio 16 2019\" ^  -DCMAKE_INSTALL_PREFIX=..\/..\/..\/..\/install ^  ..\/..<\/code><\/pre>\n<p>\u0427\u0430\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u043b\u0438 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 VS19. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443 \u0441\u0435\u0431\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 solution \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432, \u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b *.sln. \u041e\u0442\u043a\u0440\u044b\u0432 \u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c: <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c INSTALL. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d \u0430\u0440\u0445\u0438\u0432 \u0441 Protobuf, \u0442\u0430\u043c \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 install, \u0438 \u0442\u0430\u043c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438: <\/p>\n<ul>\n<li>\n<p>bin<\/p>\n<\/li>\n<li>\n<p>include<\/p>\n<\/li>\n<li>\n<p>lib<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 release \u0438 debug \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b lib:<\/p>\n<ul>\n<li>\n<p>libprotobuf.lib<\/p>\n<\/li>\n<li>\n<p>libprotobufd.lib<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 VS \u043f\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 protobuf<\/h4>\n<p>\u0414\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 protobuf \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c *.proto. \u041e\u0434\u043d\u0430\u043a\u043e, \u0444\u0430\u0439\u043b \u0441 \u0442\u0430\u043a\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e\u0433\u043e \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u0444\u0430\u0439\u043b\u0430, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 bin, \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c protoc.exe. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043a\u0438\u043d\u0435\u043c protoc.exe. \u0422\u0443\u0434\u0430 \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c: <\/p>\n<details class=\"spoiler\">\n<summary>addressbook.proto<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"powershell\">syntax = \"proto2\";  package tutorial;  message Person {   optional string name = 1;   optional int32 id = 2;   optional string email = 3;    enum PhoneType {     MOBILE = 0;     HOME = 1;     WORK = 2;   }    message PhoneNumber {     optional string number = 1;     optional PhoneType type = 2 [default = HOME];   }    repeated PhoneNumber phones = 4; }  message AddressBook {   repeated Person people = 1; }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 addressbook.proto \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"bash\">protoc_path\\protoc.exe --cpp_out=. addressbook.proto<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0443 \u043b\u0435\u043d\u044c, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 *.bat, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"bash\">@set file_name=addressbook @set mypath=%cd% @if exist %file_name%.proto (  %mypath%\\protoc.exe --cpp_out=. %file_name%.proto @echo %file_name%.pb.cc and %file_name%.pb.h created) @pause<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f <a href=\"http:\/\/addressbook.pb.cc\" rel=\"noopener noreferrer nofollow\">addressbook.pb.cc<\/a> \u0438 addressbook.pb.h.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f \u0443 \u043d\u0430\u0441 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d. \u0423 \u043d\u0430\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/developers.google.com\/protocol-buffers\/docs\/cpptutorial\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043c\u044b \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 VS, \u0432 main \u0444\u0430\u0439\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0434. \u042f \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>main.cpp<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;iostream> #include &lt;fstream> #include &lt;string> #include \"addressbook.pb.h\" using namespace std; #define READ_EXAMPLE 1 #define WRITE_EXAMPLE 2 #define TYPE_EXAMPLE WRITE_EXAMPLE  \/\/ This function fills in a Person message based on user input. void PromptForAddress(tutorial::Person* person) {     cout &lt;&lt; \"Enter person ID number: \";     int id;     cin >> id;     person->set_id(id);     cin.ignore(256, '\\n');      cout &lt;&lt; \"Enter name: \";     getline(cin, *person->mutable_name());      cout &lt;&lt; \"Enter email address (blank for none): \";     string email;     getline(cin, email);     if (!email.empty()) {         person->set_email(email);     }      while (true) {         cout &lt;&lt; \"Enter a phone number (or leave blank to finish): \";         string number;         getline(cin, number);         if (number.empty()) {             break;         }          tutorial::Person::PhoneNumber* phone_number = person->add_phones();         phone_number->set_number(number);          cout &lt;&lt; \"Is this a mobile, home, or work phone? \";         string type;         getline(cin, type);         if (type == \"mobile\") {             phone_number->set_type(tutorial::Person::MOBILE);         }         else if (type == \"home\") {             phone_number->set_type(tutorial::Person::HOME);         }         else if (type == \"work\") {             phone_number->set_type(tutorial::Person::WORK);         }         else {             cout &lt;&lt; \"Unknown phone type.  Using default.\" &lt;&lt; endl;         }     }  }  \/\/ Iterates though all people in the AddressBook and prints info about them. void ListPeople(const tutorial::AddressBook&amp; address_book) {     for (int i = 0; i &lt; address_book.people_size(); i++) {         const tutorial::Person&amp; person = address_book.people(i);          cout &lt;&lt; \"Person ID: \" &lt;&lt; person.id() &lt;&lt; endl;         cout &lt;&lt; \"  Name: \" &lt;&lt; person.name() &lt;&lt; endl;         if (person.has_email()) {             cout &lt;&lt; \"  E-mail address: \" &lt;&lt; person.email() &lt;&lt; endl;         }          for (int j = 0; j &lt; person.phones_size(); j++) {             const tutorial::Person::PhoneNumber&amp; phone_number = person.phones(j);              switch (phone_number.type()) {             case tutorial::Person::MOBILE:                 cout &lt;&lt; \"  Mobile phone #: \";                 break;             case tutorial::Person::HOME:                 cout &lt;&lt; \"  Home phone #: \";                 break;             case tutorial::Person::WORK:                 cout &lt;&lt; \"  Work phone #: \";                 break;             }             cout &lt;&lt; phone_number.number() &lt;&lt; endl;         }     } }   \/\/ Main function:  Reads the entire address book from a file, \/\/   adds one person based on user input, then writes it back out to the same \/\/   file. 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;      if (argc != 2) {         cerr &lt;&lt; \"Usage:  \" &lt;&lt; argv[0] &lt;&lt; \" ADDRESS_BOOK_FILE\" &lt;&lt; endl;         return -1;     }      tutorial::AddressBook address_book;  #if(TYPE_EXAMPLE == WRITE_EXAMPLE)     {         \/\/ Read the existing address book.         fstream input(argv[1], ios::in | ios::binary);         if (!input) {             cout &lt;&lt; argv[1] &lt;&lt; \": File not found.  Creating a new file.\" &lt;&lt; endl;         }         else if (!address_book.ParseFromIstream(&amp;input)) {             cerr &lt;&lt; \"Failed to parse address book.\" &lt;&lt; endl;             return -1;         }     }      \/\/ Add an address.     PromptForAddress(address_book.add_people());     PromptForAddress(address_book.add_people());      {         \/\/ Write the new address book back to disk.         fstream output(argv[1], ios::out | ios::trunc | ios::binary);         if (!address_book.SerializeToOstream(&amp;output)) {             cerr &lt;&lt; \"Failed to write address book.\" &lt;&lt; endl;             return -1;         }     }  #elif(TYPE_EXAMPLE == READ_EXAMPLE)      {         \/\/ Read the existing address book.         fstream input(argv[1], ios::in | ios::binary);         if (!address_book.ParseFromIstream(&amp;input)) {             cerr &lt;&lt; \"Failed to parse address book.\" &lt;&lt; endl;             return -1;         }     }      ListPeople(address_book);  #endif     \/\/ Optional:  Delete all global objects allocated by libprotobuf.     google::protobuf::ShutdownProtobufLibrary();      return 0; }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e protoc.exe. \u041c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u043a\u043b\u0430\u0432\u0438\u0448 Alt+Shift+A. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0430\u0448\u0438 \u0444\u0430\u0439\u043b\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0442\u0443\u0442 \u043c\u044b \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u043f\u043a\u0430\u043c inclune \u0438 lib. \u0412 \u043f\u0430\u043f\u043a\u0435 lib \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 libprotobuf.lib (\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 Release) \u0438\u043b\u0438 libprotobufd.lib (\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 debug), \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 include. \u041f\u0440\u043e\u0441\u0442\u043e \u043a\u0438\u0434\u0430\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0430\u043f\u043a\u0443 include, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 &#171;<strong><em>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2192 \u0421\/\u0421++ \u2192 \u041e\u0431\u0449\u0438\u0435 <\/em><\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-327999","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=327999"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327999\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}