diff --git a/include/tins/CMakeLists.txt b/include/tins/CMakeLists.txt index 54f8c42..1f55d3a 100644 --- a/include/tins/CMakeLists.txt +++ b/include/tins/CMakeLists.txt @@ -6,3 +6,4 @@ INSTALL( ) ADD_SUBDIRECTORY(dot11) ADD_SUBDIRECTORY(tcp_ip) +ADD_SUBDIRECTORY(detail) diff --git a/include/tins/cxxstd.h b/include/tins/cxxstd.h index e37e9a5..d191c54 100644 --- a/include/tins/cxxstd.h +++ b/include/tins/cxxstd.h @@ -32,8 +32,6 @@ #include "config.h" -#include - #ifdef __GXX_EXPERIMENTAL_CXX0X__ #define TINS_CXXSTD_GCC_FIX 1 #else @@ -48,15 +46,6 @@ namespace Tins{ namespace Internals { -template -struct smart_ptr { -#if TINS_IS_CXX11 - typedef std::unique_ptr type; -#else - typedef std::auto_ptr type; -#endif -}; - template void unused(const T&) { } } } diff --git a/include/tins/detail/CMakeLists.txt b/include/tins/detail/CMakeLists.txt new file mode 100644 index 0000000..5d57beb --- /dev/null +++ b/include/tins/detail/CMakeLists.txt @@ -0,0 +1,6 @@ +FILE(GLOB INCLUDE_FILES "*.h") +INSTALL( + FILES ${INCLUDE_FILES} + DESTINATION include/tins/detail + COMPONENT Headers +) diff --git a/include/tins/detail/smart_ptr.h b/include/tins/detail/smart_ptr.h new file mode 100644 index 0000000..48b07d8 --- /dev/null +++ b/include/tins/detail/smart_ptr.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, Matias Fontanini + * 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. + * + * 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. + * + */ + +#ifndef TINS_SMART_PTR_H +#define TINS_SMART_PTR_H + +#include +#include "../cxxstd.h" + +namespace Tins { +namespace Internals { + +template +struct smart_ptr { +#if TINS_IS_CXX11 + typedef std::unique_ptr type; +#else + typedef std::auto_ptr type; +#endif +}; + +} // Internals +} // Tins + +#endif // TINS_SMART_PTR_H diff --git a/src/utils.cpp b/src/utils.cpp index dd4a8c1..c849e17 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -68,6 +68,7 @@ #include "cxxstd.h" #include "hw_address.h" #include "memory_helpers.h" +#include "detail/smart_ptr.h" using std::string; using std::set; diff --git a/tests/src/dot11/ack_test.cpp b/tests/src/dot11/ack_test.cpp index e78f532..e85f9f5 100644 --- a/tests/src/dot11/ack_test.cpp +++ b/tests/src/dot11/ack_test.cpp @@ -3,7 +3,7 @@ #include #include "tests/dot11.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/assoc_request_test.cpp b/tests/src/dot11/assoc_request_test.cpp index a2e3f3d..bfca902 100644 --- a/tests/src/dot11/assoc_request_test.cpp +++ b/tests/src/dot11/assoc_request_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/assoc_response_test.cpp b/tests/src/dot11/assoc_response_test.cpp index 765194e..28eaa82 100644 --- a/tests/src/dot11/assoc_response_test.cpp +++ b/tests/src/dot11/assoc_response_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/authentication_test.cpp b/tests/src/dot11/authentication_test.cpp index 7fe5fdf..718e140 100644 --- a/tests/src/dot11/authentication_test.cpp +++ b/tests/src/dot11/authentication_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/beacon_test.cpp b/tests/src/dot11/beacon_test.cpp index fc9ee2b..76fc7d2 100644 --- a/tests/src/dot11/beacon_test.cpp +++ b/tests/src/dot11/beacon_test.cpp @@ -5,7 +5,7 @@ #include #include "rsn_information.h" #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/block_ack_request_test.cpp b/tests/src/dot11/block_ack_request_test.cpp index 6686d66..02a8470 100644 --- a/tests/src/dot11/block_ack_request_test.cpp +++ b/tests/src/dot11/block_ack_request_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/cf_end_ack_test.cpp b/tests/src/dot11/cf_end_ack_test.cpp index 4d4d721..d0a282c 100644 --- a/tests/src/dot11/cf_end_ack_test.cpp +++ b/tests/src/dot11/cf_end_ack_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_control.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/cf_end_test.cpp b/tests/src/dot11/cf_end_test.cpp index 15f102e..2172840 100644 --- a/tests/src/dot11/cf_end_test.cpp +++ b/tests/src/dot11/cf_end_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_control.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/data_test.cpp b/tests/src/dot11/data_test.cpp index 140062f..8866df9 100644 --- a/tests/src/dot11/data_test.cpp +++ b/tests/src/dot11/data_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_data.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/deauthentication_test.cpp b/tests/src/dot11/deauthentication_test.cpp index 9bfb377..4452899 100644 --- a/tests/src/dot11/deauthentication_test.cpp +++ b/tests/src/dot11/deauthentication_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/disassoc_test.cpp b/tests/src/dot11/disassoc_test.cpp index 619ccef..0867809 100644 --- a/tests/src/dot11/disassoc_test.cpp +++ b/tests/src/dot11/disassoc_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/probe_request_test.cpp b/tests/src/dot11/probe_request_test.cpp index 403bede..b620794 100644 --- a/tests/src/dot11/probe_request_test.cpp +++ b/tests/src/dot11/probe_request_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/probe_response_test.cpp b/tests/src/dot11/probe_response_test.cpp index c530992..2d8a705 100644 --- a/tests/src/dot11/probe_response_test.cpp +++ b/tests/src/dot11/probe_response_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/ps_poll_test.cpp b/tests/src/dot11/ps_poll_test.cpp index a7bb92c..eaff858 100644 --- a/tests/src/dot11/ps_poll_test.cpp +++ b/tests/src/dot11/ps_poll_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_control.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/reassoc_request_test.cpp b/tests/src/dot11/reassoc_request_test.cpp index 1f10ee8..1a9ea11 100644 --- a/tests/src/dot11/reassoc_request_test.cpp +++ b/tests/src/dot11/reassoc_request_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/reassoc_response_test.cpp b/tests/src/dot11/reassoc_response_test.cpp index c9a05c4..2c55896 100644 --- a/tests/src/dot11/reassoc_response_test.cpp +++ b/tests/src/dot11/reassoc_response_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_mgmt.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins; diff --git a/tests/src/dot11/rts_test.cpp b/tests/src/dot11/rts_test.cpp index b01e0bb..741a4a8 100644 --- a/tests/src/dot11/rts_test.cpp +++ b/tests/src/dot11/rts_test.cpp @@ -4,7 +4,7 @@ #include #include "tests/dot11_control.h" - +#include "detail/smart_ptr.h" using namespace std; using namespace Tins;