Commit 6ec22eee authored by Vitaliy Lyudvichenko's avatar Vitaliy Lyudvichenko

GSOC 2015: dnn module

Author: Vitaliy Lyudvichenko
Mentor: Anatoly Baksheev

Squashed commits are:

commit 2f6d743
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun May 31 00:05:31 2015 +0300

    Added dnn module with draft interface.

commit cfb9cfa
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 3 17:54:13 2015 +0300

    Added libprotobuf to CMake. Added some Caffe files.

commit a6963b4
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 3 22:28:12 2015 +0300

    Updated CMakeLists.txt to support protobuf Messages auto generation.

commit 6e23d93
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jun 6 19:08:12 2015 +0300

    Added simple .prototxt Caffe importer.

commit 77321e3
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Jun 8 16:59:27 2015 +0300

    Added binary .caffemodel import support.
    Some changes in API.
    Caffe source files was cleared from unnecessary code.

commit 24a9eff
Merge: 77321e3 844c30e8
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Jun 8 17:01:54 2015 +0300

    Merge branch 'master' of https://github.com/Itseez/opencv_contrib

commit 62feeec
Author: Anatoly Baksheev <no@email>
Date:   Mon Jun 8 19:41:11 2015 +0300

    fixed compilation witn C++11 compiler

commit 42b36fb
Author: Anatoly Baksheev <no@email>
Date:   Mon Jun 8 19:48:32 2015 +0300

    more compilation

commit 10c3a13
Author: Anatoly Baksheev <no@email>
Date:   Mon Jun 8 20:00:37 2015 +0300

    umbrealla header

commit eb95846
Author: Anatoly Baksheev <no@email>
Date:   Mon Jun 8 20:26:47 2015 +0300

    some warnings disabled

commit 1fd9304
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 9 13:58:35 2015 +0300

    Dnn API changes (removed NetConfiguration, added LayerRegister, improved Blob).

commit cae0bd4
Merge: 1fd9304 eb95846
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 9 14:25:35 2015 +0300

    Merge branch 'master' of github.com:ludv1x/opencv_contrib

    Conflicts:
    	modules/dnn/include/opencv2/dnn.hpp

commit ee837c1
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 9 21:36:18 2015 +0300

    Updated CMakeLists.txt

commit 194271d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun Jun 14 22:20:01 2015 +0300

    Implemented allocation of DAG and it's forward pass.
    Added wrappers for basic layers.

commit ed1c569
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 16 19:31:15 2015 +0300

    [Bomb commit] Implemented 4 main layers. Changes in API. Added worked classification example from GTSRB into tests.

commit 51df95d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 16 19:31:38 2015 +0300

    Added GSTRB test data.

commit 2638433
Merge: 51df95d 2a199bc9
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 16 22:55:35 2015 +0300

    Merge branch 'master' of https://github.com/Itseez/opencv_contrib

commit eba62d5
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jun 18 16:58:57 2015 +0300

    Layers implementations divided onto separated files.

commit 383715d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jun 18 23:55:16 2015 +0300

    libprotobuf is optional dependency now

commit 2c501f3
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Jun 19 00:01:53 2015 +0300

    Replace CMake WARNING onto STATUS

commit 29966ee
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Jun 19 16:50:25 2015 +0300

    added HAVE_PROTOBUF macro

commit 48ab440
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jun 20 01:59:56 2015 +0300

    Changed default parameter

commit 09ffc43
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jun 20 11:58:56 2015 +0300

    Fixed CMake and CPP build errors

commit eef4d1d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Jun 22 23:49:54 2015 +0300

    Added LRN and SoftMax layers, some fixes

commit 22272e8
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 23 14:27:30 2015 +0300

    Many fixes.

commit 9cddccf
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 23 14:29:42 2015 +0300

    Added AlexNet sample. Removed big .caffemodel files from repo.

commit 66fa1e1
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jun 23 17:33:48 2015 +0300

    Random changes in matlab/* module was reverted

commit d80c272
Author: Anatoly Baksheev <no@email>
Date:   Wed Jun 24 11:48:44 2015 +0300

    fixed stand alone link errors

commit 0cd5459
Author: Anatoly Baksheev <no@email>
Date:   Wed Jun 24 12:25:19 2015 +0300

    added incdes to project so that it could be visible in some IDEs (ex. qtcreator)

commit 13edaaa
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 18:25:34 2015 +0300

    Added group param to convolution_layer.cpp

commit 49b5e5e
Merge: 13edaaa 0cd5459
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 18:25:50 2015 +0300

    Merge branch 'master' of github.com:ludv1x/opencv_contrib

commit 99b8dac
Merge: 49b5e5e 8a05bdbc
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 18:26:10 2015 +0300

    Merge branch 'master' of https://github.com/Itseez/opencv_contrib

commit 0f7907d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 19:28:55 2015 +0300

    updated example

commit 2717765
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 20:02:31 2015 +0300

    Fixed some warnings

commit d117983
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jun 24 22:18:05 2015 +0300

    Deleted trailing whitespaces

commit cfdf060
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jun 25 12:16:11 2015 +0300

    Fixed more warnings. Updated glog_emulator.hpp:

commit 761b037
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Jun 26 17:57:55 2015 +0300

    Fixed critical bug in dnn::Dict. Fixed LRN layer implementation. Added layers test.

commit 6fd67d4
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jul 1 12:12:49 2015 +0300

    Updated test. Added and successfuly passed AlexNet reproducibility test. Small fixes.

commit 9838234
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 2 12:25:30 2015 +0300

    Some layer fixes. Added concat layer and avg. pooling to sucesfully run GoogLeNet.

    Added concat layer, implemented average pooling to run GoogLeNet.
    Fixed transpose error in FullyConnected layer (hotfix in softmax layer).
    Added GoogleNet test and updated AlexNet test (both nets now work fine).

commit 6f8a73b
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 2 12:31:48 2015 +0300

    Replaced CMake if() condition for standalone build.

commit 0ebe30a
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jul 4 22:41:55 2015 +0300

    Blob class was significantly refactored

commit d02bced
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun Jul 5 22:52:34 2015 +0300

    More refactoring over Blob.

    More refactoring over Blob.
    Fix warnings and eliminated zlib dependency in cnpy.h

commit 85ad43d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Jul 6 14:51:10 2015 +0300

    Generalized Blob constructor and added vector of images support.

    AlexNet and GoogLeNet tests updated.

commit 75e09fd
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jul 8 19:05:36 2015 +0300

    Implement ambiguous blobs naming scheme like: "layerName[.OutputName]".
    Old Caffe-like blob naming scheme was deleted.

commit b9e85ed
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Jul 8 19:15:51 2015 +0300

    fixed sign type mismatch warnings in cnpy

commit 9783bba
Merge: b9e85ed 6f8a73b
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 9 18:26:08 2015 +0300

    Merge branch 'master' into work

commit de4d800
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun Jul 12 23:19:07 2015 +0300

    Added .caffemodel files downloader for tests on post-build step.

commit ec74678
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 16 20:24:12 2015 +0300

    Added element-wise layers. Fixed downloader and ConcatLayer.

commit 0362da9
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Jul 17 17:24:59 2015 +0300

    Added array support for Dict.

commit 3aa37d2
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jul 18 01:12:08 2015 +0300

    Array of parmaters support into caffe_importer.cpp

commit 172419e
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun Jul 19 21:31:22 2015 +0300

    Added Reshape layer and altered importer to correctly handle its params.

commit 71cfae4
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Jul 20 23:29:42 2015 +0300

    Added Split and Slice layer.

commit 527fa65
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jul 21 16:10:29 2015 +0300

    Rewrited concat_layer.cpp in OpenCV-style. Fixed slice layer, added test for slice, split and reshape layers.

commit 9b1e28e
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 23 00:09:15 2015 +0300

    Refactored ConvolutionLayer, added Deconvolution.

commit ff45c22
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 23 21:19:25 2015 +0300

    Fixed gcc build errors.

commit 6548839
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jul 25 12:24:54 2015 +0300

    Added testdata images. Fixed Dict copy constructor.

commit db4ff21
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Jul 25 22:26:29 2015 +0300

    Updated classification example

commit 4da1046
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Jul 28 16:00:07 2015 +0300

    Implemented draft Torch importer

commit 7d795af
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Jul 30 15:43:47 2015 +0300

    Fixed Torch parser

commit 5e5cc96
Merge: 6f8a73b f9d42886
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 3 20:18:01 2015 +0300

    Merge branch 'master' of https://github.com/Itseez/opencv_contrib

commit dd15521
Merge: 5e5cc96 db4ff21
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 3 20:18:28 2015 +0300

    Merge branch 'master' of github.com:ludv1x/opencv_contrib

commit c1f4410
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 3 20:20:00 2015 +0300

    cnpy warns fix

commit 2905c03
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 4 19:16:34 2015 +0300

    Multiple layers support added into Torch importer.

    Also DictValue was refactored.

commit 8df8936
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 5 13:14:52 2015 +0300

    Added Torch blob reader and torch convolution test.

commit 1c220cf
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 6 13:29:45 2015 +0300

    Added simple tests for Torch importer, fixed some importing issues.

commit 436d929
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 6 14:37:56 2015 +0300

    Resolve reference counting problem in Torch importer.

commit b2f4ba3
Merge: c1f4410 172fdb31
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Aug 7 13:27:45 2015 +0300

    Merge branch 'master' of https://github.com/Itseez/opencv_contrib

commit 5b08053
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 10 12:53:44 2015 +0300

    Added ability to remove singleton dimensions in Reshape layer.

    Updated torch importer

commit d0875b1
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 11 01:49:27 2015 +0300

    Fixed average pooling error

commit f8119ea
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 11 22:12:48 2015 +0300

    Fixed Deconvolution layer. Added more wide layers test coverage.

commit df5eec6
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 12 16:54:44 2015 +0300

    Added MVN layer. Renamed layer test data.

commit f28effb
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 12 19:49:54 2015 +0300

    Cleaned caffe dependencies

commit b3dcc39
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 12 20:04:23 2015 +0300

    Moved caffe.proto

commit 7d2e745
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 13 00:53:50 2015 +0300

    Minor test changes

commit c65d032
Merge: 7d2e745 b2f4ba3
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 13 01:25:00 2015 +0300

    Merge branch 'master' of https://github.com/ludv1x/opencv_contrib

commit 160d864
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 13 11:45:40 2015 +0300

    Fixed small warn and example error

commit 06f949a
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 13 17:52:46 2015 +0300

    Added initModule() procedure to explicitly init builtin layers

commit 23d3ede
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 17 15:10:04 2015 +0300

    Added OpenCL im2col

commit 7acfda2
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 18 01:40:41 2015 +0300

    Fixed im2col_ocl bug caused non-zero UMat offset

commit 9d932af
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 18 01:55:05 2015 +0300

    Add new method to Net

commit 0903d79
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 19 01:28:44 2015 +0300

    Added libprotobuf 2.5 as thridparty library

commit 4929177
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 19 01:32:51 2015 +0300

    Add compiled caffe protobuf files

commit fc9795b
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 19 18:57:12 2015 +0300

    libprotobuf is a separate 3rdparty lib now

commit 93a372f
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 19 19:53:52 2015 +0300

    Try fix msvc error and cmake error on android

commit 44e52a0
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 20 01:34:05 2015 +0300

    Try fix msvc warnings

commit 519167e
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 20 18:51:44 2015 +0300

    Refactored cmake and disabled AlexNet test

commit e644b5a
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 20 21:52:41 2015 +0300

    Changed Blob::ptr and Blob::offset methods

commit f07c564
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 20 22:53:02 2015 +0300

    Add test data for layers

commit fb66acb
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Fri Aug 21 01:59:17 2015 +0300

    API refactoring

    renamed learnedParams blobs field
    added new fields: name and type for Layer

commit f8715f3
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sat Aug 22 18:31:53 2015 +0300

    Added licence headers

commit 945094b
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Sun Aug 23 03:06:24 2015 +0300

    Update doc, small changes in Blob methods

commit c681508
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 24 01:45:32 2015 +0300

    Add more docs

commit bd242d1
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 24 20:44:34 2015 +0300

    Add docs for remaning functions

commit eced23c
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Mon Aug 24 20:44:56 2015 +0300

    Updated dnn example

commit 57a2194
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 25 15:18:21 2015 +0300

    Add tutorial_dnn_build

commit efde664
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 25 17:09:00 2015 +0300

    Move binary testdata from opencv_contrib to opencv_extra

commit e52a7ee
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Tue Aug 25 19:01:05 2015 +0300

    Add bvlc_googlenet.prototxt to samples

commit 3154fc0
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 26 01:43:53 2015 +0300

    Add googlenet tutorial

commit 467cd96
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 26 13:32:27 2015 +0300

    Updated dnn build tutorial

commit 83e39a9
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Wed Aug 26 19:56:36 2015 +0300

    Fix typos

commit 0a64a9d
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 27 02:30:20 2015 +0300

    Changed Caffe googlenet tutorial

commit d2b6011
Author: Vitaliy Lyudvichenko <ludv1x@yandex.ru>
Date:   Thu Aug 27 14:01:40 2015 +0300

    Fix documentation warning

commit 248577a
Author: Anatoly Baksheev <no@email>
Date:   Thu Sep 3 18:33:26 2015 +0300

    fixed signed/unsigned cast warning
parent 4f860dcf
This diff is collapsed.
project(libprotobuf)
include(CheckIncludeFiles)
include(cmake/CheckCxxHashset.cmake)
include(cmake/CheckCxxHashmap.cmake)
check_include_files("pthread.h" HAVE_PTHREAD)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_include_file_cxx("unordered_map" HAVE_UNORDERED_MAP)
check_include_file_cxx("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP)
set(CMAKE_REQUIRED_FLAGS )
if(HAVE_UNORDERED_MAP)
add_definitions("-std=c++11") # For unordered_map
set(HASH_MAP_H "<unordered_map>")
set(HASH_MAP_CLASS "unordered_map")
set(HASH_NAMESPACE "std")
set(HAVE_HASH_MAP 1)
elseif(HAVE_TR1_UNORDERED_MAP)
add_definitions("-std=c++11") # For unordered_map
set(HASH_MAP_H "<tr1/unordered_map>")
set(HASH_MAP_CLASS "unordered_map")
set(HASH_NAMESPACE "std::tr1")
set(HAVE_HASH_MAP 1)
else()
CHECK_HASHMAP()
if(HAVE_GNU_EXT_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "__gnu_cxx")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
elseif(HAVE_STD_EXT_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "std")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
elseif(HAVE_GLOBAL_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
else()
set(HAVE_HASH_MAP 0)
endif()
endif()
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_include_file_cxx("unordered_set" HAVE_UNORDERED_SET)
check_include_file_cxx("tr1/unordered_set" HAVE_TR1_UNORDERED_SET)
set(CMAKE_REQUIRED_FLAGS )
if(HAVE_UNORDERED_SET)
set(HASH_SET_H "<unordered_set>")
set(HASH_SET_CLASS "unordered_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_TR1_UNORDERED_SET)
add_definitions("-std=c++11")
set(HASH_SET_H "<tr1/unordered_set>")
set(HASH_SET_CLASS "unordered_set")
set(HAVE_HASH_SET 1)
else()
CHECK_HASHSET()
if(HAVE_GNU_EXT_HASH_SET)
set(HASH_SET_H "<ext/hash_set>")
set(HASH_NAMESPACE "__gnu_cxx")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_STD_EXT_HASH_SET)
set(HASH_SET_H "<ext/hash_set>")
set(HASH_NAMESPACE "std")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_GLOBAL_HASH_SET)
set(HASH_SET_H "<hash_set>")
set(HASH_NAMESPACE "")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
else()
set(HAVE_HASH_SET 0)
endif()
endif()
endif()
if(WIN32 AND BUILD_SHARED_LIBS AND MSVC)
add_definitions(-DPROTOBUF_USE_DLLS)
add_definitions(-DLIBPROTOBUF_EXPORTS)
endif()
#add_definitions( -DGOOGLE_PROTOBUF_NO_THREAD_SAFETY ) #we don't need thread safety
add_definitions( -D_GNU_SOURCE=1 ) #it's maybe useful
add_definitions( -DHAVE_CONFIG_H ) #we will use config.h
configure_file("cmake/config.h.in" "config.h")
if(MSVC)
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 /wd4702)
else()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef)
endif()
# Easier to support different versions of protobufs
function(append_if_exist OUTPUT_LIST)
set(${OUTPUT_LIST})
foreach(fil ${ARGN})
if(EXISTS ${fil})
list(APPEND ${OUTPUT_LIST} "${fil}")
else()
message(WARNING "file missing: ${fil}")
endif()
endforeach()
set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE)
endfunction()
set(PROTOBUF_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
if(MSVC)
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc)
else()
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc)
endif()
append_if_exist(PROTOBUF_SRCS
${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc
${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc
${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc
${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc
${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${PROTOBUF_ROOT}/src/google/protobuf/message.cc
${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc
${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc
${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc
${PROTOBUF_ROOT}/src/google/protobuf/service.cc
${ATOMICOPS_INTERNALS}
${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc
${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc
${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc
${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc
${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc
${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc
${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc
#${PROTOBUF_ROOT}/src/google/protobuf/stubs/hash.cc
)
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
add_library(libprotobuf STATIC ${PROTOBUF_SRCS})
include_directories(${PROTOBUF_ROOT}/src ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(libprotobuf
PROPERTIES
OUTPUT_NAME libprotobuf
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(libprotobuf PROPERTIES FOLDER "3rdparty")
endif()
if(NOT BUILD_SHARED_LIBS)
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endif()
\ No newline at end of file
This file contains a list of people who have made large contributions
to the public version of Protocol Buffers.
Original Protocol Buffers design and implementation:
Sanjay Ghemawat <sanjay@google.com>
Jeff Dean <jeff@google.com>
Daniel Dulitz <daniel@google.com>
Craig Silverstein
Paul Haahr <haahr@google.com>
Corey Anderson <corin@google.com>
(and many others)
Proto2 C++ and Java primary author:
Kenton Varda <kenton@google.com>
Proto2 Python primary authors:
Will Robinson <robinson@google.com>
Petar Petrov <petar@google.com>
Large code contributions:
Jason Hsueh <jasonh@google.com>
Joseph Schorr <jschorr@google.com>
Wenbo Zhu <wenboz@google.com>
Large quantity of code reviews:
Scott Bruce <sbruce@google.com>
Frank Yellin
Neal Norwitz <nnorwitz@google.com>
Jeffrey Yasskin <jyasskin@google.com>
Ambrose Feinstein <ambrose@google.com>
Documentation:
Lisa Carey <lcarey@google.com>
Maven packaging:
Gregory Kick <gak@google.com>
Patch contributors:
Kevin Ko <kevin.s.ko@gmail.com>
* Small patch to handle trailing slashes in --proto_path flag.
Johan Euphrosine <proppy@aminche.com>
* Small patch to fix Python CallMethod().
Ulrich Kunitz <kune@deine-taler.de>
* Small optimizations to Python serialization.
Leandro Lucarella <llucax@gmail.com>
* VI syntax highlighting tweaks.
* Fix compiler to not make output executable.
Dilip Joseph <dilip.antony.joseph@gmail.com>
* Heuristic detection of sub-messages when printing unknown fields in
text format.
Brian Atkinson <nairb774@gmail.com>
* Added @Override annotation to generated Java code where appropriate.
Vincent Choinire <Choiniere.Vincent@hydro.qc.ca>
* Tru64 support.
Monty Taylor <monty.taylor@gmail.com>
* Solaris 10 + Sun Studio fixes.
Alek Storm <alek.storm@gmail.com>
* Slicing support for repeated scalar fields for the Python API.
Oleg Smolsky <oleg.smolsky@gmail.com>
* MS Visual Studio error format option.
* Detect unordered_map in stl_hash.m4.
Brian Olson <brianolson@google.com>
* gzip/zlib I/O support.
Michael Poole <mdpoole@troilus.org>
* Fixed warnings about generated constructors not explicitly initializing
all fields (only present with certain compiler settings).
* Added generation of field number constants.
Wink Saville <wink@google.com>
* Fixed initialization ordering problem in logging code.
Will Pierce <willp@nuclei.com>
* Small patch improving performance of in Python serialization.
Alexandre Vassalotti <alexandre@peadrop.com>
* Emacs mode for Protocol Buffers (editors/protobuf-mode.el).
Scott Stafford <scott.stafford@gmail.com>
* Added Swap(), SwapElements(), and RemoveLast() to Reflection interface.
Alexander Melnikov <alm@sibmail.ru>
* HPUX support.
Oliver Jowett <oliver.jowett@gmail.com>
* Detect whether zlib is new enough in configure script.
* Fixes for Solaris 10 32/64-bit confusion.
Evan Jones <evanj@mit.edu>
* Optimize Java serialization code when writing a small message to a stream.
* Optimize Java serialization of strings so that UTF-8 encoding happens only
once per string per serialization call.
* Clean up some Java warnings.
* Fix bug with permanent callbacks that delete themselves when run.
Michael Kucharski <m.kucharski@gmail.com>
* Added CodedInputStream.getTotalBytesRead().
Kacper Kowalik <xarthisius.kk@gmail.com>
* Fixed m4/acx_pthread.m4 problem for some Linux distributions.
Copyright 2008, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Code generated by the Protocol Buffer compiler is owned by the owner
of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.
Protocol Buffers - Google's data interchange format
Copyright 2008 Google Inc.
http://code.google.com/apis/protocolbuffers/
C++ Installation - Unix
=======================
To build and install the C++ Protocol Buffer runtime and the Protocol
Buffer compiler (protoc) execute the following:
$ ./configure
$ make
$ make check
$ make install
If "make check" fails, you can still install, but it is likely that
some features of this library will not work correctly on your system.
Proceed at your own risk.
"make install" may require superuser privileges.
For advanced usage information on configure and make, see INSTALL.txt.
** Hint on install location **
By default, the package will be installed to /usr/local. However,
on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
You can add it, but it may be easier to just install to /usr
instead. To do this, invoke configure as follows:
./configure --prefix=/usr
If you already built the package with a different prefix, make sure
to run "make clean" before building again.
** Compiling dependent packages **
To compile a package that uses Protocol Buffers, you need to pass
various flags to your compiler and linker. As of version 2.2.0,
Protocol Buffers integrates with pkg-config to manage this. If you
have pkg-config installed, then you can invoke it to get a list of
flags like so:
pkg-config --cflags protobuf # print compiler flags
pkg-config --libs protobuf # print linker flags
pkg-config --cflags --libs protobuf # print both
For example:
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
Note that packages written prior to the 2.2.0 release of Protocol
Buffers may not yet integrate with pkg-config to get flags, and may
not pass the correct set of flags to correctly link against
libprotobuf. If the package in question uses autoconf, you can
often fix the problem by invoking its configure script like:
configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
LIBS="$(pkg-config --libs protobuf)"
This will force it to use the correct flags.
If you are writing an autoconf-based package that uses Protocol
Buffers, you should probably use the PKG_CHECK_MODULES macro in your
configure script like:
PKG_CHECK_MODULES([protobuf], [protobuf])
See the pkg-config man page for more info.
If you only want protobuf-lite, substitute "protobuf-lite" in place
of "protobuf" in these examples.
** Note for cross-compiling **
The makefiles normally invoke the protoc executable that they just
built in order to build tests. When cross-compiling, the protoc
executable may not be executable on the host machine. In this case,
you must build a copy of protoc for the host machine first, then use
the --with-protoc option to tell configure to use it instead. For
example:
./configure --with-protoc=protoc
This will use the installed protoc (found in your $PATH) instead of
trying to execute the one built during the build process. You can
also use an executable that hasn't been installed. For example, if
you built the protobuf package for your host machine in ../host,
you might do:
./configure --with-protoc=../host/src/protoc
Either way, you must make sure that the protoc executable you use
has the same version as the protobuf source code you are trying to
use it with.
** Note for Solaris users **
Solaris 10 x86 has a bug that will make linking fail, complaining
about libstdc++.la being invalid. We have included a work-around
in this package. To use the work-around, run configure as follows:
./configure LDFLAGS=-L$PWD/src/solaris
See src/solaris/libstdc++.la for more info on this bug.
** Note for HP C++ Tru64 users **
To compile invoke configure as follows:
./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
Also, you will need to use gmake instead of make.
C++ Installation - Windows
==========================
If you are using Microsoft Visual C++, see vsprojects/readme.txt.
If you are using Cygwin or MinGW, follow the Unix installation
instructions, above.
Binary Compatibility Warning
============================
Due to the nature of C++, it is unlikely that any two versions of the
Protocol Buffers C++ runtime libraries will have compatible ABIs.
That is, if you linked an executable against an older version of
libprotobuf, it is unlikely to work with a newer version without
re-compiling. This problem, when it occurs, will normally be detected
immediately on startup of your app. Still, you may want to consider
using static linkage. You can configure this package to install
static libraries only using:
./configure --disable-shared
Java and Python Installation
============================
The Java and Python runtime libraries for Protocol Buffers are located
in the java and python directories. See the README file in each
directory for more information on how to compile and install them.
Note that both of them require you to first install the Protocol
Buffer compiler (protoc), which is part of the C++ package.
Usage
=====
The complete documentation for Protocol Buffers is available via the
web at:
http://code.google.com/apis/protocolbuffers/
# From LLVM
# - Check if for hash_map.
# CHECK_HASHMAP ()
#
include(CheckCXXSourceCompiles)
macro(CHECK_HASHMAP)
message(STATUS "Checking for C++ hash_map implementation...")
check_cxx_source_compiles("
#include <ext/hash_map>
int main() {
__gnu_cxx::hash_map<int, int> t;
}
"
HAVE_GNU_EXT_HASH_MAP
)
if(HAVE_GNU_EXT_HASH_MAP)
message(STATUS "C++ hash_map found in 'ext' dir in namespace __gnu_cxx::")
endif(HAVE_GNU_EXT_HASH_MAP)
check_cxx_source_compiles("
#include <ext/hash_map>
int main() {
std::hash_map<int, int> t;
}
"
HAVE_STD_EXT_HASH_MAP
)
if(HAVE_STD_EXT_HASH_MAP)
message(STATUS "C++ hash_map found in 'ext' dir in namespace std::")
endif(HAVE_STD_EXT_HASH_MAP)
check_cxx_source_compiles("
#include <hash_map>
int main() {
hash_map<int, int> t;
}
"
HAVE_GLOBAL_HASH_MAP
)
if(HAVE_GLOBAL_HASH_MAP)
message(STATUS "C++ hash_map found in global namespace")
endif(HAVE_GLOBAL_HASH_MAP)
if(NOT HAVE_GNU_EXT_HASH_MAP)
if(NOT HAVE_STD_EXT_HASH_MAP)
if(NOT HAVE_GLOBAL_HASH_MAP)
message(STATUS "C++ hash_map not found")
endif(NOT HAVE_GLOBAL_HASH_MAP)
endif(NOT HAVE_STD_EXT_HASH_MAP)
endif(NOT HAVE_GNU_EXT_HASH_MAP)
endmacro(CHECK_HASHMAP)
# From LLVM
# - Check if for hash_set.
# CHECK_HASHSET ()
#
include(CheckCXXSourceCompiles)
macro(CHECK_HASHSET)
message(STATUS "Checking for C++ hash_set implementation...")
check_cxx_source_compiles("
#include <ext/hash_set>
int main() {
__gnu_cxx::hash_set<int> t;
}
"
HAVE_GNU_EXT_HASH_SET
)
if(HAVE_GNU_EXT_HASH_SET)
message(STATUS "C++ hash_set found in 'ext' dir in namespace __gnu_cxx::")
endif(HAVE_GNU_EXT_HASH_SET)
check_cxx_source_compiles("
#include <ext/hash_set>
int main() {
std::hash_set<int> t;
}
"
HAVE_STD_EXT_HASH_SET
)
if(HAVE_STD_EXT_HASH_SET)
message(STATUS "C++ hash_set found in 'ext' dir in namespace std::")
endif(HAVE_STD_EXT_HASH_SET)
check_cxx_source_compiles("
#include <hash_set>
int main() {
hash_set<int> t;
}
"
HAVE_GLOBAL_HASH_SET
)
if(HAVE_GLOBAL_HASH_SET)
message(STATUS "C++ hash_set found in global namespace")
endif(HAVE_GLOBAL_HASH_SET)
if(NOT HAVE_GNU_EXT_HASH_SET)
if(NOT HAVE_STD_EXT_HASH_SET)
if(NOT HAVE_GLOBAL_HASH_SET)
message(STATUS "C++ hash_set not found")
endif(NOT HAVE_GLOBAL_HASH_SET)
endif(NOT HAVE_STD_EXT_HASH_SET)
endif(NOT HAVE_GNU_EXT_HASH_SET)
endmacro(CHECK_HASHSET)
New BSD license: http://opensource.org/licenses/BSD-3-Clause
Copyright (c) 2014, Jesper Eskilson and others
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
#ifndef _CONFIG_H_
#define _CONFIG_H_
/* the name of <hash_map> */
#define HASH_MAP_CLASS ${HASH_MAP_CLASS}
/* the location of <unordered_map> or <hash_map> */
#define HASH_MAP_H ${HASH_MAP_H}
/* the namespace of hash_map/hash_set */
#define HASH_NAMESPACE ${HASH_NAMESPACE}
/* the name of <hash_set> */
#define HASH_SET_CLASS ${HASH_SET_CLASS}
/* the location of <unordered_set> or <hash_set> */
#define HASH_SET_H ${HASH_SET_H}
/* define if the compiler has hash_map */
#cmakedefine HAVE_HASH_MAP
/* define if the compiler has hash_set */
#cmakedefine HAVE_HASH_SET
/* Define if you have POSIX threads libraries and header files. */
#cmakedefine HAVE_PTHREAD
/* Enable classes using zlib compression. */
#undef HAVE_ZLIB
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
#endif /* _CONFIG_H_ */
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
namespace compiler {
CodeGenerator::~CodeGenerator() {}
GeneratorContext::~GeneratorContext() {}
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
const string& filename, const string& insertion_point) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
return NULL; // make compiler happy
}
void GeneratorContext::ListParsedFiles(
vector<const FileDescriptor*>* output) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
}
// Parses a set of comma-delimited name/value pairs.
void ParseGeneratorParameter(const string& text,
vector<pair<string, string> >* output) {
vector<string> parts;
SplitStringUsing(text, ",", &parts);
for (int i = 0; i < parts.size(); i++) {
string::size_type equals_pos = parts[i].find_first_of('=');
pair<string, string> value;
if (equals_pos == string::npos) {
value.first = parts[i];
value.second = "";
} else {
value.first = parts[i].substr(0, equals_pos);
value.second = parts[i].substr(equals_pos + 1);
}
output->push_back(value);
}
}
} // namespace compiler
} // namespace protobuf
} // namespace google
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// Defines the abstract interface implemented by each of the language-specific
// code generators.
#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
#include <google/protobuf/stubs/common.h>
#include <string>
#include <vector>
#include <utility>
namespace google {
namespace protobuf {
namespace io { class ZeroCopyOutputStream; }
class FileDescriptor;
namespace compiler {
// Defined in this file.
class CodeGenerator;
class GeneratorContext;
// The abstract interface to a class which generates code implementing a
// particular proto file in a particular language. A number of these may
// be registered with CommandLineInterface to support various languages.
class LIBPROTOC_EXPORT CodeGenerator {
public:
inline CodeGenerator() {}
virtual ~CodeGenerator();
// Generates code for the given proto file, generating one or more files in
// the given output directory.
//
// A parameter to be passed to the generator can be specified on the
// command line. This is intended to be used by Java and similar languages
// to specify which specific class from the proto file is to be generated,
// though it could have other uses as well. It is empty if no parameter was
// given.
//
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
virtual bool Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* generator_context,
string* error) const = 0;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);
};
// CodeGenerators generate one or more files in a given directory. This
// abstract interface represents the directory to which the CodeGenerator is
// to write and other information about the context in which the Generator
// runs.
class LIBPROTOC_EXPORT GeneratorContext {
public:
inline GeneratorContext() {}
virtual ~GeneratorContext();
// Opens the given file, truncating it if it exists, and returns a
// ZeroCopyOutputStream that writes to the file. The caller takes ownership
// of the returned object. This method never fails (a dummy stream will be
// returned instead).
//
// The filename given should be relative to the root of the source tree.
// E.g. the C++ generator, when generating code for "foo/bar.proto", will
// generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that
// "foo/" is included in these filenames. The filename is not allowed to
// contain "." or ".." components.
virtual io::ZeroCopyOutputStream* Open(const string& filename) = 0;
// Creates a ZeroCopyOutputStream which will insert code into the given file
// at the given insertion point. See plugin.proto (plugin.pb.h) for more
// information on insertion points. The default implementation
// assert-fails -- it exists only for backwards-compatibility.
//
// WARNING: This feature is currently EXPERIMENTAL and is subject to change.
virtual io::ZeroCopyOutputStream* OpenForInsert(
const string& filename, const string& insertion_point);
// Returns a vector of FileDescriptors for all the files being compiled
// in this run. Useful for languages, such as Go, that treat files
// differently when compiled as a set rather than individually.
virtual void ListParsedFiles(vector<const FileDescriptor*>* output);
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
};
// The type GeneratorContext was once called OutputDirectory. This typedef
// provides backward compatibility.
typedef GeneratorContext OutputDirectory;
// Several code generators treat the parameter argument as holding a
// list of options separated by commas. This helper function parses
// a set of comma-delimited name/value pairs: e.g.,
// "foo=bar,baz,qux=corge"
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
extern void ParseGeneratorParameter(const string&,
vector<pair<string, string> >*);
} // namespace compiler
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// This test insures that google/protobuf/descriptor.pb.{h,cc} match exactly
// what would be generated by the protocol compiler. These files are not
// generated automatically at build time because they are compiled into the
// protocol compiler itself. So, if they were auto-generated, you'd have a
// chicken-and-egg problem.
//
// If this test fails, run the script
// "generate_descriptor_proto.sh" and add
// descriptor.pb.{h,cc} to your changelist.
#include <map>
#include <google/protobuf/compiler/cpp/cpp_generator.h>
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/map-util.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
namespace {
class MockErrorCollector : public MultiFileErrorCollector {
public:
MockErrorCollector() {}
~MockErrorCollector() {}
string text_;
// implements ErrorCollector ---------------------------------------
void AddError(const string& filename, int line, int column,
const string& message) {
strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n",
filename, line, column, message);
}
};
class MockGeneratorContext : public GeneratorContext {
public:
MockGeneratorContext() {}
~MockGeneratorContext() {
STLDeleteValues(&files_);
}
void ExpectFileMatches(const string& virtual_filename,
const string& physical_filename) {
string* expected_contents = FindPtrOrNull(files_, virtual_filename);
ASSERT_TRUE(expected_contents != NULL)
<< "Generator failed to generate file: " << virtual_filename;
string actual_contents;
File::ReadFileToStringOrDie(
TestSourceDir() + "/" + physical_filename,
&actual_contents);
EXPECT_TRUE(actual_contents == *expected_contents)
<< physical_filename << " needs to be regenerated. Please run "
"generate_descriptor_proto.sh and add this file "
"to your CL.";
}
// implements GeneratorContext --------------------------------------
virtual io::ZeroCopyOutputStream* Open(const string& filename) {
string** map_slot = &files_[filename];
if (*map_slot != NULL) delete *map_slot;
*map_slot = new string;
return new io::StringOutputStream(*map_slot);
}
private:
map<string, string*> files_;
};
TEST(BootstrapTest, GeneratedDescriptorMatches) {
MockErrorCollector error_collector;
DiskSourceTree source_tree;
source_tree.MapPath("", TestSourceDir());
Importer importer(&source_tree, &error_collector);
const FileDescriptor* proto_file =
importer.Import("google/protobuf/descriptor.proto");
const FileDescriptor* plugin_proto_file =
importer.Import("google/protobuf/compiler/plugin.proto");
EXPECT_EQ("", error_collector.text_);
ASSERT_TRUE(proto_file != NULL);
ASSERT_TRUE(plugin_proto_file != NULL);
CppGenerator generator;
MockGeneratorContext context;
string error;
string parameter;
parameter = "dllexport_decl=LIBPROTOBUF_EXPORT";
ASSERT_TRUE(generator.Generate(proto_file, parameter,
&context, &error));
parameter = "dllexport_decl=LIBPROTOC_EXPORT";
ASSERT_TRUE(generator.Generate(plugin_proto_file, parameter,
&context, &error));
context.ExpectFileMatches("google/protobuf/descriptor.pb.h",
"google/protobuf/descriptor.pb.h");
context.ExpectFileMatches("google/protobuf/descriptor.pb.cc",
"google/protobuf/descriptor.pb.cc");
context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.h",
"google/protobuf/compiler/plugin.pb.h");
context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc",
"google/protobuf/compiler/plugin.pb.cc");
}
} // namespace
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// Generates C++ code for a given .proto file.
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
#include <string>
#include <google/protobuf/compiler/code_generator.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
// CodeGenerator implementation which generates a C++ source file and
// header. If you create your own protocol compiler binary and you want
// it to support C++ output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator {
public:
CppGenerator();
~CppGenerator();
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* generator_context,
string* error) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator);
};
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment