PROTON-865: Fix extern declarations and other windows portability issues. Added type_traits to manage the complicated variations of distinct/identical integer types of various sizes on different C++ compilers.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9f7e3462 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9f7e3462 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9f7e3462 Branch: refs/heads/cjansen-cpp-client Commit: 9f7e3462006e03a421097ce3157eb68451e23070 Parents: 327f358 Author: Alan Conway <[email protected]> Authored: Wed Jun 17 17:11:47 2015 -0400 Committer: Alan Conway <[email protected]> Committed: Thu Jun 18 17:55:28 2015 -0400 ---------------------------------------------------------------------- examples/cpp/CMakeLists.txt | 4 +- examples/cpp/encode_decode.cpp | 2 +- examples/cpp/example_test.py | 35 +- proton-c/bindings/cpp/CMakeCache.txt | 334 +++++++++++++++++++ proton-c/bindings/cpp/CMakeLists.txt | 38 ++- .../bindings/cpp/include/proton/Acceptor.hpp | 5 +- proton-c/bindings/cpp/include/proton/Acking.hpp | 2 +- .../cpp/include/proton/BlockingConnection.hpp | 2 +- .../cpp/include/proton/BlockingLink.hpp | 6 +- .../cpp/include/proton/BlockingSender.hpp | 2 +- .../bindings/cpp/include/proton/Connection.hpp | 2 +- .../bindings/cpp/include/proton/Container.hpp | 2 +- proton-c/bindings/cpp/include/proton/Data.hpp | 33 +- .../bindings/cpp/include/proton/Decoder.hpp | 22 +- .../bindings/cpp/include/proton/Delivery.hpp | 2 +- .../bindings/cpp/include/proton/Duration.hpp | 18 +- .../bindings/cpp/include/proton/Encoder.hpp | 85 ++--- .../bindings/cpp/include/proton/Endpoint.hpp | 6 +- proton-c/bindings/cpp/include/proton/Error.hpp | 8 +- proton-c/bindings/cpp/include/proton/Event.hpp | 8 +- proton-c/bindings/cpp/include/proton/Handle.hpp | 16 +- .../bindings/cpp/include/proton/Handler.hpp | 4 +- .../cpp/include/proton/ImportExport.hpp | 50 --- proton-c/bindings/cpp/include/proton/Link.hpp | 4 +- .../bindings/cpp/include/proton/Message.hpp | 78 ++--- .../cpp/include/proton/MessagingHandler.hpp | 88 ++--- .../cpp/include/proton/ProtonHandle.hpp | 12 +- .../cpp/include/proton/ProtonHandler.hpp | 82 ++--- .../bindings/cpp/include/proton/Receiver.hpp | 4 +- proton-c/bindings/cpp/include/proton/Sender.hpp | 8 +- .../bindings/cpp/include/proton/Session.hpp | 9 +- .../bindings/cpp/include/proton/Terminus.hpp | 2 +- .../bindings/cpp/include/proton/Transport.hpp | 2 +- proton-c/bindings/cpp/include/proton/Value.hpp | 26 +- proton-c/bindings/cpp/include/proton/Values.hpp | 15 +- .../cpp/include/proton/WaitCondition.hpp | 2 +- proton-c/bindings/cpp/include/proton/export.hpp | 46 +++ .../bindings/cpp/include/proton/type_traits.hpp | 116 +++++++ proton-c/bindings/cpp/include/proton/types.hpp | 147 ++++---- .../bindings/cpp/src/BlockingConnection.cpp | 62 ++++ .../bindings/cpp/src/BlockingConnectionImpl.cpp | 124 +++++++ .../bindings/cpp/src/BlockingConnectionImpl.hpp | 63 ++++ proton-c/bindings/cpp/src/BlockingLink.cpp | 86 +++++ proton-c/bindings/cpp/src/BlockingSender.cpp | 66 ++++ proton-c/bindings/cpp/src/ConnectionImpl.hpp | 2 +- proton-c/bindings/cpp/src/ContainerImpl.hpp | 2 +- proton-c/bindings/cpp/src/Decoder.cpp | 3 +- proton-c/bindings/cpp/src/Duration.cpp | 2 +- proton-c/bindings/cpp/src/Encoder.cpp | 3 +- proton-c/bindings/cpp/src/Error.cpp | 4 +- proton-c/bindings/cpp/src/MessagingAdapter.cpp | 2 +- proton-c/bindings/cpp/src/PrivateImplRef.hpp | 2 +- proton-c/bindings/cpp/src/ProtonImplRef.hpp | 2 +- proton-c/bindings/cpp/src/Sender.cpp | 9 +- proton-c/bindings/cpp/src/Session.cpp | 1 + proton-c/bindings/cpp/src/Url.hpp | 2 +- .../cpp/src/blocking/BlockingConnection.cpp | 62 ---- .../cpp/src/blocking/BlockingConnectionImpl.cpp | 124 ------- .../cpp/src/blocking/BlockingConnectionImpl.hpp | 63 ---- .../bindings/cpp/src/blocking/BlockingLink.cpp | 86 ----- .../cpp/src/blocking/BlockingSender.cpp | 66 ---- proton-c/bindings/cpp/src/interop_test.cpp | 36 +- proton-c/bindings/cpp/src/proton_bits.hpp | 1 + proton-c/bindings/cpp/src/types.cpp | 43 ++- proton-c/include/proton/codec.h | 2 +- 65 files changed, 1391 insertions(+), 854 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/examples/cpp/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index bafcd38..7a9f911 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -17,7 +17,9 @@ # under the License. # -include_directories("${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include") +include_directories( + "${CMAKE_SOURCE_DIR}/proton-c/include" + "${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include") foreach(example broker http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/examples/cpp/encode_decode.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp index cad4c0e..fd65ebd 100644 --- a/examples/cpp/encode_decode.cpp +++ b/examples/cpp/encode_decode.cpp @@ -68,7 +68,7 @@ void simple_insert_extract_exact_type() { // Check that we encoded the correct types, but note that decoding will // still convert to standard C++ types, in particular any AMQP integer type // can be converted to a long-enough C++ integer type.. - int64_t i1, i2; + std::int64_t i1, i2; std::string s; values >> i1 >> i2 >> s; cout << "Extracted (with conversion) " << i1 << ", " << i2 << ", " << s << endl; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/examples/cpp/example_test.py ---------------------------------------------------------------------- diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py index 2e2d91c..8507be8 100644 --- a/examples/cpp/example_test.py +++ b/examples/cpp/example_test.py @@ -22,7 +22,18 @@ import unittest import os, sys, socket, time from random import randrange -from subprocess import Popen, check_output, PIPE, STDOUT +from subprocess import Popen, PIPE, STDOUT + +def call(*args, **kwargs): + p = Popen(*args, stdout=PIPE, stderr=STDOUT, **kwargs) + out, err = p.communicate() + if p.returncode: + raise CalledProcessError("""%s exit code %s +vvvvvvvvvvvvvvvv output of %s exit code %s vvvvvvvvvvvvvvvv +%s +^^^^^^^^^^^^^^^^ output of %s exit code %s ^^^^^^^^^^^^^^^^""" % ( + p.cmd, p.returncode, p.cmd, p.returncode, out, p.cmd, p.returncode)) + return out NULL = open(os.devnull, 'w') @@ -68,25 +79,25 @@ class ExampleTest(unittest.TestCase): def test_helloworld(self): b = Broker.get() - hw = check_output(["./helloworld", b.addr]) + hw = call(["./helloworld", b.addr]) self.assertEqual("Hello World!\n", hw) def test_helloworld_blocking(self): b = Broker.get() - hw = check_output(["./helloworld_blocking", b.addr]) + hw = call(["./helloworld_blocking", b.addr]) self.assertEqual("Hello World!\n", hw) def test_helloworld_direct(self): url = ":%s/examples" % randrange(10000, 20000) - hw = check_output(["./helloworld_direct", url]) + hw = call(["./helloworld_direct", url]) self.assertEqual("Hello World!\n", hw) def test_simple_send_recv(self): b = Broker.get() n = 5 - send = check_output(["./simple_send", "-a", b.addr, "-m", str(n)]) + send = call(["./simple_send", "-a", b.addr, "-m", str(n)]) self.assertEqual("all messages confirmed\n", send) - recv = check_output(["./simple_recv", "-a", b.addr, "-m", str(n)]) + recv = call(["./simple_recv", "-a", b.addr, "-m", str(n)]) recv_expect = "simple_recv listening on %s\n" % (b.addr) recv_expect += "".join(['{"sequence"=%s}\n' % (i+1) for i in range(n)]) self.assertEqual(recv_expect, recv) @@ -99,20 +110,12 @@ class ExampleTest(unittest.TestCase): n = 5 recv = Popen(["./simple_recv", "-a", b.addr, "-m", str(n)], stdout=PIPE) self.assertEqual("simple_recv listening on %s\n" % (b.addr), recv.stdout.readline()) - send = check_output(["./simple_send", "-a", b.addr, "-m", str(n)]) + send = call(["./simple_send", "-a", b.addr, "-m", str(n)]) self.assertEqual("all messages confirmed\n", send) recv_expect = "".join(['[%d]: b"some arbitrary binary data"\n' % (i+1) for i in range(n)]) out, err = recv.communicate() self.assertEqual(recv_expect, out) - def call(self, *cmd): - p = Popen(cmd, stdout=PIPE, stderr=STDOUT) - out, err = p.communicate() - self.assertEqual(0, p.returncode, - "%s exit code %s, output:\n%s\n---- end of %s exit code %s" % ( - cmd, p.returncode, out, cmd, p.returncode)) - return out - def test_encode_decode(self): expect=""" == Simple values: int, string, bool @@ -140,6 +143,6 @@ Values: list[int(42), bool(false), symbol(:x)] Values: map{string("k1"):int(42), symbol(:"k2"):bool(false)} """ self.maxDiff = None - self.assertMultiLineEqual(expect, self.call("./encode_decode")) + self.assertMultiLineEqual(expect, call("./encode_decode")) if __name__ == "__main__": unittest.main() http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/CMakeCache.txt ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/CMakeCache.txt b/proton-c/bindings/cpp/CMakeCache.txt new file mode 100644 index 0000000..9e6eaeb --- /dev/null +++ b/proton-c/bindings/cpp/CMakeCache.txt @@ -0,0 +1,334 @@ +# This is the CMakeCache file. +# For build in directory: /home/aconway/proton/proton-c/bindings/cpp +# It was generated by CMake: /usr/bin/cmake +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a variable in the cache. +# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//Build cpp language binding +BUILD_CPP:BOOL=ON + +//Build javascript language binding +BUILD_JAVASCRIPT:BOOL=OFF + +//Path to a program. +CMAKE_AR:FILEPATH=/usr/bin/ar + +//For backwards compatibility, what version of CMake commands and +// syntax should this version of CMake try to support. +CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4 + +//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or +// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. +CMAKE_BUILD_TYPE:STRING= + +//Enable/Disable color output during build. +CMAKE_COLOR_MAKEFILE:BOOL=ON + +//CXX compiler +CMAKE_CXX_COMPILER:FILEPATH=/usr/lib64/ccache/c++ + +//Flags used by the compiler during all build types. +CMAKE_CXX_FLAGS:STRING= + +//Flags used by the compiler during debug builds. +CMAKE_CXX_FLAGS_DEBUG:STRING=-g + +//Flags used by the compiler during release builds for minimum +// size. +CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the compiler during release builds. +CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the compiler during release builds with debug info. +CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG + +//C compiler +CMAKE_C_COMPILER:FILEPATH=/usr/lib64/ccache/cc + +//Flags used by the compiler during all build types. +CMAKE_C_FLAGS:STRING= + +//Flags used by the compiler during debug builds. +CMAKE_C_FLAGS_DEBUG:STRING=-g + +//Flags used by the compiler during release builds for minimum +// size. +CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the compiler during release builds. +CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the compiler during release builds with debug info. +CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG + +//Flags used by the linker. +CMAKE_EXE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Enable/Disable output of compile commands during generation. +CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF + +//Install path prefix, prepended onto install directories. +CMAKE_INSTALL_PREFIX:PATH=/usr/local + +//Path to a program. +CMAKE_LINKER:FILEPATH=/usr/bin/ld + +//Path to a program. +CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake + +//Flags used by the linker during the creation of modules. +CMAKE_MODULE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_NM:FILEPATH=/usr/bin/nm + +//Path to a program. +CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy + +//Path to a program. +CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump + +//Value Computed by CMake +CMAKE_PROJECT_NAME:STATIC=Project + +//Path to a program. +CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib + +//Flags used by the linker during the creation of dll's. +CMAKE_SHARED_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//If set, runtime paths are not added when installing shared libraries, +// but are added when building. +CMAKE_SKIP_INSTALL_RPATH:BOOL=NO + +//If set, runtime paths are not added when using shared libraries. +CMAKE_SKIP_RPATH:BOOL=NO + +//Flags used by the linker during the creation of static libraries. +CMAKE_STATIC_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_STRIP:FILEPATH=/usr/bin/strip + +//If true, cmake will use relative paths in makefiles and projects. +CMAKE_USE_RELATIVE_PATHS:BOOL=OFF + +//If this value is on, makefiles will be generated without the +// .SILENT directive, and all commands will be echoed to the console +// during the make. This is useful for debugging only. With Visual +// Studio IDE projects all commands are done without /nologo. +CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE + +//Single output directory for building all executables. +EXECUTABLE_OUTPUT_PATH:PATH= + +//The directory containing a CMake configuration file for Emscripten. +Emscripten_DIR:PATH=Emscripten_DIR-NOTFOUND + +//Single output directory for building all libraries. +LIBRARY_OUTPUT_PATH:PATH= + +//Value Computed by CMake +Project_BINARY_DIR:STATIC=/home/aconway/proton/proton-c/bindings/cpp + +//Value Computed by CMake +Project_SOURCE_DIR:STATIC=/home/aconway/proton/proton-c/bindings + +//Dependencies for the target +qpid-proton-cpp_LIB_DEPENDS:STATIC=general;qpid-proton; + + +######################## +# INTERNAL cache entries +######################## + +//ADVANCED property for variable: CMAKE_AR +CMAKE_AR-ADVANCED:INTERNAL=1 +//This is the directory where this CMakeCache.txt was created +CMAKE_CACHEFILE_DIR:INTERNAL=/home/aconway/proton/proton-c/bindings/cpp +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3 +//Minor version of cmake used to create the current loaded cache +CMAKE_CACHE_MINOR_VERSION:INTERNAL=2 +//Patch version of cmake used to create the current loaded cache +CMAKE_CACHE_PATCH_VERSION:INTERNAL=2 +//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE +CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 +//Path to CMake executable. +CMAKE_COMMAND:INTERNAL=/usr/bin/cmake +//Path to cpack program executable. +CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack +//Path to ctest program executable. +CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest +//ADVANCED property for variable: CMAKE_CXX_COMPILER +CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS +CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG +CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL +CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE +CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO +CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_COMPILER +CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS +CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG +CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL +CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE +CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO +CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Path to cache edit program executable. +CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake +//Executable file format +CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS +CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG +CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE +CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS +CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1 +//Name of external makefile project generator. +CMAKE_EXTRA_GENERATOR:INTERNAL= +//Name of generator. +CMAKE_GENERATOR:INTERNAL=Unix Makefiles +//Name of generator platform. +CMAKE_GENERATOR_PLATFORM:INTERNAL= +//Name of generator toolset. +CMAKE_GENERATOR_TOOLSET:INTERNAL= +//Start directory with the top level CMakeLists.txt file for this +// project +CMAKE_HOME_DIRECTORY:INTERNAL=/home/aconway/proton/proton-c/bindings +//Install .so files without execute permission. +CMAKE_INSTALL_SO_NO_EXE:INTERNAL=0 +//ADVANCED property for variable: CMAKE_LINKER +CMAKE_LINKER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MAKE_PROGRAM +CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS +CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG +CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE +CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_NM +CMAKE_NM-ADVANCED:INTERNAL=1 +//number of local generators +CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=2 +//ADVANCED property for variable: CMAKE_OBJCOPY +CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_OBJDUMP +CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_RANLIB +CMAKE_RANLIB-ADVANCED:INTERNAL=1 +//Path to CMake installation. +CMAKE_ROOT:INTERNAL=/usr/share/cmake +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS +CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG +CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE +CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH +CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SKIP_RPATH +CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS +CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG +CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL +CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE +CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STRIP +CMAKE_STRIP-ADVANCED:INTERNAL=1 +//uname command +CMAKE_UNAME:INTERNAL=/usr/bin/uname +//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS +CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE +CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 +//Result of TRY_COMPILE +RESULT:INTERNAL=TRUE http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt index f3fbb44..462e2bf 100644 --- a/proton-c/bindings/cpp/CMakeLists.txt +++ b/proton-c/bindings/cpp/CMakeLists.txt @@ -17,10 +17,26 @@ # under the License. # -## Build +set(CPP_FLAGS ${CXX_WARNING_FLAGS}) -include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src") -include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include") +## Check compiler capabilities. +macro(compiler_test RESULT_VAR NAME CODE) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${NAME} "${CODE}") + try_compile(${RESULT_VAR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}) +endmacro() + +compiler_test(RESULT has_long_long.cpp "long long ll; int main(int, char**) { return 0; }") +if (RESULT) + message("C++ compiler has long long") + set(CPP_FLAGS "${CPP_FLAGS} -DHAS_LONG_LONG") +else() + message("C++ compiler does not have long long") +endif() + +include_directories( + "${CMAKE_SOURCE_DIR}/proton-c/include" + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}/src") set(qpid-proton-cpp-source src/Acceptor.cpp @@ -55,15 +71,19 @@ set(qpid-proton-cpp-source src/Value.cpp src/Values.cpp src/proton_bits.cpp - src/blocking/BlockingConnection.cpp - src/blocking/BlockingConnectionImpl.cpp - src/blocking/BlockingLink.cpp - src/blocking/BlockingSender.cpp + src/BlockingConnection.cpp + src/BlockingConnectionImpl.cpp + src/BlockingLink.cpp + src/BlockingSender.cpp src/contexts.cpp src/types.cpp ) -set_source_files_properties(${qpid-proton-cpp-source} PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS}") +set_source_files_properties ( + ${qpid-proton-cpp-source} + PROPERTIES + COMPILE_FLAGS "${CPP_FLAGS}" + ) add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) @@ -100,7 +120,7 @@ add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) ## Install -install (TARGETS qpid-proton-cpp +install(TARGETS qpid-proton-cpp EXPORT proton ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR}) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Acceptor.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Acceptor.hpp b/proton-c/bindings/cpp/include/proton/Acceptor.hpp index 591af2c..5702c10 100644 --- a/proton-c/bindings/cpp/include/proton/Acceptor.hpp +++ b/proton-c/bindings/cpp/include/proton/Acceptor.hpp @@ -21,9 +21,10 @@ * under the License. * */ -#include "proton/ImportExport.hpp" -#include "proton/ProtonHandle.hpp" + #include "proton/reactor.h" +#include "proton/export.hpp" +#include "proton/ProtonHandle.hpp" struct pn_connection_t; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Acking.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Acking.hpp b/proton-c/bindings/cpp/include/proton/Acking.hpp index 67da0b1..327f1a1 100644 --- a/proton-c/bindings/cpp/include/proton/Acking.hpp +++ b/proton-c/bindings/cpp/include/proton/Acking.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Delivery.hpp" namespace proton { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp b/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp index 77345c4..5b01136 100644 --- a/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp +++ b/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Handle.hpp" #include "proton/Endpoint.hpp" #include "proton/Container.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/BlockingLink.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/BlockingLink.hpp b/proton-c/bindings/cpp/include/proton/BlockingLink.hpp index 80df739..b1a5915 100644 --- a/proton-c/bindings/cpp/include/proton/BlockingLink.hpp +++ b/proton-c/bindings/cpp/include/proton/BlockingLink.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Handle.hpp" #include "proton/Endpoint.hpp" #include "proton/Container.hpp" @@ -40,14 +40,14 @@ class BlockingLink { public: PN_CPP_EXTERN void close(); - ~BlockingLink(); + PN_CPP_EXTERN ~BlockingLink(); protected: PN_CPP_EXTERN BlockingLink(BlockingConnection *c, pn_link_t *l); PN_CPP_EXTERN void waitForClosed(Duration timeout=Duration::SECOND); private: BlockingConnection connection; Link link; - void checkClosed(); + PN_CPP_EXTERN void checkClosed(); friend class BlockingConnection; friend class BlockingSender; friend class BlockingReceiver; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/BlockingSender.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/BlockingSender.hpp b/proton-c/bindings/cpp/include/proton/BlockingSender.hpp index 25f09bb..5d95df5 100644 --- a/proton-c/bindings/cpp/include/proton/BlockingSender.hpp +++ b/proton-c/bindings/cpp/include/proton/BlockingSender.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Handle.hpp" #include "proton/Endpoint.hpp" #include "proton/Container.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Connection.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Connection.hpp b/proton-c/bindings/cpp/include/proton/Connection.hpp index 5656889..c16556b 100644 --- a/proton-c/bindings/cpp/include/proton/Connection.hpp +++ b/proton-c/bindings/cpp/include/proton/Connection.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Handle.hpp" #include "proton/Endpoint.hpp" #include "proton/Container.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Container.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Container.hpp b/proton-c/bindings/cpp/include/proton/Container.hpp index 7333566..c1ecb65 100644 --- a/proton-c/bindings/cpp/include/proton/Container.hpp +++ b/proton-c/bindings/cpp/include/proton/Container.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Handle.hpp" #include "proton/Acceptor.hpp" #include "proton/Duration.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Data.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Data.hpp b/proton-c/bindings/cpp/include/proton/Data.hpp index 30f85b7..77df52f 100644 --- a/proton-c/bindings/cpp/include/proton/Data.hpp +++ b/proton-c/bindings/cpp/include/proton/Data.hpp @@ -19,7 +19,7 @@ * under the License. */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include <iosfwd> /**@file @@ -31,37 +31,36 @@ struct pn_data_t; namespace proton { /** Base for classes that hold AMQP data. */ -PN_CPP_EXTERN class Data { +class Data { public: - explicit Data(); - virtual ~Data(); - Data(const Data&); - - Data& operator=(const Data&); + PN_CPP_EXTERN explicit Data(); + PN_CPP_EXTERN Data(const Data&); + PN_CPP_EXTERN virtual ~Data(); + PN_CPP_EXTERN Data& operator=(const Data&); /** Clear the data. */ - void clear(); + PN_CPP_EXTERN void clear(); /** True if there are no values. */ - bool empty() const; - - /** Human readable representation of data. */ - friend std::ostream& operator<<(std::ostream&, const Data&); + PN_CPP_EXTERN bool empty() const; /** The underlying pn_data_t */ - pn_data_t* pnData() { return data; } + PN_CPP_EXTERN pn_data_t* pnData() { return data; } /** True if this Data object owns it's own pn_data_t, false if it is acting as a "view" */ - bool own() const { return own_; } + PN_CPP_EXTERN bool own() const { return own_; } - void swap(Data&); + PN_CPP_EXTERN void swap(Data&); + + /** Human readable representation of data. */ + friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const Data&); protected: /** Does not take ownership, just a view on the data */ - explicit Data(pn_data_t*); + PN_CPP_EXTERN explicit Data(pn_data_t*); /** Does not take ownership, just a view on the data */ - void view(pn_data_t*); + PN_CPP_EXTERN void view(pn_data_t*); mutable pn_data_t* data; bool own_; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Decoder.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Decoder.hpp b/proton-c/bindings/cpp/include/proton/Decoder.hpp index c3da9dc..11cd5fb 100644 --- a/proton-c/bindings/cpp/include/proton/Decoder.hpp +++ b/proton-c/bindings/cpp/include/proton/Decoder.hpp @@ -20,8 +20,9 @@ */ #include "proton/Data.hpp" -#include "proton/types.hpp" #include "proton/Error.hpp" +#include "proton/type_traits.hpp" +#include "proton/types.hpp" #include <iosfwd> namespace proton { @@ -29,7 +30,7 @@ namespace proton { class Value; /** Raised by Decoder operations on error */ -struct DecodeError : public Error { explicit DecodeError(const std::string&) throw(); }; +struct DecodeError : public Error { PN_CPP_EXTERN explicit DecodeError(const std::string&) throw(); }; /**@file * Stream-like decoder from AMQP bytes to C++ values. @@ -64,7 +65,7 @@ extracting AMQP maps. You can also extract container values element-by-element, see the Start class. */ -PN_CPP_EXTERN class Decoder : public virtual Data { +class Decoder : public virtual Data { public: PN_CPP_EXTERN Decoder(); @@ -171,16 +172,21 @@ PN_CPP_EXTERN class Decoder : public virtual Data { private: template <class T> Decoder& extract(T& value); - void checkType(TypeId); - - // Not implemented - Decoder(const Decoder&); - Decoder& operator=(const Decoder&); + PN_CPP_EXTERN void checkType(TypeId); friend class Value; friend class Encoder; }; +// operator >> for integer types that are not covered by the standard overrides. +template <class T> +typename std::enable_if<IsUnknownInteger<T>::value, Decoder&>::type operator>>(Decoder& d, T& i) { + typename IntegerType<sizeof(T), std::is_signed<T>::value>::type v; + d >> v; // Extract as a known integer type + i = v; + return d; +} + template <class T> Decoder& operator>>(Decoder& d, Ref<T, ARRAY> ref) { Decoder::Scope s(d); if (s.isDescribed) d >> skip(); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Delivery.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Delivery.hpp b/proton-c/bindings/cpp/include/proton/Delivery.hpp index b90f7fa..110b1ce 100644 --- a/proton-c/bindings/cpp/include/proton/Delivery.hpp +++ b/proton-c/bindings/cpp/include/proton/Delivery.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/ProtonHandle.hpp" #include "proton/delivery.h" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Duration.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Duration.hpp b/proton-c/bindings/cpp/include/proton/Duration.hpp index 288ef9d..596b4d0 100644 --- a/proton-c/bindings/cpp/include/proton/Duration.hpp +++ b/proton-c/bindings/cpp/include/proton/Duration.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/types.hpp" namespace proton { @@ -33,20 +33,20 @@ namespace proton { class Duration : public Comparable<Duration> { public: - uint64_t milliseconds; - explicit Duration(uint64_t ms) : milliseconds(ms) {} + std::uint64_t milliseconds; + explicit Duration(std::uint64_t ms) : milliseconds(ms) {} bool operator<(Duration d) { return milliseconds < d.milliseconds; } bool operator==(Duration d) { return milliseconds == d.milliseconds; } - static const Duration FOREVER; - static const Duration IMMEDIATE; - static const Duration SECOND; - static const Duration MINUTE; + PN_CPP_EXTERN static const Duration FOREVER; + PN_CPP_EXTERN static const Duration IMMEDIATE; + PN_CPP_EXTERN static const Duration SECOND; + PN_CPP_EXTERN static const Duration MINUTE; }; -inline Duration operator*(Duration d, uint64_t n) { return Duration(d.milliseconds*n); } -inline Duration operator*(uint64_t n, Duration d) { return d * n; } +inline Duration operator*(Duration d, std::uint64_t n) { return Duration(d.milliseconds*n); } +inline Duration operator*(std::uint64_t n, Duration d) { return d * n; } inline Timestamp operator+(Timestamp ts, Duration d) { return Timestamp(ts.milliseconds+d.milliseconds); } inline Timestamp operator+(Duration d, Timestamp ts) { return ts + d; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Encoder.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Encoder.hpp b/proton-c/bindings/cpp/include/proton/Encoder.hpp index aaa8d93..8b2f77c 100644 --- a/proton-c/bindings/cpp/include/proton/Encoder.hpp +++ b/proton-c/bindings/cpp/include/proton/Encoder.hpp @@ -20,15 +20,17 @@ */ #include "proton/Data.hpp" -#include "proton/types.hpp" #include "proton/Error.hpp" +#include "proton/types.hpp" +#include "proton/type_traits.hpp" #include <iosfwd> +#include <iostream> // FIXME aconway 2015-06-18: + struct pn_data_t; namespace proton { - class Value; /**@file @@ -37,7 +39,7 @@ class Value; */ /** Raised by Encoder operations on error */ -struct EncodeError : public Error { explicit EncodeError(const std::string&) throw(); }; +struct EncodeError : public Error { PN_CPP_EXTERN explicit EncodeError(const std::string&) throw(); }; /** @ingroup cpp @@ -84,41 +86,41 @@ class Encoder : public virtual Data { /** @name Insert simple types. *@{ */ - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Null); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Bool); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Ubyte); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Byte); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Ushort); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Short); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Uint); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Int); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Char); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Ulong); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Long); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Timestamp); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Float); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Double); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Decimal32); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Decimal64); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Decimal128); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Uuid); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, String); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Symbol); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, Binary); - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, const Value&); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Null); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Bool); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ubyte); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Byte); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ushort); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Short); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Uint); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Int); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Char); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ulong); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Long); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Timestamp); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Float); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Double); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal32); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal64); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal128); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Uuid); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, String); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Symbol); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Binary); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, const Value&); ///@} /** Start a container type. See the Start class. */ - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, const Start&); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, const Start&); /** Finish a container type. */ - PN_CPP_EXTERN friend Encoder& operator<<(Encoder& e, Finish); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder& e, Finish); /**@name Insert values returned by the as<TypeId> helper. *@{ */ - template <class T, TypeId A> friend Encoder& operator<<(Encoder&, CRef<T, A>); + template <class T, TypeId A> friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, CRef<T, A>); template <class T> friend Encoder& operator<<(Encoder&, CRef<T, ARRAY>); template <class T> friend Encoder& operator<<(Encoder&, CRef<T, LIST>); template <class T> friend Encoder& operator<<(Encoder&, CRef<T, MAP>); @@ -126,29 +128,24 @@ class Encoder : public virtual Data { ///@} /** Copy data from a raw pn_data_t */ - PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, pn_data_t*); + friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, pn_data_t*); + private: PN_CPP_EXTERN Encoder(pn_data_t* pd); - // Not implemented - Encoder(const Encoder&); - Encoder& operator=(const Encoder&); - friend class Value; }; -/** Encode const char* as string */ -inline Encoder& operator<<(Encoder& e, const char* s) { return e << String(s); } - -/** Encode char* as string */ +// Need to disambiguate char* conversion to bool and std::string as String. inline Encoder& operator<<(Encoder& e, char* s) { return e << String(s); } - -/** Encode std::string as string */ +inline Encoder& operator<<(Encoder& e, const char* s) { return e << String(s); } inline Encoder& operator<<(Encoder& e, const std::string& s) { return e << String(s); } -//@internal Convert a Ref to a CRef. -template <class T, TypeId A> Encoder& operator<<(Encoder& e, Ref<T, A> ref) { - return e << CRef<T,A>(ref); +// operator << for integer types that are not covered by the standard overrides. +template <class T> +typename std::enable_if<IsUnknownInteger<T>::value, Encoder&>::type operator<<(Encoder& e, T i) { + typename IntegerType<sizeof(T), std::is_signed<T>::value>::type v = i; + return e << v; // Insert as a known integer type } // TODO aconway 2015-06-16: described array insertion. @@ -178,6 +175,10 @@ template <class T> Encoder& operator<<(Encoder& e, CRef<T, MAP> m){ e << finish(); return e; } +//@internal Convert a Ref to a CRef. +template <class T, TypeId A> Encoder& operator<<(Encoder& e, Ref<T, A> ref) { + return e << CRef<T,A>(ref); +} } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Endpoint.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Endpoint.hpp b/proton-c/bindings/cpp/include/proton/Endpoint.hpp index 2736047..645ca0f 100644 --- a/proton-c/bindings/cpp/include/proton/Endpoint.hpp +++ b/proton-c/bindings/cpp/include/proton/Endpoint.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/connection.h" namespace proton { @@ -48,8 +48,8 @@ class Endpoint virtual PN_CPP_EXTERN Connection &getConnection() = 0; Transport PN_CPP_EXTERN &getTransport(); protected: - Endpoint(); - ~Endpoint(); + PN_CPP_EXTERN Endpoint(); + PN_CPP_EXTERN ~Endpoint(); }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Error.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Error.hpp b/proton-c/bindings/cpp/include/proton/Error.hpp index a3d3242..578c3d6 100644 --- a/proton-c/bindings/cpp/include/proton/Error.hpp +++ b/proton-c/bindings/cpp/include/proton/Error.hpp @@ -22,19 +22,21 @@ * */ #include <stdexcept> +#include <string> +#include "proton/export.hpp" namespace proton { /** @ingroup cpp * Functions in the proton namespace throw a subclass of proton::Error on error. */ -struct Error : public std::runtime_error { explicit Error(const std::string&) throw(); }; +struct Error : public std::runtime_error { PN_CPP_EXTERN explicit Error(const std::string&) throw(); }; /** Raised if a message is rejected */ -struct MessageReject : public Error { explicit MessageReject(const std::string&) throw(); }; +struct MessageReject : public Error { PN_CPP_EXTERN explicit MessageReject(const std::string&) throw(); }; /** Raised if a message is released */ -struct MessageRelease : public Error { explicit MessageRelease(const std::string&) throw(); }; +struct MessageRelease : public Error { PN_CPP_EXTERN explicit MessageRelease(const std::string&) throw(); }; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Event.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Event.hpp b/proton-c/bindings/cpp/include/proton/Event.hpp index db85c9c..3fbb6a7 100644 --- a/proton-c/bindings/cpp/include/proton/Event.hpp +++ b/proton-c/bindings/cpp/include/proton/Event.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Link.hpp" #include "proton/Connection.hpp" #include "proton/Message.hpp" @@ -48,10 +48,10 @@ class Event virtual PN_CPP_EXTERN void setMessage(Message &); virtual PN_CPP_EXTERN ~Event(); protected: - PN_CPP_EXTERN PN_CPP_EXTERN Event(); + PN_CPP_EXTERN Event(); private: - PN_CPP_EXTERN Event(const Event&); - PN_CPP_EXTERN Event& operator=(const Event&); + Event(const Event&); + Event& operator=(const Event&); }; }} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Handle.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Handle.hpp b/proton-c/bindings/cpp/include/proton/Handle.hpp index 648658b..916fd80 100644 --- a/proton-c/bindings/cpp/include/proton/Handle.hpp +++ b/proton-c/bindings/cpp/include/proton/Handle.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" namespace proton { namespace reactor { @@ -43,20 +43,20 @@ template <class T> class Handle { public: /**@return true if handle is valid, i.e. not null. */ - PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; } + bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; } + bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; } + operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - PROTON_CPP_INLINE_EXTERN bool operator !() const { return !impl; } + bool operator !() const { return !impl; } /** Operator == equal if they point to same non-null object*/ - PROTON_CPP_INLINE_EXTERN bool operator ==(const Handle<T>& other) const { return impl == other.impl; } - PROTON_CPP_INLINE_EXTERN bool operator !=(const Handle<T>& other) const { return impl != other.impl; } + bool operator ==(const Handle<T>& other) const { return impl == other.impl; } + bool operator !=(const Handle<T>& other) const { return impl != other.impl; } void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } @@ -67,7 +67,7 @@ template <class T> class Handle { protected: typedef T Impl; - PROTON_CPP_INLINE_EXTERN Handle() :impl() {} + Handle() : impl() {} mutable Impl* impl; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Handler.hpp b/proton-c/bindings/cpp/include/proton/Handler.hpp index c66eecb..f7bb23b 100644 --- a/proton-c/bindings/cpp/include/proton/Handler.hpp +++ b/proton-c/bindings/cpp/include/proton/Handler.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Event.hpp" #include "proton/event.h" #include <vector> @@ -29,7 +29,7 @@ namespace proton { namespace reactor { -class PN_CPP_EXTERN Handler +class Handler { public: PN_CPP_EXTERN Handler(); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/ImportExport.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/ImportExport.hpp b/proton-c/bindings/cpp/include/proton/ImportExport.hpp deleted file mode 100644 index cbc0626..0000000 --- a/proton-c/bindings/cpp/include/proton/ImportExport.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef PROTON_CPP_IMPORTEXPORT_H -#define PROTON_CPP_IMPORTEXPORT_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#if defined(WIN32) && !defined(PROTON_CPP_DECLARE_STATIC) - // - // Import and Export definitions for Windows: - // -# define PROTON_CPP_EXPORT __declspec(dllexport) -# define PROTON_CPP_IMPORT __declspec(dllimport) -#else - // - // Non-Windows (Linux, etc.) definitions: - // -# define PROTON_CPP_EXPORT -# define PROTON_CPP_IMPORT -#endif - - -// For c++ library symbols - -#ifdef protoncpp_EXPORTS -# define PN_CPP_EXTERN PROTON_CPP_EXPORT -#else -# define PN_CPP_EXTERN PROTON_CPP_IMPORT -#endif - -// TODO: -#define PROTON_CPP_INLINE_EXTERN - -#endif /*!PROTON_CPP_IMPORTEXPORT_H*/ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Link.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Link.hpp b/proton-c/bindings/cpp/include/proton/Link.hpp index 5500041..ac0e471 100644 --- a/proton-c/bindings/cpp/include/proton/Link.hpp +++ b/proton-c/bindings/cpp/include/proton/Link.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/ProtonHandle.hpp" #include "proton/Endpoint.hpp" #include "proton/Terminus.hpp" @@ -55,7 +55,7 @@ class Link : public Endpoint, public ProtonHandle<pn_link_t> virtual PN_CPP_EXTERN Connection &getConnection(); PN_CPP_EXTERN Link getNext(Endpoint::State mask); protected: - virtual void verifyType(pn_link_t *l); + PN_CPP_EXTERN virtual void verifyType(pn_link_t *l); private: friend class ProtonImplRef<Link>; bool senderLink; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Message.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Message.hpp b/proton-c/bindings/cpp/include/proton/Message.hpp index b35eb18..c98dc31 100644 --- a/proton-c/bindings/cpp/include/proton/Message.hpp +++ b/proton-c/bindings/cpp/include/proton/Message.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/ProtonHandle.hpp" #include "proton/Value.hpp" #include "proton/Message.hpp" @@ -33,74 +33,74 @@ struct pn_data_t; namespace proton { // FIXME aconway 2015-06-17: documentation of properties. -PN_CPP_EXTERN class Message : public reactor::ProtonHandle<pn_message_t> +class Message : public reactor::ProtonHandle<pn_message_t> { public: - Message(); - Message(pn_message_t *); - Message(const Message&); - Message& operator=(const Message&); - ~Message(); + PN_CPP_EXTERN Message(); + PN_CPP_EXTERN Message(pn_message_t *); + PN_CPP_EXTERN Message(const Message&); + PN_CPP_EXTERN Message& operator=(const Message&); + PN_CPP_EXTERN ~Message(); - pn_message_t *pnMessage() const; + PN_CPP_EXTERN pn_message_t *pnMessage() const; - void id(const Value& id); - Value id() const; + PN_CPP_EXTERN void id(const Value& id); + PN_CPP_EXTERN Value id() const; - void user(const std::string &user); - std::string user() const; + PN_CPP_EXTERN void user(const std::string &user); + PN_CPP_EXTERN std::string user() const; - void address(const std::string &addr); - std::string address() const; + PN_CPP_EXTERN void address(const std::string &addr); + PN_CPP_EXTERN std::string address() const; - void subject(const std::string &s); - std::string subject() const; + PN_CPP_EXTERN void subject(const std::string &s); + PN_CPP_EXTERN std::string subject() const; - void replyTo(const std::string &s); - std::string replyTo() const; + PN_CPP_EXTERN void replyTo(const std::string &s); + PN_CPP_EXTERN std::string replyTo() const; - void correlationId(const Value&); - Value correlationId() const; + PN_CPP_EXTERN void correlationId(const Value&); + PN_CPP_EXTERN Value correlationId() const; - void contentType(const std::string &s); - std::string contentType() const; + PN_CPP_EXTERN void contentType(const std::string &s); + PN_CPP_EXTERN std::string contentType() const; - void contentEncoding(const std::string &s); - std::string contentEncoding() const; + PN_CPP_EXTERN void contentEncoding(const std::string &s); + PN_CPP_EXTERN std::string contentEncoding() const; - void expiry(Timestamp t); - Timestamp expiry() const; + PN_CPP_EXTERN void expiry(Timestamp t); + PN_CPP_EXTERN Timestamp expiry() const; - void creationTime(Timestamp t); - Timestamp creationTime() const; + PN_CPP_EXTERN void creationTime(Timestamp t); + PN_CPP_EXTERN Timestamp creationTime() const; - void groupId(const std::string &s); - std::string groupId() const; + PN_CPP_EXTERN void groupId(const std::string &s); + PN_CPP_EXTERN std::string groupId() const; - void replyToGroupId(const std::string &s); - std::string replyToGroupId() const; + PN_CPP_EXTERN void replyToGroupId(const std::string &s); + PN_CPP_EXTERN std::string replyToGroupId() const; /** Set the body to an AMQP value. */ - void body(const Value&); + PN_CPP_EXTERN void body(const Value&); /** Template to convert any type to a Value and set as the body */ template <class T> void body(const T& v) { body(Value(v)); } /** Set the body to a sequence of sections containing AMQP values. */ - void body(const Values&); + PN_CPP_EXTERN void body(const Values&); - const Values& body() const; + PN_CPP_EXTERN const Values& body() const; - Values& body(); ///< Allows in-place modification of body sections. + PN_CPP_EXTERN Values& body(); ///< Allows in-place modification of body sections. // FIXME aconway 2015-06-17: consistent and flexible treatment of buffers. // Allow convenient std::string encoding/decoding (with re-use of existing // string capacity) but also need to allow encoding/decoding of non-string // buffers. Introduce a buffer type with begin/end pointers? - void encode(std::string &data); - std::string encode(); - void decode(const std::string &data); + PN_CPP_EXTERN void encode(std::string &data); + PN_CPP_EXTERN std::string encode(); + PN_CPP_EXTERN void decode(const std::string &data); private: mutable Values body_; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp b/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp index 06858e3..ddc8165 100644 --- a/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp +++ b/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp @@ -32,63 +32,65 @@ namespace reactor { class Event; class MessagingAdapter; -class PN_CPP_EXTERN MessagingHandler : public ProtonHandler , public Acking +class MessagingHandler : public ProtonHandler , public Acking { public: PN_CPP_EXTERN MessagingHandler(int prefetch=10, bool autoAccept=true, bool autoSettle=true, bool peerCloseIsError=false); - virtual ~MessagingHandler(); + PN_CPP_EXTERN virtual ~MessagingHandler(); - virtual void onAbort(Event &e); - virtual void onAccepted(Event &e); - virtual void onCommit(Event &e); - virtual void onConnectionClosed(Event &e); - virtual void onConnectionClosing(Event &e); - virtual void onConnectionError(Event &e); - virtual void onConnectionOpening(Event &e); - virtual void onConnectionOpened(Event &e); - virtual void onDisconnected(Event &e); - virtual void onFetch(Event &e); - virtual void onIdLoaded(Event &e); - virtual void onLinkClosed(Event &e); - virtual void onLinkClosing(Event &e); - virtual void onLinkError(Event &e); - virtual void onLinkOpened(Event &e); - virtual void onLinkOpening(Event &e); - virtual void onMessage(Event &e); - virtual void onQuit(Event &e); - virtual void onRecordInserted(Event &e); - virtual void onRecordsLoaded(Event &e); - virtual void onRejected(Event &e); - virtual void onReleased(Event &e); - virtual void onRequest(Event &e); - virtual void onResponse(Event &e); - virtual void onSendable(Event &e); - virtual void onSessionClosed(Event &e); - virtual void onSessionClosing(Event &e); - virtual void onSessionError(Event &e); - virtual void onSessionOpened(Event &e); - virtual void onSessionOpening(Event &e); - virtual void onSettled(Event &e); - virtual void onStart(Event &e); - virtual void onTimer(Event &e); - virtual void onTransactionAborted(Event &e); - virtual void onTransactionCommitted(Event &e); - virtual void onTransactionDeclared(Event &e); - virtual void onTransportClosed(Event &e); - protected: + PN_CPP_EXTERN virtual void onAbort(Event &e); + PN_CPP_EXTERN virtual void onAccepted(Event &e); + PN_CPP_EXTERN virtual void onCommit(Event &e); + PN_CPP_EXTERN virtual void onConnectionClosed(Event &e); + PN_CPP_EXTERN virtual void onConnectionClosing(Event &e); + PN_CPP_EXTERN virtual void onConnectionError(Event &e); + PN_CPP_EXTERN virtual void onConnectionOpening(Event &e); + PN_CPP_EXTERN virtual void onConnectionOpened(Event &e); + PN_CPP_EXTERN virtual void onDisconnected(Event &e); + PN_CPP_EXTERN virtual void onFetch(Event &e); + PN_CPP_EXTERN virtual void onIdLoaded(Event &e); + PN_CPP_EXTERN virtual void onLinkClosed(Event &e); + PN_CPP_EXTERN virtual void onLinkClosing(Event &e); + PN_CPP_EXTERN virtual void onLinkError(Event &e); + PN_CPP_EXTERN virtual void onLinkOpened(Event &e); + PN_CPP_EXTERN virtual void onLinkOpening(Event &e); + PN_CPP_EXTERN virtual void onMessage(Event &e); + PN_CPP_EXTERN virtual void onQuit(Event &e); + PN_CPP_EXTERN virtual void onRecordInserted(Event &e); + PN_CPP_EXTERN virtual void onRecordsLoaded(Event &e); + PN_CPP_EXTERN virtual void onRejected(Event &e); + PN_CPP_EXTERN virtual void onReleased(Event &e); + PN_CPP_EXTERN virtual void onRequest(Event &e); + PN_CPP_EXTERN virtual void onResponse(Event &e); + PN_CPP_EXTERN virtual void onSendable(Event &e); + PN_CPP_EXTERN virtual void onSessionClosed(Event &e); + PN_CPP_EXTERN virtual void onSessionClosing(Event &e); + PN_CPP_EXTERN virtual void onSessionError(Event &e); + PN_CPP_EXTERN virtual void onSessionOpened(Event &e); + PN_CPP_EXTERN virtual void onSessionOpening(Event &e); + PN_CPP_EXTERN virtual void onSettled(Event &e); + PN_CPP_EXTERN virtual void onStart(Event &e); + PN_CPP_EXTERN virtual void onTimer(Event &e); + PN_CPP_EXTERN virtual void onTransactionAborted(Event &e); + PN_CPP_EXTERN virtual void onTransactionCommitted(Event &e); + PN_CPP_EXTERN virtual void onTransactionDeclared(Event &e); + PN_CPP_EXTERN virtual void onTransportClosed(Event &e); + + protected: int prefetch; bool autoAccept; bool autoSettle; bool peerCloseIsError; MessagingAdapter *messagingAdapter; Handler *flowController; - PN_CPP_EXTERN MessagingHandler(bool rawHandler, int prefetch=10, bool autoAccept=true, bool autoSettle=true, - bool peerCloseIsError=false); + PN_CPP_EXTERN MessagingHandler( + bool rawHandler, int prefetch=10, bool autoAccept=true, + bool autoSettle=true, bool peerCloseIsError=false); private: friend class ContainerImpl; friend class MessagingAdapter; - void createHelpers(); + PN_CPP_EXTERN void createHelpers(); }; }} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp b/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp index 213bc14..da12c09 100644 --- a/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp +++ b/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" namespace proton { namespace reactor { @@ -36,16 +36,16 @@ template <class T> class ProtonHandle { public: /**@return true if handle is valid, i.e. not null. */ - PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; } + bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; } + bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; } + operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - PROTON_CPP_INLINE_EXTERN bool operator !() const { return !impl; } + bool operator !() const { return !impl; } void swap(ProtonHandle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } @@ -56,7 +56,7 @@ template <class T> class ProtonHandle { protected: typedef T Impl; - PROTON_CPP_INLINE_EXTERN ProtonHandle() :impl() {} + ProtonHandle() :impl() {} mutable Impl* impl; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp b/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp index 799ca89..3768f78 100644 --- a/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp +++ b/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp @@ -33,48 +33,48 @@ class ProtonHandler : public Handler { public: PN_CPP_EXTERN ProtonHandler(); - virtual void onReactorInit(Event &e); - virtual void onReactorQuiesced(Event &e); - virtual void onReactorFinal(Event &e); - virtual void onTimerTask(Event &e); - virtual void onConnectionInit(Event &e); - virtual void onConnectionBound(Event &e); - virtual void onConnectionUnbound(Event &e); - virtual void onConnectionLocalOpen(Event &e); - virtual void onConnectionLocalClose(Event &e); - virtual void onConnectionRemoteOpen(Event &e); - virtual void onConnectionRemoteClose(Event &e); - virtual void onConnectionFinal(Event &e); - virtual void onSessionInit(Event &e); - virtual void onSessionLocalOpen(Event &e); - virtual void onSessionLocalClose(Event &e); - virtual void onSessionRemoteOpen(Event &e); - virtual void onSessionRemoteClose(Event &e); - virtual void onSessionFinal(Event &e); - virtual void onLinkInit(Event &e); - virtual void onLinkLocalOpen(Event &e); - virtual void onLinkLocalClose(Event &e); - virtual void onLinkLocalDetach(Event &e); - virtual void onLinkRemoteOpen(Event &e); - virtual void onLinkRemoteClose(Event &e); - virtual void onLinkRemoteDetach(Event &e); - virtual void onLinkFlow(Event &e); - virtual void onLinkFinal(Event &e); - virtual void onDelivery(Event &e); - virtual void onTransport(Event &e); - virtual void onTransportError(Event &e); - virtual void onTransportHeadClosed(Event &e); - virtual void onTransportTailClosed(Event &e); - virtual void onTransportClosed(Event &e); - virtual void onSelectableInit(Event &e); - virtual void onSelectableUpdated(Event &e); - virtual void onSelectableReadable(Event &e); - virtual void onSelectableWritable(Event &e); - virtual void onSelectableExpired(Event &e); - virtual void onSelectableError(Event &e); - virtual void onSelectableFinal(Event &e); + PN_CPP_EXTERN virtual void onReactorInit(Event &e); + PN_CPP_EXTERN virtual void onReactorQuiesced(Event &e); + PN_CPP_EXTERN virtual void onReactorFinal(Event &e); + PN_CPP_EXTERN virtual void onTimerTask(Event &e); + PN_CPP_EXTERN virtual void onConnectionInit(Event &e); + PN_CPP_EXTERN virtual void onConnectionBound(Event &e); + PN_CPP_EXTERN virtual void onConnectionUnbound(Event &e); + PN_CPP_EXTERN virtual void onConnectionLocalOpen(Event &e); + PN_CPP_EXTERN virtual void onConnectionLocalClose(Event &e); + PN_CPP_EXTERN virtual void onConnectionRemoteOpen(Event &e); + PN_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e); + PN_CPP_EXTERN virtual void onConnectionFinal(Event &e); + PN_CPP_EXTERN virtual void onSessionInit(Event &e); + PN_CPP_EXTERN virtual void onSessionLocalOpen(Event &e); + PN_CPP_EXTERN virtual void onSessionLocalClose(Event &e); + PN_CPP_EXTERN virtual void onSessionRemoteOpen(Event &e); + PN_CPP_EXTERN virtual void onSessionRemoteClose(Event &e); + PN_CPP_EXTERN virtual void onSessionFinal(Event &e); + PN_CPP_EXTERN virtual void onLinkInit(Event &e); + PN_CPP_EXTERN virtual void onLinkLocalOpen(Event &e); + PN_CPP_EXTERN virtual void onLinkLocalClose(Event &e); + PN_CPP_EXTERN virtual void onLinkLocalDetach(Event &e); + PN_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e); + PN_CPP_EXTERN virtual void onLinkRemoteClose(Event &e); + PN_CPP_EXTERN virtual void onLinkRemoteDetach(Event &e); + PN_CPP_EXTERN virtual void onLinkFlow(Event &e); + PN_CPP_EXTERN virtual void onLinkFinal(Event &e); + PN_CPP_EXTERN virtual void onDelivery(Event &e); + PN_CPP_EXTERN virtual void onTransport(Event &e); + PN_CPP_EXTERN virtual void onTransportError(Event &e); + PN_CPP_EXTERN virtual void onTransportHeadClosed(Event &e); + PN_CPP_EXTERN virtual void onTransportTailClosed(Event &e); + PN_CPP_EXTERN virtual void onTransportClosed(Event &e); + PN_CPP_EXTERN virtual void onSelectableInit(Event &e); + PN_CPP_EXTERN virtual void onSelectableUpdated(Event &e); + PN_CPP_EXTERN virtual void onSelectableReadable(Event &e); + PN_CPP_EXTERN virtual void onSelectableWritable(Event &e); + PN_CPP_EXTERN virtual void onSelectableExpired(Event &e); + PN_CPP_EXTERN virtual void onSelectableError(Event &e); + PN_CPP_EXTERN virtual void onSelectableFinal(Event &e); - virtual void onUnhandled(Event &e); + PN_CPP_EXTERN virtual void onUnhandled(Event &e); }; }} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Receiver.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Receiver.hpp b/proton-c/bindings/cpp/include/proton/Receiver.hpp index ad22302..4f2333e 100644 --- a/proton-c/bindings/cpp/include/proton/Receiver.hpp +++ b/proton-c/bindings/cpp/include/proton/Receiver.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Endpoint.hpp" #include "proton/Link.hpp" #include "proton/types.h" @@ -39,7 +39,7 @@ class Receiver : public Link PN_CPP_EXTERN Receiver(); PN_CPP_EXTERN Receiver(const Link& c); protected: - virtual void verifyType(pn_link_t *l); + PN_CPP_EXTERN virtual void verifyType(pn_link_t *l); }; }} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Sender.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Sender.hpp b/proton-c/bindings/cpp/include/proton/Sender.hpp index 3a3ee41..33e02b7 100644 --- a/proton-c/bindings/cpp/include/proton/Sender.hpp +++ b/proton-c/bindings/cpp/include/proton/Sender.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Delivery.hpp" #include "proton/Link.hpp" #include "proton/Message.hpp" @@ -38,12 +38,12 @@ namespace reactor { class Sender : public Link { public: - PN_CPP_EXTERN Sender(pn_link_t *lnk); - PN_CPP_EXTERN Sender(); + PN_CPP_EXTERN Sender(pn_link_t *lnk=0); PN_CPP_EXTERN Sender(const Link& c); PN_CPP_EXTERN Delivery send(Message &m); + protected: - virtual void verifyType(pn_link_t *l); + PN_CPP_EXTERN virtual void verifyType(pn_link_t *l); }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Session.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Session.hpp b/proton-c/bindings/cpp/include/proton/Session.hpp index 1f19b32..eaae4ce 100644 --- a/proton-c/bindings/cpp/include/proton/Session.hpp +++ b/proton-c/bindings/cpp/include/proton/Session.hpp @@ -21,13 +21,12 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Endpoint.hpp" #include "proton/Link.hpp" #include "proton/types.h" #include "proton/link.h" -#include "ProtonImplRef.hpp" #include <string> struct pn_connection_t; @@ -50,9 +49,9 @@ class Transport; PN_CPP_EXTERN Session& operator=(const Session&); PN_CPP_EXTERN void close(); PN_CPP_EXTERN pn_session_t *getPnSession(); - virtual PN_CPP_EXTERN Connection &getConnection(); - Receiver createReceiver(std::string name); - Sender createSender(std::string name); + PN_CPP_EXTERN virtual Connection &getConnection(); + PN_CPP_EXTERN Receiver createReceiver(std::string name); + PN_CPP_EXTERN Sender createSender(std::string name); private: friend class ProtonImplRef<Session>; }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Terminus.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Terminus.hpp b/proton-c/bindings/cpp/include/proton/Terminus.hpp index b13165e..91d4f6f 100644 --- a/proton-c/bindings/cpp/include/proton/Terminus.hpp +++ b/proton-c/bindings/cpp/include/proton/Terminus.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/Link.hpp" #include "proton/link.h" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Transport.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Transport.hpp b/proton-c/bindings/cpp/include/proton/Transport.hpp index f81e483..1a8d39c 100644 --- a/proton-c/bindings/cpp/include/proton/Transport.hpp +++ b/proton-c/bindings/cpp/include/proton/Transport.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" #include "proton/transport.h" #include <string> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Value.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Value.hpp b/proton-c/bindings/cpp/include/proton/Value.hpp index a5f2edf..43a5878 100644 --- a/proton-c/bindings/cpp/include/proton/Value.hpp +++ b/proton-c/bindings/cpp/include/proton/Value.hpp @@ -30,22 +30,22 @@ struct pn_data_t; namespace proton { /** Holds a single AMQP value. */ -PN_CPP_EXTERN class Value { +class Value { public: - Value(); - Value(const Value&); + PN_CPP_EXTERN Value(); + PN_CPP_EXTERN Value(const Value&); /** Converting constructor from any settable value */ template <class T> explicit Value(const T& v); - ~Value(); + PN_CPP_EXTERN ~Value(); - Value& operator=(const Value&); + PN_CPP_EXTERN Value& operator=(const Value&); /** Copy the first value from a raw pn_data_t. */ - Value& operator=(pn_data_t*); + PN_CPP_EXTERN Value& operator=(pn_data_t*); - TypeId type() const; + PN_CPP_EXTERN TypeId type() const; /** Set the value. */ template<class T> void set(const T& value); @@ -61,19 +61,19 @@ PN_CPP_EXTERN class Value { template<class T> operator T() const; /** insert a value into an Encoder. */ - friend Encoder& operator<<(Encoder&, const Value&); + PN_CPP_EXTERN friend Encoder& operator<<(Encoder&, const Value&); /** Extract a value from a decoder. */ - friend Decoder& operator>>(Decoder&, Value&); + PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Value&); /** Human readable format */ - friend std::ostream& operator<<(std::ostream&, const Value&); + PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const Value&); - bool operator==(const Value&) const; - bool operator !=(const Value& v) const{ return !(*this == v); } + PN_CPP_EXTERN bool operator==(const Value&) const; + PN_CPP_EXTERN bool operator !=(const Value& v) const{ return !(*this == v); } /** operator < makes Value valid for use as a std::map key. */ - bool operator<(const Value&) const; + PN_CPP_EXTERN bool operator<(const Value&) const; bool operator>(const Value& v) const { return v < *this; } bool operator<=(const Value& v) const { return !(*this > v); } bool operator>=(const Value& v) const { return !(*this < v); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/Values.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/Values.hpp b/proton-c/bindings/cpp/include/proton/Values.hpp index 604d2be..275f905 100644 --- a/proton-c/bindings/cpp/include/proton/Values.hpp +++ b/proton-c/bindings/cpp/include/proton/Values.hpp @@ -34,21 +34,20 @@ namespace proton { * * After inserting values, call rewind() to extract them. */ -PN_CPP_EXTERN class Values : public Encoder, public Decoder { +class Values : public Encoder, public Decoder { public: - Values(); - Values(const Values&); + PN_CPP_EXTERN Values(); + PN_CPP_EXTERN Values(const Values&); /** Does not take ownership, just a view on the data */ - Values(pn_data_t*); + PN_CPP_EXTERN Values(pn_data_t*); - ~Values(); + PN_CPP_EXTERN ~Values(); /** Copy data from another Values */ - Values& operator=(const Values&); - - Values& rewind(); + PN_CPP_EXTERN Values& operator=(const Values&); + PN_CPP_EXTERN Values& rewind(); friend class Value; friend class Message; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/WaitCondition.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/WaitCondition.hpp b/proton-c/bindings/cpp/include/proton/WaitCondition.hpp index 12c7708..c175841 100644 --- a/proton-c/bindings/cpp/include/proton/WaitCondition.hpp +++ b/proton-c/bindings/cpp/include/proton/WaitCondition.hpp @@ -21,7 +21,7 @@ * under the License. * */ -#include "proton/ImportExport.hpp" +#include "proton/export.hpp" namespace proton { namespace reactor { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/export.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/export.hpp b/proton-c/bindings/cpp/include/proton/export.hpp new file mode 100644 index 0000000..0be5187 --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/export.hpp @@ -0,0 +1,46 @@ +#ifndef PN_CPP_IMPORTEXPORT_H +#define PN_CPP_IMPORTEXPORT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#if defined(WIN32) && !defined(PN_CPP_DECLARE_STATIC) + // + // Import and Export definitions for Windows: + // +# define PN_CPP_EXPORT __declspec(dllexport) +# define PN_CPP_IMPORT __declspec(dllimport) +#else + // + // Non-Windows (Linux, etc.) definitions: + // +# define PN_CPP_EXPORT +# define PN_CPP_IMPORT +#endif + +// For qpid-proton-cpp library symbols +#ifdef qpid_proton_cpp_EXPORTS +# define PN_CPP_EXTERN PN_CPP_EXPORT +#else +# define PN_CPP_EXTERN PN_CPP_IMPORT +#endif + +#endif /*!PN_CPP_IMPORTEXPORT_H*/ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f7e3462/proton-c/bindings/cpp/include/proton/type_traits.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp new file mode 100644 index 0000000..f635128 --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp @@ -0,0 +1,116 @@ +#ifndef ENABLE_IF_HPP +#define ENABLE_IF_HPP +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "proton/types.hpp" + +/**@file + * Type traits used for type conversions. + * @internal + */ +#if defined(__cplusplus) && __cplusplus >= 201100 +#include <type_traits> +#else +namespace std { + +// Workaround for older C++ compilers. NOTE this is NOT a full implementation of the +// corresponding c++11 types, it is the bare minimum needed by this library. + +template <bool, class T=void> struct enable_if; +template <class T> struct enable_if<true, T> { typedef T type; }; + +struct true_type { static const bool value = true; }; +struct false_type { static const bool value = false; }; + +template <class T> struct is_integral : public false_type {}; + +template <> struct is_integral<unsigned char> : public true_type {}; +template <> struct is_integral<unsigned short> : public true_type {}; +template <> struct is_integral<unsigned int> : public true_type {}; +template <> struct is_integral<unsigned long> : public true_type {}; + +template <> struct is_integral<signed char> : public true_type {}; +template <> struct is_integral<signed short> : public true_type {}; +template <> struct is_integral<signed int> : public true_type {}; +template <> struct is_integral<signed long> : public true_type {}; + +template <class T> struct is_signed : public false_type {}; + +template <> struct is_signed<unsigned char> : public false_type {}; +template <> struct is_signed<unsigned short> : public false_type {}; +template <> struct is_signed<unsigned int> : public false_type {}; +template <> struct is_signed<unsigned long> : public false_type {}; + +template <> struct is_signed<signed char> : public true_type {}; +template <> struct is_signed<signed short> : public true_type {}; +template <> struct is_signed<signed int> : public true_type {}; +template <> struct is_signed<signed long> : public true_type {}; +} +#endif // Old C++ workarounds + +namespace proton { + +// Metafunction returning exact AMQP type associated with a C++ type +template <class T> struct TypeIdOf; +template<> struct TypeIdOf<Null> { static const TypeId value=NULL_; }; +template<> struct TypeIdOf<Bool> { static const TypeId value=BOOL; }; +template<> struct TypeIdOf<Ubyte> { static const TypeId value=UBYTE; }; +template<> struct TypeIdOf<Byte> { static const TypeId value=BYTE; }; +template<> struct TypeIdOf<Ushort> { static const TypeId value=USHORT; }; +template<> struct TypeIdOf<Short> { static const TypeId value=SHORT; }; +template<> struct TypeIdOf<Uint> { static const TypeId value=UINT; }; +template<> struct TypeIdOf<Int> { static const TypeId value=INT; }; +template<> struct TypeIdOf<Char> { static const TypeId value=CHAR; }; +template<> struct TypeIdOf<Ulong> { static const TypeId value=ULONG; }; +template<> struct TypeIdOf<Long> { static const TypeId value=LONG; }; +template<> struct TypeIdOf<Timestamp> { static const TypeId value=TIMESTAMP; }; +template<> struct TypeIdOf<Float> { static const TypeId value=FLOAT; }; +template<> struct TypeIdOf<Double> { static const TypeId value=DOUBLE; }; +template<> struct TypeIdOf<Decimal32> { static const TypeId value=DECIMAL32; }; +template<> struct TypeIdOf<Decimal64> { static const TypeId value=DECIMAL64; }; +template<> struct TypeIdOf<Decimal128> { static const TypeId value=DECIMAL128; }; +template<> struct TypeIdOf<Uuid> { static const TypeId value=UUID; }; +template<> struct TypeIdOf<Binary> { static const TypeId value=BINARY; }; +template<> struct TypeIdOf<String> { static const TypeId value=STRING; }; +template<> struct TypeIdOf<Symbol> { static const TypeId value=SYMBOL; }; + +template <class T, class Enable=void> struct HasTypeId { static const bool value = false; }; +template <class T> struct HasTypeId<T, typename std::enable_if<TypeIdOf<T>::value>::type> { + static const bool value = true; +}; + +// Map to known integer types by sizeof and signedness. +template<size_t N, bool S> struct IntegerType; +template<> struct IntegerType<1, true> { typedef Byte type; }; +template<> struct IntegerType<2, true> { typedef Short type; }; +template<> struct IntegerType<4, true> { typedef Int type; }; +template<> struct IntegerType<8, true> { typedef Long type; }; +template<> struct IntegerType<1, false> { typedef Ubyte type; }; +template<> struct IntegerType<2, false> { typedef Ushort type; }; +template<> struct IntegerType<4, false> { typedef Uint type; }; +template<> struct IntegerType<8, false> { typedef Ulong type; }; + +// True if T is an integer type that does not have a TypeId mapping. +template <class T> struct IsUnknownInteger { + static const bool value = !HasTypeId<T>::value && std::is_integral<T>::value; +}; + +} +#endif // ENABLE_IF_HPP --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
