first commit
This commit is contained in:
26
third_party/socket.io-client-cpp/.github/workflows/ci.yml
vendored
Normal file
26
third_party/socket.io-client-cpp/.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.0.0
|
||||
|
||||
- name: Build project
|
||||
uses: nicledomaS/cmake_build_action@v1.3
|
||||
with:
|
||||
submodule_update: ON
|
||||
run_tests: ON
|
||||
unit_test_build: -DBUILD_UNIT_TESTS=ON
|
||||
cmake_args: -DCMAKE_CXX_FLAGS=-std=c++11
|
||||
12
third_party/socket.io-client-cpp/.gitignore
vendored
Normal file
12
third_party/socket.io-client-cpp/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
build/
|
||||
**/*.user
|
||||
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
libsioclient.a
|
||||
sio_test
|
||||
.DS_Store
|
||||
.cache/
|
||||
9
third_party/socket.io-client-cpp/.gitmodules
vendored
Normal file
9
third_party/socket.io-client-cpp/.gitmodules
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
[submodule "lib/websocketpp"]
|
||||
path = lib/websocketpp
|
||||
url = https://github.com/zaphoyd/websocketpp.git
|
||||
[submodule "lib/rapidjson"]
|
||||
path = lib/rapidjson
|
||||
url = https://github.com/miloyip/rapidjson.git
|
||||
[submodule "lib/asio"]
|
||||
path = lib/asio
|
||||
url = https://github.com/chriskohlhoff/asio.git
|
||||
209
third_party/socket.io-client-cpp/API.md
vendored
Normal file
209
third_party/socket.io-client-cpp/API.md
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
## API
|
||||
### *Overview*
|
||||
There're just 3 roles in this library - `socket`, `client` and `message`.
|
||||
|
||||
`client` is for physical connection while `socket` is for "namespace" (which is like a logical channel), which means one `socket` paired with one namespace, and one `client` paired with one physical connection.
|
||||
|
||||
Since a physical connection can have multiple namespaces (which is called multiplex), a `client` object may have multiple `socket` objects, each of which is bound to a distinct `namespace`.
|
||||
|
||||
Use `client` to setup the connection to the server, manange the connection status, also session id for the connection.
|
||||
|
||||
Use `socket` to send messages under namespace and receives messages in the namespace, also handle special types of message.
|
||||
|
||||
The `message` is just about the content you want to send, with text, binary or structured combinations.
|
||||
|
||||
### *Socket*
|
||||
#### Constructors
|
||||
Sockets are all managed by `client`, no public constructors.
|
||||
|
||||
You can get it's pointer by `client.socket(namespace)`.
|
||||
|
||||
#### Event Emitter
|
||||
`void emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack)`
|
||||
|
||||
Universal event emission interface, by applying implicit conversion magic, it is backward compatible with all previous `emit` interfaces.
|
||||
|
||||
#### Event Bindings
|
||||
`void on(std::string const& event_name,event_listener const& func)`
|
||||
|
||||
`void on(std::string const& event_name,event_listener_aux const& func)`
|
||||
|
||||
Bind a callback to specified event name. Same as `socket.on()` function in JS, `event_listener` is for full content event object, `event_listener_aux` is for convenience.
|
||||
|
||||
`void off(std::string const& event_name)`
|
||||
|
||||
Unbind the event callback with specified name.
|
||||
|
||||
`void off_all()`
|
||||
|
||||
Clear all event bindings (not including the error listener).
|
||||
|
||||
`void on_error(error_listener const& l)`
|
||||
|
||||
Bind the error handler for socket.io error messages.
|
||||
|
||||
`void off_error()`
|
||||
|
||||
Unbind the error handler.
|
||||
|
||||
```C++
|
||||
//event object:
|
||||
class event
|
||||
{
|
||||
public:
|
||||
const std::string& get_nsp() const;
|
||||
|
||||
const std::string& get_name() const;
|
||||
|
||||
const message::ptr& get_message() const;
|
||||
|
||||
bool need_ack() const;
|
||||
|
||||
void put_ack_message(message::ptr const& ack_message);
|
||||
|
||||
message::ptr const& get_ack_message() const;
|
||||
...
|
||||
};
|
||||
//event listener declare:
|
||||
typedef std::function<void(const std::string& name,message::ptr const& message,bool need_ack, message::ptr& ack_message)> event_listener_aux;
|
||||
|
||||
typedef std::function<void(event& event)> event_listener;
|
||||
|
||||
typedef std::function<void(message::ptr const& message)> error_listener;
|
||||
|
||||
```
|
||||
|
||||
#### Connect and close socket
|
||||
`connect` will happen for existing `socket`s automatically when `client` have opened up the physical connection.
|
||||
|
||||
`socket` opened with connected `client` will connect to its namespace immediately.
|
||||
|
||||
`void close()`
|
||||
|
||||
Positively disconnect from namespace.
|
||||
|
||||
#### Get name of namespace
|
||||
`std::string const& get_namespace() const`
|
||||
|
||||
Get current namespace name which the client is inside.
|
||||
|
||||
### *Client*
|
||||
#### Constructors
|
||||
`client()` default constructor.
|
||||
|
||||
#### Connection Listeners
|
||||
`void set_open_listener(con_listener const& l)`
|
||||
|
||||
Call when websocket is open, especially means good connectivity.
|
||||
|
||||
`void set_fail_listener(con_listener const& l)`
|
||||
|
||||
Call when failed in connecting.
|
||||
|
||||
`void set_close_listener(close_listener const& l)`
|
||||
|
||||
Call when closed or drop. See `client::close_reason`
|
||||
|
||||
```C++
|
||||
//connection listener declare:
|
||||
enum close_reason
|
||||
{
|
||||
close_reason_normal,
|
||||
close_reason_drop
|
||||
};
|
||||
typedef std::function<void(void)> con_listener;
|
||||
|
||||
typedef std::function<void(close_reason const& reason)> close_listener;
|
||||
```
|
||||
#### Socket listeners
|
||||
`void set_socket_open_listener(socket_listener const& l)`
|
||||
|
||||
Set listener for socket connect event, called when any sockets being ready to send message.
|
||||
|
||||
`void set_socket_close_listener(socket_listener const& l)`
|
||||
|
||||
Set listener for socket close event, called when any sockets being closed, afterward, corresponding `socket` object will be cleared from client.
|
||||
|
||||
```C++
|
||||
//socket_listener declare:
|
||||
typedef std::function<void(std::string const& nsp)> socket_listener;
|
||||
```
|
||||
|
||||
#### Connect and Close
|
||||
`void connect(const std::string& uri)`
|
||||
|
||||
Connect to socket.io server, e.g., `client.connect("ws://localhost:3000");`
|
||||
|
||||
`void close()`
|
||||
|
||||
Close the client, return immediately.
|
||||
|
||||
`void sync_close()`
|
||||
|
||||
Close the client, don't return until it is really closed.
|
||||
|
||||
`bool opened() const`
|
||||
|
||||
Check if client's connection is opened.
|
||||
|
||||
#### Transparent reconnecting
|
||||
`void set_reconnect_attempts(int attempts)`
|
||||
|
||||
Set max reconnect attempts, set to 0 to disable transparent reconnecting.
|
||||
|
||||
`void set_reconnect_delay(unsigned millis)`
|
||||
|
||||
Set minimum delay for reconnecting, this is the delay for 1st reconnecting attempt,
|
||||
then the delay duration grows by attempts made.
|
||||
|
||||
`void set_reconnect_delay_max(unsigned millis)`
|
||||
|
||||
Set maximum delay for reconnecting.
|
||||
|
||||
`void set_reconnecting_listener(con_listener const& l)`
|
||||
|
||||
Set listener for reconnecting is in process.
|
||||
|
||||
`void set_reconnect_listener(reconnect_listener const& l)`
|
||||
|
||||
Set listener for reconnecting event, called once a delayed connecting is scheduled.
|
||||
|
||||
#### Logs
|
||||
`void set_logs_default()`
|
||||
|
||||
Configure logs to the default level (connect, disconnect, app)
|
||||
|
||||
`void set_logs_quiet()`
|
||||
|
||||
Configure logs to the quiet level
|
||||
|
||||
`void set_logs_verbose()`
|
||||
|
||||
Configure logs to the verbose level
|
||||
|
||||
#### Namespace
|
||||
`socket::ptr socket(std::string const& nsp)`
|
||||
|
||||
Get a pointer to a socket which is paired with the specified namespace.
|
||||
|
||||
#### Session ID
|
||||
`std::string const& get_sessionid() const`
|
||||
|
||||
Get socket.io session id.
|
||||
|
||||
### *Message*
|
||||
`message` Base class of all message object.
|
||||
|
||||
`int_message` message contains a 64-bit integer.
|
||||
|
||||
`double_message` message contains a double.
|
||||
|
||||
`string_message` message contains a string.
|
||||
|
||||
`array_message` message contains a `vector<message::ptr>`.
|
||||
|
||||
`object_message` message contains a `map<string,message::ptr>`.
|
||||
|
||||
`message::ptr` pointer to `message` object, it will be one of its derived classes, judge by `message.get_flag()`.
|
||||
|
||||
All designated constructor of `message` objects is hidden, you need to create message and get the `message::ptr` by `[derived]_message:create()`.
|
||||
40
third_party/socket.io-client-cpp/CHANGELOG.md
vendored
Normal file
40
third_party/socket.io-client-cpp/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# [2.1.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...2.1.0) (2021-10-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix ASIO_STANDALONE release build trying to use boost::random ([#301](https://github.com/socketio/socket.io-client-cpp/issues/301)) ([168ce9d](https://github.com/socketio/socket.io-client-cpp/commit/168ce9d10b4ac667c43fe16b4cf530f6a3749235))
|
||||
* fix LOG call syntax ([#301](https://github.com/socketio/socket.io-client-cpp/issues/301)) ([c09221f](https://github.com/socketio/socket.io-client-cpp/commit/c09221f357effe1a5a0fc0e7d7902eba1ab0484d))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support TLSv1.2 and newer ([#321](https://github.com/socketio/socket.io-client-cpp/issues/321)) ([7c60ba9](https://github.com/socketio/socket.io-client-cpp/commit/7c60ba9d1e5e58de57f127025bcf69f4baecd2b4))
|
||||
|
||||
|
||||
|
||||
# [3.1.0](https://github.com/socketio/socket.io-client-cpp/compare/3.0.0...3.1.0) (2021-10-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* lower the minimum CMake supported version ([b196fa7](https://github.com/socketio/socket.io-client-cpp/commit/b196fa7537cd3f7bed626ead873a7b71d1293c0d))
|
||||
* handle closing sockets upon on_fail events ([d1c73b7](https://github.com/socketio/socket.io-client-cpp/commit/d1c73b73a8f536da3d353eac2a560af9791b13e3))
|
||||
* resolve client_impl::ping LOG call syntax in debug builds ([e7de4eb](https://github.com/socketio/socket.io-client-cpp/commit/e7de4ebf64f4f49e18594a2c093c07beb963579a))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow resource path to be set in connection URI ([#134](https://github.com/socketio/socket.io-client-cpp/issues/134)) ([36a8cd4](https://github.com/socketio/socket.io-client-cpp/commit/36a8cd45272aa51f0f6ef27aa4744dbc6e8421f7))
|
||||
* add support for logging configuration ([1b42ce7](https://github.com/socketio/socket.io-client-cpp/commit/1b42ce738f4c3e260f79bcb143bfe6efcdce5709))
|
||||
* support TLSv1.2 and newer ([#321](https://github.com/socketio/socket.io-client-cpp/issues/321)) ([82d39a9](https://github.com/socketio/socket.io-client-cpp/commit/82d39a90ef118500a0329d214eec331db983bd74))
|
||||
|
||||
|
||||
|
||||
# [3.0.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...3.0.0) (2021-01-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support for Socket.IO v3 ([ec4d540](https://github.com/socketio/socket.io-client-cpp/commit/ec4d540ad54593604ac2091e67ffc2a6d9a00db6))
|
||||
|
||||
177
third_party/socket.io-client-cpp/CMakeLists.txt
vendored
Normal file
177
third_party/socket.io-client-cpp/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
cmake_minimum_required(VERSION 3.12...3.27)
|
||||
|
||||
PROJECT(sioclient
|
||||
VERSION 3.1.0
|
||||
)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
|
||||
option(BUILD_UNIT_TESTS "Builds unit tests target" OFF)
|
||||
option(USE_SUBMODULES "Use source in local submodules instead of system libraries" ON)
|
||||
option(DISABLE_LOGGING "Do not print logging messages" OFF)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(DEFAULT_BUILD_TYPE "Release")
|
||||
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
|
||||
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# Only do these if this is the main project, and not if it is included through add_subdirectory
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
# Testing only available if this is the main app
|
||||
# Note this needs to be done in the main CMakeLists
|
||||
# since it calls enable_testing, which must be in the
|
||||
# main CMakeLists.
|
||||
include(CTest)
|
||||
endif()
|
||||
|
||||
add_definitions(
|
||||
# These will force ASIO to compile without Boost
|
||||
-DBOOST_DATE_TIME_NO_LIB
|
||||
-DBOOST_REGEX_NO_LIB
|
||||
-DASIO_STANDALONE
|
||||
|
||||
# These will force sioclient to compile with C++11
|
||||
-D_WEBSOCKETPP_CPP11_STL_
|
||||
-D_WEBSOCKETPP_CPP11_FUNCTIONAL_
|
||||
-D_WEBSOCKETPP_CPP11_TYPE_TRAITS_
|
||||
-D_WEBSOCKETPP_CPP11_CHRONO_
|
||||
)
|
||||
|
||||
if (DISABLE_LOGGING)
|
||||
add_definitions(-DSIO_DISABLE_LOGGING)
|
||||
endif()
|
||||
|
||||
set(ALL_SRC
|
||||
"src/sio_client.cpp"
|
||||
"src/sio_socket.cpp"
|
||||
"src/internal/sio_client_impl.cpp"
|
||||
"src/internal/sio_packet.cpp"
|
||||
)
|
||||
add_library(sioclient ${ALL_SRC})
|
||||
|
||||
if(USE_SUBMODULES)
|
||||
set(MODULE_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
|
||||
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
|
||||
)
|
||||
else()
|
||||
find_package(websocketpp CONFIG REQUIRED)
|
||||
find_package(asio CONFIG REQUIRED)
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
target_link_libraries(sioclient PRIVATE websocketpp::websocketpp asio::asio rapidjson)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
target_include_directories(sioclient
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
PRIVATE
|
||||
${MODULE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_compile_features(sioclient PUBLIC cxx_std_11)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(sioclient PUBLIC Threads::Threads)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(sioclient
|
||||
PROPERTIES
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND TARGET_LIBRARIES sioclient)
|
||||
|
||||
find_package(OpenSSL)
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
add_library(sioclient_tls ${ALL_SRC})
|
||||
target_include_directories(sioclient_tls PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
PRIVATE
|
||||
${MODULE_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_compile_features(sioclient_tls PUBLIC cxx_std_11)
|
||||
target_link_libraries(sioclient_tls PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
if (NOT USE_SUBMODULES)
|
||||
target_link_libraries(sioclient_tls PRIVATE websocketpp::websocketpp asio asio::asio rapidjson)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(sioclient_tls PRIVATE -DSIO_TLS)
|
||||
target_link_libraries(sioclient_tls PUBLIC Threads::Threads)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(sioclient_tls
|
||||
PROPERTIES
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND TARGET_LIBRARIES sioclient_tls)
|
||||
endif()
|
||||
|
||||
export(PACKAGE sioclient)
|
||||
|
||||
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h)
|
||||
install(FILES ${ALL_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(TARGETS ${TARGET_LIBRARIES} EXPORT sioclientTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# === generate a CMake Config File ===
|
||||
include(CMakePackageConfigHelpers)
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/sioclient)
|
||||
string(REGEX REPLACE "([^;]+)" "find_dependency(\\1)" _find_dependency_calls "${_package_dependencies}")
|
||||
string(REPLACE ";" "\n" _find_dependency_calls "${_find_dependency_calls}")
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientConfigVersion.cmake"
|
||||
VERSION ${sioclient_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
export(EXPORT sioclientTargets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientTargets.cmake"
|
||||
NAMESPACE sioclient::
|
||||
)
|
||||
|
||||
configure_package_config_file(sioclientConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientConfig.cmake"
|
||||
INSTALL_DESTINATION "${ConfigPackageLocation}"
|
||||
)
|
||||
|
||||
install(EXPORT sioclientTargets
|
||||
NAMESPACE
|
||||
sioclient::
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientConfigVersion.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sioclient/sioclientTargets.cmake"
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) OR BUILD_UNIT_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
39
third_party/socket.io-client-cpp/INSTALL.md
vendored
Normal file
39
third_party/socket.io-client-cpp/INSTALL.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
## Install
|
||||
|
||||
### With CMake
|
||||
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
|
||||
2. Run `cmake ./`
|
||||
3. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
|
||||
4. Outputs is under `./build`, link with the all static libs under `./build/lib` and include headers under `./build/include` in your client code where you want to use it.
|
||||
|
||||
### Without CMake
|
||||
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
|
||||
2. Add `./lib/asio/asio/include`, `./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
|
||||
3. Include all files under `./src` in your project, add `sio_client.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp`, `internal/sio_packet.cpp` to source list.
|
||||
4. Add `BOOST_DATE_TIME_NO_LIB`, `BOOST_REGEX_NO_LIB`, `ASIO_STANDALONE`, `_WEBSOCKETPP_CPP11_STL_` and `_WEBSOCKETPP_CPP11_FUNCTIONAL_` to the preprocessor definitions
|
||||
5. Include `sio_client.h` in your client code where you want to use it.
|
||||
|
||||
### With vcpkg
|
||||
|
||||
You can download and install the Socket.IO C++ client using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install socket-io-client
|
||||
```
|
||||
|
||||
The Socket.IO client port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
### With Conan
|
||||
|
||||
You can install pre-built binaries for Socket.IO C++ client or build it from source using [Conan](https://conan.io/). Use the following command:
|
||||
|
||||
```
|
||||
conan install --requires="sioclient/[*]" --build=missing
|
||||
```
|
||||
|
||||
The Socket.IO client Conan recipe is kept up to date by Conan maintainers and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the ConanCenterIndex repository.
|
||||
27
third_party/socket.io-client-cpp/INSTALL_IOS.md
vendored
Normal file
27
third_party/socket.io-client-cpp/INSTALL_IOS.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
## iOS
|
||||
|
||||
### Option 1: Create a static library
|
||||
|
||||
1. Create a static library
|
||||
1. Copy the header files into xcode
|
||||
|
||||
Use the static libraries generated by the example project [iOS example project](examples/iOS)
|
||||
|
||||
Create one for
|
||||
- release iphoneos
|
||||
- release simulator
|
||||
- debug iphoneos
|
||||
- debug simulator
|
||||
|
||||
Join the debug libraries and the release libraries with e.g.
|
||||
```
|
||||
libtool -static -o libUniversalRelease.a Release-iphoneos/libsioclient.a Release-iphonesimulator/libsioclient.a
|
||||
libtool -static -o libUniversalDebug.a Debug-iphoneos/libsioclient.a Debug-iphonesimulator/libsioclient.a
|
||||
```
|
||||
|
||||
|
||||
### Option 2: Manual integration
|
||||
|
||||
Use this [shell](https://gist.github.com/melode11/a90114a2abf009ca22ea) to download and build boost completely automattically. It installs boost to `<shell folder>/prefix`.
|
||||
|
||||
See the [iOS example project](examples/iOS) for how to integrate the rest.
|
||||
20
third_party/socket.io-client-cpp/LICENSE
vendored
Normal file
20
third_party/socket.io-client-cpp/LICENSE
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2015, Melo Yao
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to all conditions.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
131
third_party/socket.io-client-cpp/README.md
vendored
Normal file
131
third_party/socket.io-client-cpp/README.md
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
# Socket.IO C++ Client
|
||||
|
||||
[](https://github.com/socketio/socket.io-client-cpp/actions)
|
||||
|
||||
By virtue of being written in C++, this client works in several different platforms. The [examples](https://github.com/socketio/socket.io-client-cpp/tree/master/examples) folder contains an iPhone, QT and Console example chat client! It depends on [websocket++](https://github.com/zaphoyd/websocketpp) and is inspired by [socket.io-clientpp](https://github.com/ebshimizu/socket.io-clientpp).
|
||||
|
||||
[](https://github.com/socketio/socket.io-client-cpp/tree/master/examples)
|
||||
|
||||
## Compatibility table
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th rowspan="2">C++ Client version</th>
|
||||
<th colspan="2">Socket.IO server version</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">1.x / 2.x</td>
|
||||
<td align="center">3.x / 4.x</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.x (<code>2.x</code> branch)</td>
|
||||
<td align="center">YES</td>
|
||||
<td align="center">YES, with <code><a href="https://socket.io/docs/v4/server-initialization/#allowEIO3">allowEIO3: true</a></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.x (<code>master</code> branch)</td>
|
||||
<td align="center">NO</td>
|
||||
<td align="center">YES</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Features
|
||||
|
||||
- 100% written in modern C++11
|
||||
- Binary support
|
||||
- Automatic JSON encoding
|
||||
- Multiplex support
|
||||
- Similar API to the Socket.IO JS client
|
||||
- Cross platform
|
||||
|
||||
Note: Only the WebSocket transport is currently implemented (no fallback to HTTP long-polling)
|
||||
|
||||
## Installation alternatives
|
||||
|
||||
* [With CMAKE](./INSTALL.md#with-cmake)
|
||||
* [Without CMAKE](./INSTALL.md#without-cmake)
|
||||
* [With VCPKG](./INSTALL.md#with-vcpkg)
|
||||
* [With Conan](./INSTALL.md#with-conan)
|
||||
* [iOS and OS X](./INSTALL_IOS.md)
|
||||
* Option 1: Cocoapods
|
||||
* Option 2: Create a static library
|
||||
* Option 3: Manual integration
|
||||
|
||||
|
||||
## Quickstart
|
||||
|
||||
** [Full overview of API can be seen here](./API.md) **
|
||||
|
||||
|
||||
The APIs are similar to the JS client.
|
||||
|
||||
#### Connect to a server
|
||||
```C++
|
||||
sio::client h;
|
||||
h.connect("http://127.0.0.1:3000");
|
||||
```
|
||||
|
||||
#### Emit an event
|
||||
|
||||
```C++
|
||||
// emit event name only:
|
||||
h.socket()->emit("login");
|
||||
|
||||
// emit text
|
||||
h.socket()->emit("add user", username);
|
||||
|
||||
// emit binary
|
||||
char buf[100];
|
||||
h.socket()->emit("add user", std::make_shared<std::string>(buf,100));
|
||||
|
||||
// emit message object with lambda ack handler
|
||||
h.socket()->emit("add user", string_message::create(username), [&](message::list const& msg) {
|
||||
});
|
||||
|
||||
// emit multiple arguments
|
||||
message::list li("sports");
|
||||
li.push(string_message::create("economics"));
|
||||
socket->emit("categories", li);
|
||||
```
|
||||
Items in `message::list` will be expanded in server side event callback function as function arguments.
|
||||
|
||||
#### Bind an event
|
||||
|
||||
##### Bind with function pointer
|
||||
```C++
|
||||
void OnMessage(sio::event &)
|
||||
{
|
||||
|
||||
}
|
||||
h.socket()->on("new message", &OnMessage);
|
||||
```
|
||||
|
||||
##### Bind with lambda
|
||||
```C++
|
||||
h.socket()->on("login", [&](sio::event& ev)
|
||||
{
|
||||
//handle login message
|
||||
//post to UI thread if any UI updating.
|
||||
});
|
||||
```
|
||||
|
||||
##### Bind with member function
|
||||
```C++
|
||||
class MessageHandler
|
||||
{
|
||||
public:
|
||||
void OnMessage(sio::event &);
|
||||
};
|
||||
MessageHandler mh;
|
||||
h.socket()->on("new message",std::bind( &MessageHandler::OnMessage,&mh,std::placeholders::_1));
|
||||
```
|
||||
|
||||
#### Using namespace
|
||||
```C++
|
||||
h.socket("/chat")->emit("add user", username);
|
||||
```
|
||||
** [Full overview of API can be seen here](./API.md) **
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
9
third_party/socket.io-client-cpp/examples/Console/CMakeLists.txt
vendored
Normal file
9
third_party/socket.io-client-cpp/examples/Console/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
find_package(Threads REQUIRED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)
|
||||
add_executable(sio_console_demo main.cpp)
|
||||
target_link_libraries(sio_console_demo sioclient)
|
||||
target_link_libraries(sio_console_demo Threads::Threads)
|
||||
target_compile_features(sio_console_demo PRIVATE cxx_std_11)
|
||||
message(STATUS ${Boost_INCLUDE_DIRS} )
|
||||
#target_include_directories(sio_console_demo PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ${Boost_INCLUDE_DIRS} )
|
||||
28
third_party/socket.io-client-cpp/examples/Console/README.md
vendored
Normal file
28
third_party/socket.io-client-cpp/examples/Console/README.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
#SioChatDemo setup
|
||||
This Demo is create with `Visual Studio 2012 Update 4` , It is a simple console app, connect to official [socket.io chatroom example](https://github.com/Automattic/socket.io/tree/master/examples/chat) as a chat client.
|
||||
|
||||
You can choose a nickname, send/receive message in the chat room, and see join/left information as well.
|
||||
##boost for windows
|
||||
Please download boost package from [boost.org](www.boost.org), and unpack to `boost` folder.
|
||||
Please make sure there's no redundent folder levels under it (by check if `bootstrap.bat` is directly under `boost` folder).
|
||||
|
||||
cd to `boost` folder, and run `bootstrap.bat`
|
||||
|
||||
Then run:
|
||||
|
||||
```shell
|
||||
bjam stage --toolset=msvc --with-system --with-date_time --with-random --stagedir="release" link=static runtime-link=shared threading=multi release
|
||||
bjam stage --toolset=msvc --with-system --with-date_time --with-random --stagedir="debug" link=static runtime-link=shared threading=multi debug
|
||||
```
|
||||
After done this, use Visual studio command line tool, go to `boost\release` folder, run
|
||||
|
||||
```shell
|
||||
lib.exe /OUT:boost.lib *
|
||||
```
|
||||
|
||||
And do then same thing in `boost\debug` folder.
|
||||
|
||||
then you can open the VS project `SioChatDemo.sln` to build and run.
|
||||
|
||||
##Visual studio version
|
||||
Microsoft start to support c++11 after `Visual studio 2012 Update 4`. Please make sure you're using up-to-date version.
|
||||
20
third_party/socket.io-client-cpp/examples/Console/SioChatDemo/SioChatDemo.sln
vendored
Normal file
20
third_party/socket.io-client-cpp/examples/Console/SioChatDemo/SioChatDemo.sln
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SioChatDemo", "SioChatDemo.vcxproj", "{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
101
third_party/socket.io-client-cpp/examples/Console/SioChatDemo/SioChatDemo.vcxproj
vendored
Normal file
101
third_party/socket.io-client-cpp/examples/Console/SioChatDemo/SioChatDemo.vcxproj
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>SioChatDemo</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>D:\BoostRoot\include\boost-1_55;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\boost_1_55_0\boost_build\debug\lib;$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(SolutionDir)boost;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>boost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>boost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\internal\sio_client_impl.h" />
|
||||
<ClInclude Include="..\..\..\src\internal\sio_packet.h" />
|
||||
<ClInclude Include="..\..\..\src\sio_client.h" />
|
||||
<ClInclude Include="..\..\..\src\sio_message.h" />
|
||||
<ClInclude Include="..\..\..\src\sio_socket.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\src\internal\sio_client_impl.cpp" />
|
||||
<ClCompile Include="..\..\..\src\internal\sio_packet.cpp" />
|
||||
<ClCompile Include="..\..\..\src\sio_client.cpp" />
|
||||
<ClCompile Include="..\..\..\src\sio_socket.cpp" />
|
||||
<ClCompile Include="..\main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
188
third_party/socket.io-client-cpp/examples/Console/main.cpp
vendored
Normal file
188
third_party/socket.io-client-cpp/examples/Console/main.cpp
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// sio_test_sample.cpp
|
||||
//
|
||||
// Created by Melo Yao on 3/24/15.
|
||||
//
|
||||
|
||||
#include "../../src/sio_client.h"
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <string>
|
||||
#ifdef WIN32
|
||||
#define HIGHLIGHT(__O__) std::cout<<__O__<<std::endl
|
||||
#define EM(__O__) std::cout<<__O__<<std::endl
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#define MAIN_FUNC int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
#define HIGHLIGHT(__O__) std::cout<<"\e[1;31m"<<__O__<<"\e[0m"<<std::endl
|
||||
#define EM(__O__) std::cout<<"\e[1;30;1m"<<__O__<<"\e[0m"<<std::endl
|
||||
|
||||
#define MAIN_FUNC int main(int argc ,const char* args[])
|
||||
#endif
|
||||
|
||||
using namespace sio;
|
||||
using namespace std;
|
||||
std::mutex _lock;
|
||||
|
||||
std::condition_variable_any _cond;
|
||||
bool connect_finish = false;
|
||||
|
||||
class connection_listener
|
||||
{
|
||||
sio::client &handler;
|
||||
|
||||
public:
|
||||
|
||||
connection_listener(sio::client& h):
|
||||
handler(h)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void on_connected()
|
||||
{
|
||||
_lock.lock();
|
||||
_cond.notify_all();
|
||||
connect_finish = true;
|
||||
_lock.unlock();
|
||||
}
|
||||
void on_close(client::close_reason const& reason)
|
||||
{
|
||||
std::cout<<"sio closed "<<std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void on_fail()
|
||||
{
|
||||
std::cout<<"sio failed "<<std::endl;
|
||||
exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
int participants = -1;
|
||||
|
||||
socket::ptr current_socket;
|
||||
|
||||
void bind_events()
|
||||
{
|
||||
current_socket->on("new message", sio::socket::event_listener_aux([&](string const& name, message::ptr const& data, bool isAck,message::list &ack_resp)
|
||||
{
|
||||
_lock.lock();
|
||||
string user = data->get_map()["username"]->get_string();
|
||||
string message = data->get_map()["message"]->get_string();
|
||||
EM(user<<":"<<message);
|
||||
_lock.unlock();
|
||||
}));
|
||||
|
||||
current_socket->on("user joined",sio::socket::event_listener_aux([&](string const& name, message::ptr const& data, bool isAck,message::list &ack_resp)
|
||||
{
|
||||
_lock.lock();
|
||||
string user = data->get_map()["username"]->get_string();
|
||||
participants = data->get_map()["numUsers"]->get_int();
|
||||
bool plural = participants !=1;
|
||||
|
||||
// abc "
|
||||
HIGHLIGHT(user<<" joined"<<"\nthere"<<(plural?" are ":"'s ")<< participants<<(plural?" participants":" participant"));
|
||||
_lock.unlock();
|
||||
}));
|
||||
current_socket->on("user left", sio::socket::event_listener_aux([&](string const& name, message::ptr const& data, bool isAck,message::list &ack_resp)
|
||||
{
|
||||
_lock.lock();
|
||||
string user = data->get_map()["username"]->get_string();
|
||||
participants = data->get_map()["numUsers"]->get_int();
|
||||
bool plural = participants !=1;
|
||||
HIGHLIGHT(user<<" left"<<"\nthere"<<(plural?" are ":"'s ")<< participants<<(plural?" participants":" participant"));
|
||||
_lock.unlock();
|
||||
}));
|
||||
}
|
||||
|
||||
MAIN_FUNC
|
||||
{
|
||||
|
||||
sio::client h;
|
||||
connection_listener l(h);
|
||||
|
||||
h.set_open_listener(std::bind(&connection_listener::on_connected, &l));
|
||||
h.set_close_listener(std::bind(&connection_listener::on_close, &l,std::placeholders::_1));
|
||||
h.set_fail_listener(std::bind(&connection_listener::on_fail, &l));
|
||||
h.connect("http://127.0.0.1:3000");
|
||||
_lock.lock();
|
||||
if(!connect_finish)
|
||||
{
|
||||
_cond.wait(_lock);
|
||||
}
|
||||
_lock.unlock();
|
||||
current_socket = h.socket();
|
||||
Login:
|
||||
string nickname;
|
||||
while (nickname.length() == 0) {
|
||||
HIGHLIGHT("Type your nickname:");
|
||||
|
||||
getline(cin, nickname);
|
||||
}
|
||||
current_socket->on("login", sio::socket::event_listener_aux([&](string const& name, message::ptr const& data, bool isAck,message::list &ack_resp){
|
||||
_lock.lock();
|
||||
participants = data->get_map()["numUsers"]->get_int();
|
||||
bool plural = participants !=1;
|
||||
HIGHLIGHT("Welcome to Socket.IO Chat-\nthere"<<(plural?" are ":"'s ")<< participants<<(plural?" participants":" participant"));
|
||||
_cond.notify_all();
|
||||
_lock.unlock();
|
||||
current_socket->off("login");
|
||||
}));
|
||||
current_socket->emit("add user", nickname);
|
||||
_lock.lock();
|
||||
if (participants<0) {
|
||||
_cond.wait(_lock);
|
||||
}
|
||||
_lock.unlock();
|
||||
bind_events();
|
||||
|
||||
HIGHLIGHT("Start to chat,commands:\n'$exit' : exit chat\n'$nsp <namespace>' : change namespace");
|
||||
for (std::string line; std::getline(std::cin, line);) {
|
||||
if(line.length()>0)
|
||||
{
|
||||
if(line == "$exit")
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(line.length() > 5&&line.substr(0,5) == "$nsp ")
|
||||
{
|
||||
string new_nsp = line.substr(5);
|
||||
if(new_nsp == current_socket->get_namespace())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
current_socket->off_all();
|
||||
current_socket->off_error();
|
||||
//per socket.io, default nsp should never been closed.
|
||||
if(current_socket->get_namespace() != "/")
|
||||
{
|
||||
current_socket->close();
|
||||
}
|
||||
current_socket = h.socket(new_nsp);
|
||||
bind_events();
|
||||
//if change to default nsp, we do not need to login again (since it is not closed).
|
||||
if(current_socket->get_namespace() == "/")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
goto Login;
|
||||
}
|
||||
current_socket->emit("new message", line);
|
||||
_lock.lock();
|
||||
EM("\t\t\t"<<line<<":"<<"You");
|
||||
_lock.unlock();
|
||||
}
|
||||
}
|
||||
HIGHLIGHT("Closing...");
|
||||
h.sync_close();
|
||||
h.clear_con_listeners();
|
||||
return 0;
|
||||
}
|
||||
|
||||
1
third_party/socket.io-client-cpp/examples/QT/.gitignore
vendored
Normal file
1
third_party/socket.io-client-cpp/examples/QT/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build-*
|
||||
290
third_party/socket.io-client-cpp/examples/QT/README.md
vendored
Normal file
290
third_party/socket.io-client-cpp/examples/QT/README.md
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||

|
||||
|
||||
In this tutorial we’ll learn how to create a QT chat application that communicates with a [Socket.IO Node.JS chat server](https://github.com/Automattic/socket.io/tree/master/examples/chat).
|
||||
|
||||
### Introduction
|
||||
To follow along, start by cloning the repository: [socket.io-client-cpp](https://github.com/socketio/socket.io-client-cpp).
|
||||
Using:
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git
|
||||
```
|
||||
|
||||
The app has the following features:
|
||||
|
||||
* Sending a message to all users joining to the room.
|
||||
|
||||
* Notifies when each user joins or leaves.
|
||||
|
||||
* Notifies when an user start typing a message.
|
||||
|
||||
###Install QT community
|
||||
Visit [QT community download link](http://www.qt.io/download-open-source/#section-2) to get the install package.
|
||||
Just install it with default installation option.
|
||||
|
||||
###Create a QT GUI application.
|
||||
Launch QT Creator.
|
||||
In welcome page, select `New Project`, create a `QT Widget Application`, named it `SioChatDemo`
|
||||
The project structure is like:
|
||||
|
||||
```
|
||||
SioChatDemo
|
||||
|__ SioChatDemo.pro
|
||||
|__Headers
|
||||
| |__mainwindow.h
|
||||
|__Sources
|
||||
| |__main.cpp
|
||||
| |__mainwindow.cpp
|
||||
|__Forms
|
||||
|__mainwindow.ui
|
||||
```
|
||||
|
||||
### Import SioClient and config compile options.
|
||||
Let's copy the SioClient into the QT project as a subfolder `sioclient`.
|
||||
|
||||
Edit `SioChatDemo.pro` to config paths and compile options, simply add:
|
||||
|
||||
```bash
|
||||
SOURCES += ./sioclient/src/sio_client.cpp \
|
||||
./sioclient/src/sio_packet.cpp
|
||||
|
||||
HEADERS += ./sioclient/src/sio_client.h \
|
||||
./sioclient/src/sio_message.h
|
||||
|
||||
INCLUDEPATH += $$PWD/sioclient/lib/rapidjson/include
|
||||
INCLUDEPATH += $$PWD/sioclient/lib/websocketpp
|
||||
```
|
||||
|
||||
Also add two additional compile option
|
||||
|
||||
```bash
|
||||
CONFIG+=no_keywords
|
||||
CONFIG+=c++11
|
||||
```
|
||||
|
||||
`no_keywords` is for preventing qmake treat some function's name `emit` as the keyword of signal-slot mechanism.
|
||||
`c++11` ask for C++11 support.
|
||||
|
||||
### Make up mainwindow ui.
|
||||
Make up a simple ui by drag and drop widget from `Widget box` in left side.
|
||||
|
||||
We finally end up with this:
|
||||
|
||||

|
||||
|
||||
It contains:
|
||||
|
||||
* a `QLineEdit` at the top for nickname inputing, named `nickNameEdit`
|
||||
|
||||
* a `QPushButton` at the topright for login, named `loginBtn`
|
||||
|
||||
* a `QListWidget` at the center for showing messages, named `listView`
|
||||
|
||||
* a `QLineEdit` at the bottom for typing message, named `messageEdit`
|
||||
|
||||
* a `QPushButton` at the bottomright for sending message, named `sendBtn`
|
||||
|
||||
### Add Slots in mainwindow
|
||||
Slots need to be added in `mainwindow` class to handle UI events.They are
|
||||
|
||||
* click login button
|
||||
|
||||
* click send message button
|
||||
|
||||
* text change in messageEdit(for typing status)
|
||||
|
||||
* message editing is returned (for sending message by return)
|
||||
|
||||
Insert following code into `MainWindow` class in `mainwindow.h`
|
||||
|
||||
```C++
|
||||
public Q_SLOTS:
|
||||
void SendBtnClicked();
|
||||
void TypingChanged();
|
||||
void LoginClicked();
|
||||
void OnMessageReturn();
|
||||
```
|
||||
|
||||
### Connect UI event signal and slots together
|
||||
Open `mainwindow.ui` in Design mode. switch to `signals/slots` mode by check `Menu->Edit->Edit Signals/Slots`
|
||||
|
||||
By press left mouse on widget and drag on to the window (cursor will become a sign of electrical ground), to open the connection editor.
|
||||
|
||||
In the connection editor, edit the slots of MainWindow at the right side, add Those slots function name added in `mainwindow.h` before.
|
||||
|
||||
Then we'll be able to connect the event signal from widget with our own slots.
|
||||
|
||||
We finally end up with this:
|
||||
|
||||

|
||||
|
||||
### Adding UI refresh Signals/Slots
|
||||
`sio::client`'s callbacks are not in UI thread. However, UI is required to be updated by those callbacks, so we need some `Signal` for non-UI thread to "request" `Slots` functions been called in UI thread. Say if we want to signal `QListWidgetItem` being added, add:
|
||||
|
||||
```C++
|
||||
//In mainwindow.h
|
||||
Q_SIGNALS:
|
||||
void RequestAddListItem(QListWidgetItem *item);
|
||||
private Q_SLOTS:
|
||||
void AddListItem(QListWidgetItem *item);
|
||||
```
|
||||
|
||||
```C++
|
||||
//In mainwindow.cpp
|
||||
void MainWindow::AddListItem(QListWidgetItem* item)
|
||||
{
|
||||
this->findChild<QListWidget*>("listView")->addItem(item);
|
||||
}
|
||||
```
|
||||
|
||||
Then connect them in `MainWindow` constructor.
|
||||
|
||||
```C++
|
||||
connect(this,SIGNAL(RequestAddListItem(QListWidgetItem*)),this,SLOT(AddListItem(QListWidgetItem*)));
|
||||
```
|
||||
|
||||
### Init sio::client in MainWindow
|
||||
For single window applications, simply let `MainWindow` class holding the `sio::client` object:
|
||||
|
||||
declare a `unique_ptr` member of `sio::client` and Several event handling functions in `mainwindow.h`
|
||||
|
||||
```C++
|
||||
private:
|
||||
void OnNewMessage(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnUserJoined(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnUserLeft(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnTyping(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnStopTyping(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnLogin(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp);
|
||||
void OnConnected();
|
||||
void OnClosed(client::close_reason const& reason);
|
||||
void OnFailed();
|
||||
|
||||
std::unique_ptr<client> _io;
|
||||
```
|
||||
|
||||
Init `sio::client` and setup event bindings for default `socket` in `MainWindow` constructor.
|
||||
|
||||
And we also need to handle the connectivity events, handle the connect and disconnect events.
|
||||
|
||||
Now the `MainWindow` constructor:
|
||||
|
||||
```C++
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
_io(new client())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
using std::placeholders::_1;
|
||||
using std::placeholders::_2;
|
||||
using std::placeholders::_3;
|
||||
using std::placeholders::_4;
|
||||
socket::ptr sock = _io->socket();
|
||||
sock->on("new message",std::bind(&MainWindow::OnNewMessage,this,_1,_2,_3,_4));
|
||||
sock->on("user joined",std::bind(&MainWindow::OnUserJoined,this,_1,_2,_3,_4));
|
||||
sock->on("user left",std::bind(&MainWindow::OnUserLeft,this,_1,_2,_3,_4));
|
||||
sock->on("typing",std::bind(&MainWindow::OnTyping,this,_1,_2,_3,_4));
|
||||
sock->on("stop typing",std::bind(&MainWindow::OnStopTyping,this,_1,_2,_3,_4));
|
||||
sock->on("login",std::bind(&MainWindow::OnLogin,this,_1,_2,_3,_4));
|
||||
//default socket opened, also we have "set_open_listener" for monitoring physical connection opened.
|
||||
_io->set_socket_open_listener(std::bind(&MainWindow::OnConnected,this,std::placeholders::_1));
|
||||
//physical connection closed or drop.
|
||||
_io->set_close_listener(std::bind(&MainWindow::OnClosed,this,_1));
|
||||
//physical connection fail to establish.
|
||||
_io->set_fail_listener(std::bind(&MainWindow::OnFailed,this));
|
||||
connect(this,SIGNAL(RequestAddListItem(QListWidgetItem*)),this,SLOT(AddListItem(QListWidgetItem*)));
|
||||
}
|
||||
```
|
||||
|
||||
### Managing connection state
|
||||
We have several connection listeners for connection events.
|
||||
|
||||
First we want to send login message once we're connected, get the default `socket` from `client` to do that.
|
||||
|
||||
```C++
|
||||
void MainWindow::OnConnected()
|
||||
{
|
||||
QByteArray bytes = m_name.toUtf8();
|
||||
std::string nickName(bytes.data(),bytes.length());
|
||||
_io->socket()->emit("add user", nickName);
|
||||
}
|
||||
```
|
||||
|
||||
Then if connection is closed or failed, we need to restore to the UI before connect.
|
||||
|
||||
```C++
|
||||
void MainWindow::OnClosed(client::close_reason const& reason)
|
||||
{
|
||||
//restore UI to pre-login state
|
||||
}
|
||||
|
||||
void MainWindow::OnFailed()
|
||||
{
|
||||
//restore UI to pre-login state
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
If `MainWindow` is exit, we need to clear event bindings and listeners.
|
||||
|
||||
the `sio::client` object will be destruct by `unique_ptr`
|
||||
|
||||
```C++
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
_io->socket()->off_all();
|
||||
_io->socket()->off_error();
|
||||
delete ui;
|
||||
}
|
||||
```
|
||||
|
||||
### Handle socket.io events
|
||||
We'll need to handle socket.io events in our functions bind to socket.io events.
|
||||
For example, we need to show received messages to the `listView`
|
||||
|
||||
```C++
|
||||
void MainWindow::OnNewMessage(std::string const& name,message::ptr const& data,bool hasAck,message::ptr &ack_resp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
std::string msg = data->get_map()["message"]->get_string();
|
||||
std::string name = data->get_map()["username"]->get_string();
|
||||
QString label = QString::fromUtf8(name.data(),name.length());
|
||||
label.append(':');
|
||||
label.append(QString::fromUtf8(msg.data(),msg.length()));
|
||||
QListWidgetItem *item= new QListWidgetItem(label);
|
||||
//emit RequestAddListItem signal
|
||||
//so that 'AddListItem' will be executed in UI thread.
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Sending chat message
|
||||
When `sendBtn` is clicked, we need to send the text in `messageEdit` to chatroom.
|
||||
Add code to `SendBtnClicked()`:
|
||||
|
||||
```C++
|
||||
void MainWindow::SendBtnClicked()
|
||||
{
|
||||
QLineEdit* messageEdit = this->findChild<QLineEdit*>("messageEdit");
|
||||
QString text = messageEdit->text();
|
||||
if(text.length()>0)
|
||||
{
|
||||
QByteArray bytes = text.toUtf8();
|
||||
std::string msg(bytes.data(),bytes.length());
|
||||
_io->socket()->emit("new message",msg);//emit new message
|
||||
text.append(":You");
|
||||
QListWidgetItem *item = new QListWidgetItem(text);
|
||||
item->setTextAlignment(Qt::AlignRight);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
messageEdit->clear();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Further reading
|
||||
You can run [Demo project](https://github.com/socketio/socket.io-client-cpp/tree/master/examples/QT/SioChatDemo) to have a closer look.
|
||||
Before running, please follow the [instructions](../../README.md#with_cmake) to make the sioclient library.
|
||||
|
||||
1
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/.gitignore
vendored
Normal file
1
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
SioChatDemo.pro.user
|
||||
44
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/SioChatDemo.pro
vendored
Normal file
44
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/SioChatDemo.pro
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-03-30T19:25:23
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = SioChatDemo
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG+=no_keywords
|
||||
CONFIG+=c++11
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
nicknamedialog.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
nicknamedialog.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
nicknamedialog.ui
|
||||
|
||||
CONFIG(debug, debug|release):DEFINES +=DEBUG=1
|
||||
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../build/include
|
||||
DEPENDPATH += $$PWD/../../../build/lib
|
||||
|
||||
CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/Release/ -lsioclient
|
||||
else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/Debug/ -lsioclient
|
||||
|
||||
|
||||
CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/Release/ -lboost_random
|
||||
else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/Debug/ -lboost_random
|
||||
|
||||
CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/Release/ -lboost_system
|
||||
else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/Debug/ -lboost_system
|
||||
|
||||
CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build/lib/Release/ -lboost_date_time
|
||||
else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build/lib/Debug/ -lboost_date_time
|
||||
4
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/boost/.gitignore
vendored
Normal file
4
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/boost/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
osx/*
|
||||
src/*
|
||||
src
|
||||
osx
|
||||
378
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/boost/boost.sh
vendored
Normal file
378
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/boost/boost.sh
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
#===============================================================================
|
||||
# Filename: boost.sh
|
||||
# Author: Pete Goodliffe
|
||||
# Copyright: (c) Copyright 2009 Pete Goodliffe
|
||||
# Licence: Please feel free to use this, with attribution
|
||||
# Modified version
|
||||
#===============================================================================
|
||||
#
|
||||
# Builds a Boost framework for the iPhone.
|
||||
# Creates a set of universal libraries that can be used on an iPhone and in the
|
||||
# iPhone simulator. Then creates a pseudo-framework to make using boost in Xcode
|
||||
# less painful.
|
||||
#
|
||||
# To configure the script, define:
|
||||
# BOOST_LIBS: which libraries to build
|
||||
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 5.1)
|
||||
#
|
||||
# Then go get the source tar.bz of the boost you want to build, shove it in the
|
||||
# same directory as this script, and run "./boost.sh". Grab a cuppa. And voila.
|
||||
#===============================================================================
|
||||
|
||||
: ${BOOST_LIBS:="random regex graph random chrono thread signals filesystem system date_time"}
|
||||
: ${IPHONE_SDKVERSION:=`xcodebuild -showsdks | grep iphoneos | egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`}
|
||||
: ${OSX_SDKVERSION:=10.8}
|
||||
: ${XCODE_ROOT:=`xcode-select -print-path`}
|
||||
: ${EXTRA_CPPFLAGS:="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -std=c++11 -stdlib=libc++"}
|
||||
|
||||
# The EXTRA_CPPFLAGS definition works around a thread race issue in
|
||||
# shared_ptr. I encountered this historically and have not verified that
|
||||
# the fix is no longer required. Without using the posix thread primitives
|
||||
# an invalid compare-and-swap ARM instruction (non-thread-safe) was used for the
|
||||
# shared_ptr use count causing nasty and subtle bugs.
|
||||
#
|
||||
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
|
||||
|
||||
: ${TARBALLDIR:=`pwd`}
|
||||
: ${SRCDIR:=`pwd`/src}
|
||||
: ${IOSBUILDDIR:=`pwd`/ios/build}
|
||||
: ${OSXBUILDDIR:=`pwd`/osx/build}
|
||||
: ${PREFIXDIR:=`pwd`/ios/prefix}
|
||||
: ${IOSFRAMEWORKDIR:=`pwd`/ios/framework}
|
||||
: ${OSXFRAMEWORKDIR:=`pwd`/osx/framework}
|
||||
: ${COMPILER:="clang++"}
|
||||
|
||||
: ${BOOST_VERSION:=1.55.0}
|
||||
: ${BOOST_VERSION2:=1_55_0}
|
||||
|
||||
BOOST_TARBALL=$TARBALLDIR/boost_$BOOST_VERSION2.tar.bz2
|
||||
BOOST_SRC=$SRCDIR/boost_${BOOST_VERSION2}
|
||||
|
||||
#===============================================================================
|
||||
ARM_DEV_CMD="xcrun --sdk iphoneos"
|
||||
SIM_DEV_CMD="xcrun --sdk iphonesimulator"
|
||||
OSX_DEV_CMD="xcrun --sdk macosx"
|
||||
|
||||
ARM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_arm.a
|
||||
SIM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_x86.a
|
||||
|
||||
#===============================================================================
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Functions
|
||||
#===============================================================================
|
||||
|
||||
abort()
|
||||
{
|
||||
echo
|
||||
echo "Aborted: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
doneSection()
|
||||
{
|
||||
echo
|
||||
echo "================================================================="
|
||||
echo "Done"
|
||||
echo
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
cleanEverythingReadyToStart()
|
||||
{
|
||||
echo Cleaning everything before we start to build...
|
||||
|
||||
rm -rf iphone-build iphonesim-build osx-build
|
||||
rm -rf $IOSBUILDDIR
|
||||
rm -rf $OSXBUILDDIR
|
||||
rm -rf $PREFIXDIR
|
||||
rm -rf $IOSFRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
rm -rf $OSXFRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
downloadBoost()
|
||||
{
|
||||
if [ ! -s $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 ]; then
|
||||
echo "Downloading boost ${BOOST_VERSION}"
|
||||
curl -L -o $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION2}.tar.bz2/download
|
||||
fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
unpackBoost()
|
||||
{
|
||||
[ -f "$BOOST_TARBALL" ] || abort "Source tarball missing."
|
||||
|
||||
echo Unpacking boost into $SRCDIR...
|
||||
|
||||
[ -d $SRCDIR ] || mkdir -p $SRCDIR
|
||||
[ -d $BOOST_SRC ] || ( cd $SRCDIR; tar xfj $BOOST_TARBALL )
|
||||
[ -d $BOOST_SRC ] && echo " ...unpacked as $BOOST_SRC"
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
restoreBoost()
|
||||
{
|
||||
cp $BOOST_SRC/tools/build/v2/user-config.jam-bk $BOOST_SRC/tools/build/v2/user-config.jam
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
updateBoost()
|
||||
{
|
||||
echo Updating boost into $BOOST_SRC...
|
||||
|
||||
cp $BOOST_SRC/tools/build/v2/user-config.jam $BOOST_SRC/tools/build/v2/user-config.jam-bk
|
||||
|
||||
cat >> $BOOST_SRC/tools/build/v2/user-config.jam <<EOF
|
||||
using darwin : ${IPHONE_SDKVERSION}~iphone
|
||||
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch armv6 -arch armv7 -arch armv7s -arch arm64 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
|
||||
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
|
||||
: <architecture>arm <target-os>iphone
|
||||
;
|
||||
using darwin : ${IPHONE_SDKVERSION}~iphonesim
|
||||
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch i386 -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
|
||||
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
|
||||
: <architecture>x86 <target-os>iphone
|
||||
;
|
||||
EOF
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
inventMissingHeaders()
|
||||
{
|
||||
# These files are missing in the ARM iPhoneOS SDK, but they are in the simulator.
|
||||
# They are supported on the device, so we copy them from x86 SDK to a staging area
|
||||
# to use them on ARM, too.
|
||||
echo Invent missing headers
|
||||
|
||||
cp $XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDKVERSION}.sdk/usr/include/{crt_externs,bzlib}.h $BOOST_SRC
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
bootstrapBoost()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g")
|
||||
echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)"
|
||||
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
buildBoostForIPhoneOS()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
# Install this one so we can copy the includes for the frameworks...
|
||||
./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage
|
||||
./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install
|
||||
doneSection
|
||||
|
||||
./bjam -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin-${IPHONE_SDKVERSION}~iphonesim architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage
|
||||
doneSection
|
||||
|
||||
# ./b2 -j16 --build-dir=osx-build --stagedir=osx-build/stage toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++" link=static threading=multi stage
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
scrunchAllLibsTogetherInOneLibPerPlatform()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
mkdir -p $IOSBUILDDIR/armv6/obj
|
||||
mkdir -p $IOSBUILDDIR/armv7/obj
|
||||
mkdir -p $IOSBUILDDIR/armv7s/obj
|
||||
mkdir -p $IOSBUILDDIR/arm64/obj
|
||||
mkdir -p $IOSBUILDDIR/i386/obj
|
||||
mkdir -p $IOSBUILDDIR/x86_64/obj
|
||||
|
||||
mkdir -p $OSXBUILDDIR/i386/obj
|
||||
mkdir -p $OSXBUILDDIR/x86_64/obj
|
||||
|
||||
ALL_LIBS=""
|
||||
|
||||
echo Splitting all existing fat binaries...
|
||||
|
||||
for NAME in $BOOST_LIBS; do
|
||||
ALL_LIBS="$ALL_LIBS libboost_$NAME.a"
|
||||
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv6 -o $IOSBUILDDIR/armv6/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7 -o $IOSBUILDDIR/armv7/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7s -o $IOSBUILDDIR/armv7s/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin arm64 -o $IOSBUILDDIR/arm64/libboost_$NAME.a
|
||||
|
||||
$ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin i386 -o $IOSBUILDDIR/i386/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $IOSBUILDDIR/x86_64/libboost_$NAME.a
|
||||
|
||||
$ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin i386 -o $OSXBUILDDIR/i386/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $OSXBUILDDIR/x86_64/libboost_$NAME.a
|
||||
done
|
||||
|
||||
echo "Decomposing each architecture's .a files"
|
||||
|
||||
for NAME in $ALL_LIBS; do
|
||||
echo Decomposing $NAME...
|
||||
(cd $IOSBUILDDIR/armv6/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/armv7/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/armv7s/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/arm64/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/i386/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/x86_64/obj; ar -x ../$NAME );
|
||||
|
||||
(cd $OSXBUILDDIR/i386/obj; ar -x ../$NAME );
|
||||
(cd $OSXBUILDDIR/x86_64/obj; ar -x ../$NAME );
|
||||
done
|
||||
|
||||
echo "Linking each architecture into an uberlib ($ALL_LIBS => libboost.a )"
|
||||
|
||||
rm $IOSBUILDDIR/*/libboost.a
|
||||
|
||||
echo ...armv6
|
||||
(cd $IOSBUILDDIR/armv6; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...armv7
|
||||
(cd $IOSBUILDDIR/armv7; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...armv7s
|
||||
(cd $IOSBUILDDIR/armv7s; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...arm64
|
||||
(cd $IOSBUILDDIR/arm64; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...i386
|
||||
(cd $IOSBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...x86_64
|
||||
(cd $IOSBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
|
||||
rm $OSXBUILDDIR/*/libboost.a
|
||||
echo ...osx-i386
|
||||
(cd $OSXBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
|
||||
echo ...x86_64
|
||||
(cd $OSXBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
buildFramework()
|
||||
{
|
||||
: ${1:?}
|
||||
FRAMEWORKDIR=$1
|
||||
BUILDDIR=$2
|
||||
|
||||
VERSION_TYPE=Alpha
|
||||
FRAMEWORK_NAME=boost
|
||||
FRAMEWORK_VERSION=A
|
||||
|
||||
FRAMEWORK_CURRENT_VERSION=$BOOST_VERSION
|
||||
FRAMEWORK_COMPATIBILITY_VERSION=$BOOST_VERSION
|
||||
|
||||
FRAMEWORK_BUNDLE=$FRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
echo "Framework: Building $FRAMEWORK_BUNDLE from $BUILDDIR..."
|
||||
|
||||
rm -rf $FRAMEWORK_BUNDLE
|
||||
|
||||
echo "Framework: Setting up directories..."
|
||||
mkdir -p $FRAMEWORK_BUNDLE
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Resources
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Headers
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Documentation
|
||||
|
||||
echo "Framework: Creating symlinks..."
|
||||
ln -s $FRAMEWORK_VERSION $FRAMEWORK_BUNDLE/Versions/Current
|
||||
ln -s Versions/Current/Headers $FRAMEWORK_BUNDLE/Headers
|
||||
ln -s Versions/Current/Resources $FRAMEWORK_BUNDLE/Resources
|
||||
ln -s Versions/Current/Documentation $FRAMEWORK_BUNDLE/Documentation
|
||||
ln -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_BUNDLE/$FRAMEWORK_NAME
|
||||
|
||||
FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_NAME
|
||||
|
||||
echo "Lipoing library into $FRAMEWORK_INSTALL_NAME..."
|
||||
$ARM_DEV_CMD lipo -create $BUILDDIR/*/libboost.a -o "$FRAMEWORK_INSTALL_NAME" || abort "Lipo $1 failed"
|
||||
|
||||
echo "Framework: Copying includes..."
|
||||
cp -r $PREFIXDIR/include/boost/* $FRAMEWORK_BUNDLE/Headers/
|
||||
|
||||
echo "Framework: Creating plist..."
|
||||
cat > $FRAMEWORK_BUNDLE/Resources/Info.plist <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${FRAMEWORK_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.boost</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${FRAMEWORK_CURRENT_VERSION}</string>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
# Execution starts here
|
||||
#===============================================================================
|
||||
|
||||
mkdir -p $IOSBUILDDIR
|
||||
|
||||
cleanEverythingReadyToStart #may want to comment if repeatedly running during dev
|
||||
restoreBoost
|
||||
|
||||
echo "BOOST_VERSION: $BOOST_VERSION"
|
||||
echo "BOOST_LIBS: $BOOST_LIBS"
|
||||
echo "BOOST_SRC: $BOOST_SRC"
|
||||
echo "IOSBUILDDIR: $IOSBUILDDIR"
|
||||
echo "OSXBUILDDIR: $OSXBUILDDIR"
|
||||
echo "PREFIXDIR: $PREFIXDIR"
|
||||
echo "IOSFRAMEWORKDIR: $IOSFRAMEWORKDIR"
|
||||
echo "OSXFRAMEWORKDIR: $OSXFRAMEWORKDIR"
|
||||
echo "IPHONE_SDKVERSION: $IPHONE_SDKVERSION"
|
||||
echo "XCODE_ROOT: $XCODE_ROOT"
|
||||
echo "COMPILER: $COMPILER"
|
||||
echo
|
||||
|
||||
downloadBoost
|
||||
unpackBoost
|
||||
inventMissingHeaders
|
||||
bootstrapBoost
|
||||
updateBoost
|
||||
buildBoostForIPhoneOS
|
||||
scrunchAllLibsTogetherInOneLibPerPlatform
|
||||
buildFramework $IOSFRAMEWORKDIR $IOSBUILDDIR
|
||||
buildFramework $OSXFRAMEWORKDIR $OSXBUILDDIR
|
||||
|
||||
restoreBoost
|
||||
|
||||
echo "Completed successfully"
|
||||
|
||||
#===============================================================================
|
||||
11
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/main.cpp
vendored
Normal file
11
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/main.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
291
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.cpp
vendored
Normal file
291
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.cpp
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <cstdlib>
|
||||
|
||||
#define kURL "ws://localhost:3000"
|
||||
#ifdef WIN32
|
||||
#define BIND_EVENT(IO,EV,FN) \
|
||||
do{ \
|
||||
socket::event_listener_aux l = FN;\
|
||||
IO->on(EV,l);\
|
||||
} while(0)
|
||||
|
||||
#else
|
||||
#define BIND_EVENT(IO,EV,FN) \
|
||||
IO->on(EV,FN)
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
_io(new client()),
|
||||
m_typingItem(NULL),
|
||||
m_dialog()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
using std::placeholders::_1;
|
||||
using std::placeholders::_2;
|
||||
using std::placeholders::_3;
|
||||
using std::placeholders::_4;
|
||||
socket::ptr sock = _io->socket();
|
||||
BIND_EVENT(sock,"new message",std::bind(&MainWindow::OnNewMessage,this,_1,_2,_3,_4));
|
||||
BIND_EVENT(sock,"user joined",std::bind(&MainWindow::OnUserJoined,this,_1,_2,_3,_4));
|
||||
BIND_EVENT(sock,"user left",std::bind(&MainWindow::OnUserLeft,this,_1,_2,_3,_4));
|
||||
BIND_EVENT(sock,"typing",std::bind(&MainWindow::OnTyping,this,_1,_2,_3,_4));
|
||||
BIND_EVENT(sock,"stop typing",std::bind(&MainWindow::OnStopTyping,this,_1,_2,_3,_4));
|
||||
BIND_EVENT(sock,"login",std::bind(&MainWindow::OnLogin,this,_1,_2,_3,_4));
|
||||
_io->set_socket_open_listener(std::bind(&MainWindow::OnConnected,this,std::placeholders::_1));
|
||||
_io->set_close_listener(std::bind(&MainWindow::OnClosed,this,_1));
|
||||
_io->set_fail_listener(std::bind(&MainWindow::OnFailed,this));
|
||||
|
||||
connect(this,SIGNAL(RequestAddListItem(QListWidgetItem*)),this,SLOT(AddListItem(QListWidgetItem*)));
|
||||
connect(this,SIGNAL(RequestRemoveListItem(QListWidgetItem*)),this,SLOT(RemoveListItem(QListWidgetItem*)));
|
||||
connect(this,SIGNAL(RequestToggleInputs(bool)),this,SLOT(ToggleInputs(bool)));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
_io->socket()->off_all();
|
||||
_io->socket()->off_error();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::SendBtnClicked()
|
||||
{
|
||||
QLineEdit* messageEdit = this->findChild<QLineEdit*>("messageEdit");
|
||||
QString text = messageEdit->text();
|
||||
if(text.length()>0)
|
||||
{
|
||||
QByteArray bytes = text.toUtf8();
|
||||
std::string msg(bytes.data(),bytes.length());
|
||||
_io->socket()->emit("new message",msg);
|
||||
text.append(" : You");
|
||||
QListWidgetItem *item = new QListWidgetItem(text);
|
||||
item->setTextAlignment(Qt::AlignRight);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
messageEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnMessageReturn()
|
||||
{
|
||||
this->SendBtnClicked();
|
||||
}
|
||||
|
||||
void MainWindow::ShowLoginDialog()
|
||||
{
|
||||
m_dialog.reset(new NicknameDialog(this));
|
||||
connect(m_dialog.get(),SIGNAL(accepted()),this,SLOT(NicknameAccept()));
|
||||
connect(m_dialog.get(),SIGNAL(rejected()),this,SLOT(NicknameCancelled()));
|
||||
m_dialog->exec();
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
ShowLoginDialog();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::TypingStop()
|
||||
{
|
||||
m_timer.reset();
|
||||
_io->socket()->emit("stop typing");
|
||||
}
|
||||
|
||||
void MainWindow::TypingChanged()
|
||||
{
|
||||
if(m_timer&&m_timer->isActive())
|
||||
{
|
||||
m_timer->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_io->socket()->emit("typing");
|
||||
}
|
||||
m_timer.reset(new QTimer(this));
|
||||
connect(m_timer.get(),SIGNAL(timeout()),this,SLOT(TypingStop()));
|
||||
m_timer->setSingleShot(true);
|
||||
m_timer->start(1000);
|
||||
}
|
||||
|
||||
void MainWindow::NicknameAccept()
|
||||
{
|
||||
m_name = m_dialog->getNickname();
|
||||
if(m_name.length()>0)
|
||||
{
|
||||
_io->connect(kURL);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::NicknameCancelled()
|
||||
{
|
||||
QApplication::exit();
|
||||
}
|
||||
|
||||
void MainWindow::AddListItem(QListWidgetItem* item)
|
||||
{
|
||||
this->findChild<QListWidget*>("listView")->addItem(item);
|
||||
}
|
||||
|
||||
void MainWindow::RemoveListItem(QListWidgetItem* item)
|
||||
{
|
||||
QListWidget* list = this->findChild<QListWidget*>("listView");
|
||||
int row = list->row(item);
|
||||
delete list->takeItem(row);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::OnNewMessage(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
std::string msg = data->get_map()["message"]->get_string();
|
||||
std::string username = data->get_map()["username"]->get_string();
|
||||
QString label = QString::fromUtf8(username.data(),username.length());
|
||||
label.append(" : ");
|
||||
label.append(QString::fromUtf8(msg.data(),msg.length()));
|
||||
QListWidgetItem *item= new QListWidgetItem(label);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnUserJoined(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
std::string name = data->get_map()["username"]->get_string();
|
||||
int numUser = data->get_map()["numUsers"]->get_int();
|
||||
QString label = QString::fromUtf8(name.data(),name.length());
|
||||
bool plural = numUser != 1;
|
||||
label.append(" joined\n");
|
||||
label.append(plural?"there are ":"there's ");
|
||||
QString digits;
|
||||
while(numUser>=10)
|
||||
{
|
||||
digits.insert(0,QChar((numUser%10)+'0'));
|
||||
numUser/=10;
|
||||
}
|
||||
digits.insert(0,QChar(numUser+'0'));
|
||||
label.append(digits);
|
||||
label.append(plural?" participants":" participant");
|
||||
QListWidgetItem *item= new QListWidgetItem(label);
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
QFont font;
|
||||
font.setPointSize(9);
|
||||
item->setFont(font);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::OnUserLeft(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
std::string name = data->get_map()["username"]->get_string();
|
||||
int numUser = data->get_map()["numUsers"]->get_int();
|
||||
QString label = QString::fromUtf8(name.data(),name.length());
|
||||
bool plural = numUser != 1;
|
||||
label.append(" left\n");
|
||||
label.append(plural?"there are ":"there's ");
|
||||
QString digits;
|
||||
while(numUser>=10)
|
||||
{
|
||||
digits.insert(0,QChar((numUser%10)+'0'));
|
||||
numUser/=10;
|
||||
}
|
||||
digits.insert(0,QChar(numUser+'0'));
|
||||
label.append(digits);
|
||||
label.append(plural?" participants":" participant");
|
||||
QListWidgetItem *item= new QListWidgetItem(label);
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
QFont font;
|
||||
font.setPointSize(9);
|
||||
item->setFont(font);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnTyping(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
if(m_typingItem == NULL)
|
||||
{
|
||||
std::string name = data->get_map()["username"]->get_string();
|
||||
QString label = QString::fromUtf8(name.data(),name.length());
|
||||
label.append(" is typing...");
|
||||
QListWidgetItem *item = new QListWidgetItem(label);
|
||||
item->setTextColor(QColor(200,200,200,255));
|
||||
m_typingItem = item;
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnStopTyping(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
if(m_typingItem != NULL)
|
||||
{
|
||||
Q_EMIT RequestRemoveListItem(m_typingItem);
|
||||
m_typingItem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnLogin(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp)
|
||||
{
|
||||
Q_EMIT RequestToggleInputs(true);
|
||||
int numUser = data->get_map()["numUsers"]->get_int();
|
||||
|
||||
QString digits;
|
||||
bool plural = numUser !=1;
|
||||
while(numUser>=10)
|
||||
{
|
||||
digits.insert(0,QChar((numUser%10)+'0'));
|
||||
numUser/=10;
|
||||
}
|
||||
|
||||
digits.insert(0,QChar(numUser+'0'));
|
||||
digits.insert(0,plural?"there are ":"there's ");
|
||||
digits.append(plural? " participants":" participant");
|
||||
QListWidgetItem *item = new QListWidgetItem(digits);
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
QFont font;
|
||||
font.setPointSize(9);
|
||||
item->setFont(font);
|
||||
Q_EMIT RequestAddListItem(item);
|
||||
}
|
||||
|
||||
void MainWindow::OnConnected(std::string const& nsp)
|
||||
{
|
||||
QByteArray bytes = m_name.toUtf8();
|
||||
std::string nickName(bytes.data(),bytes.length());
|
||||
_io->socket()->emit("add user", nickName);
|
||||
}
|
||||
|
||||
void MainWindow::OnClosed(client::close_reason const& reason)
|
||||
{
|
||||
Q_EMIT RequestToggleInputs(false);
|
||||
}
|
||||
|
||||
void MainWindow::OnFailed()
|
||||
{
|
||||
Q_EMIT RequestToggleInputs(false);
|
||||
}
|
||||
|
||||
void MainWindow::ToggleInputs(bool loginOrNot)
|
||||
{
|
||||
if(loginOrNot)//already login
|
||||
{
|
||||
this->findChild<QWidget*>("messageEdit")->setEnabled(true);
|
||||
this->findChild<QWidget*>("listView")->setEnabled(true);
|
||||
// this->findChild<QWidget*>("sendBtn")->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->findChild<QWidget*>("messageEdit")->setEnabled(false);
|
||||
this->findChild<QWidget*>("listView")->setEnabled(false);
|
||||
// this->findChild<QWidget*>("sendBtn")->setEnabled(false);
|
||||
ShowLoginDialog();
|
||||
}
|
||||
}
|
||||
68
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.h
vendored
Normal file
68
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.h
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QTimer>
|
||||
#include <sio_client.h>
|
||||
#include "nicknamedialog.h"
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
using namespace sio;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
public Q_SLOTS:
|
||||
void SendBtnClicked();
|
||||
void TypingChanged();
|
||||
void OnMessageReturn();
|
||||
protected:
|
||||
void showEvent(QShowEvent* event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void RequestAddListItem(QListWidgetItem *item);
|
||||
void RequestRemoveListItem(QListWidgetItem *item);
|
||||
void RequestToggleInputs(bool loginOrNot);
|
||||
private Q_SLOTS:
|
||||
void AddListItem(QListWidgetItem *item);
|
||||
void RemoveListItem(QListWidgetItem *item);
|
||||
void ToggleInputs(bool loginOrNot);
|
||||
void TypingStop();
|
||||
void NicknameAccept();
|
||||
void NicknameCancelled();
|
||||
private:
|
||||
void OnNewMessage(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnUserJoined(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnUserLeft(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnTyping(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnStopTyping(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnLogin(std::string const& name,message::ptr const& data,bool hasAck,message::list &ack_resp);
|
||||
void OnConnected(std::string const& nsp);
|
||||
void OnClosed(client::close_reason const& reason);
|
||||
void OnFailed();
|
||||
void ShowLoginDialog();
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
std::unique_ptr<client> _io;
|
||||
|
||||
std::unique_ptr<NicknameDialog> m_dialog;
|
||||
|
||||
QString m_name;
|
||||
|
||||
std::unique_ptr<QTimer> m_timer;
|
||||
|
||||
QListWidgetItem *m_typingItem;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
131
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.ui
vendored
Normal file
131
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/mainwindow.ui
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>366</width>
|
||||
<height>549</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Socket.IO Chat</string>
|
||||
</property>
|
||||
<property name="unifiedTitleAndToolBarOnMac">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QListWidget" name="listView">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>11</y>
|
||||
<width>350</width>
|
||||
<height>461</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="messageEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>480</y>
|
||||
<width>350</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Type here...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>366</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>messageEdit</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>OnMessageReturn()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>116</x>
|
||||
<y>524</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>30</x>
|
||||
<y>545</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>messageEdit</sender>
|
||||
<signal>textChanged(QString)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>TypingChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>73</x>
|
||||
<y>531</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>70</x>
|
||||
<y>510</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>SendBtnClicked(bool)</slot>
|
||||
<slot>TypingChanged()</slot>
|
||||
<slot>LoginClicked()</slot>
|
||||
<slot>OnMessageReturn()</slot>
|
||||
<slot>SendBtnClicked()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
38
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.cpp
vendored
Normal file
38
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.cpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "nicknamedialog.h"
|
||||
#include "ui_nicknamedialog.h"
|
||||
#include <QTimer>
|
||||
NicknameDialog::NicknameDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NicknameDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
NicknameDialog::~NicknameDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
const QString& NicknameDialog::getNickname() const
|
||||
{
|
||||
return m_nickName;
|
||||
}
|
||||
|
||||
void NicknameDialog::exitApp()
|
||||
{
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
void NicknameDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QTimer::singleShot(0,this,SLOT(exitApp()));
|
||||
}
|
||||
|
||||
void NicknameDialog::accept()
|
||||
{
|
||||
if(this->findChild<QLineEdit*>("nicknameEdit")->text().length()>0)
|
||||
{
|
||||
m_nickName = this->findChild<QLineEdit*>("nicknameEdit")->text();
|
||||
done(QDialog::Accepted);
|
||||
}
|
||||
}
|
||||
28
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.h
vendored
Normal file
28
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef NICKNAMEDIALOG_H
|
||||
#define NICKNAMEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class NicknameDialog;
|
||||
}
|
||||
|
||||
class NicknameDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public Q_SLOTS:
|
||||
void accept();
|
||||
void exitApp();
|
||||
public:
|
||||
explicit NicknameDialog(QWidget *parent = 0);
|
||||
~NicknameDialog();
|
||||
|
||||
const QString& getNickname() const;
|
||||
void closeEvent(QCloseEvent *);
|
||||
private:
|
||||
Ui::NicknameDialog *ui;
|
||||
QString m_nickName;
|
||||
};
|
||||
|
||||
#endif // NICKNAMEDIALOG_H
|
||||
106
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.ui
vendored
Normal file
106
third_party/socket.io-client-cpp/examples/QT/SioChatDemo/nicknamedialog.ui
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NicknameDialog</class>
|
||||
<widget class="QDialog" name="NicknameDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>366</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Login</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>99</y>
|
||||
<width>311</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="nicknameEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>27</x>
|
||||
<y>60</y>
|
||||
<width>311</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Type nickname here...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>44</x>
|
||||
<y>23</y>
|
||||
<width>271</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>What's your nickname?</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NicknameDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>298</x>
|
||||
<y>97</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>298</x>
|
||||
<y>108</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NicknameDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>210</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>202</x>
|
||||
<y>84</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>checkAccept()</slot>
|
||||
<slot>checkAcc()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
31
third_party/socket.io-client-cpp/examples/iOS/README.md
vendored
Normal file
31
third_party/socket.io-client-cpp/examples/iOS/README.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#SIOClient iOS chat room demo
|
||||
## What is this
|
||||
This is a iOS project run on xcode 6, you can use this single view application chatting in the official [chat room demo](https://github.com/Automattic/socket.io/tree/master/examples/chat).
|
||||
|
||||
## How to setup
|
||||
Suppose you're using your Mac's shell, under your workspace folder, run
|
||||
```shell
|
||||
git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git
|
||||
```
|
||||
Step in the demo folder
|
||||
```shell
|
||||
cd ./socket.io-client-cpp/examples/iOS/SioChatDemo
|
||||
```
|
||||
you will see a shell script named `boost.sh` under folder `boost`,Run
|
||||
```shell
|
||||
cd ./boost
|
||||
bash ./boost.sh
|
||||
```
|
||||
Please stand by with patient, this step will take about one or two hours depends on your network.
|
||||
When done, open `SioChatDemo.xcodeproj` file in the parent folder with xcode.
|
||||
Just compile and run the `SioChatDemo` target.
|
||||
Now, if you have your chat room server run on your local machine, you can chat with device to device or device to web.
|
||||
|
||||
## Use sioclient as static lib on iOS
|
||||
There's a target named `sioclient` in the Demo project, That is the exactly right config for buiding the `sioclient` as a static library on iOS.
|
||||
With the static library file `libsioclient.a` and two exported headers `sio_client.h` and `sio_message.h`, you won't need to config anything again and again in your integrating projects.
|
||||
|
||||
## About the `boost.sh`
|
||||
The `boost.sh` is copied from [boostmake_ios](https://github.com/alist/boostmake_ios),it is worked on my machine for boost 1.55.0
|
||||
there're lot's versions of boost build shells, you can choose what you like.
|
||||
|
||||
1
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/.gitignore
vendored
Normal file
1
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/**/xcuserdata/
|
||||
722
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo.xcodeproj/project.pbxproj
vendored
Normal file
722
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo.xcodeproj/project.pbxproj
vendored
Normal file
@@ -0,0 +1,722 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
CE1D31A01AD5087800895150 /* sio_packet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE1D319E1AD5087800895150 /* sio_packet.cpp */; };
|
||||
CE1D31A11AD5087800895150 /* sio_packet.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1D319F1AD5087800895150 /* sio_packet.h */; };
|
||||
CE2958691ACE4589000ABD30 /* sio_client_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE2958671ACE442F000ABD30 /* sio_client_impl.cpp */; };
|
||||
CE29586A1ACE4592000ABD30 /* sio_socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE2958621ACE2CD6000ABD30 /* sio_socket.cpp */; };
|
||||
CE3B3B401AC8F365003CEB94 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CE3B3B3F1AC8F365003CEB94 /* main.m */; };
|
||||
CE3B3B431AC8F365003CEB94 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE3B3B421AC8F365003CEB94 /* AppDelegate.m */; };
|
||||
CE3B3B4B1AC8F365003CEB94 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE3B3B4A1AC8F365003CEB94 /* Images.xcassets */; };
|
||||
CE3B3B4E1AC8F365003CEB94 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE3B3B4C1AC8F365003CEB94 /* LaunchScreen.xib */; };
|
||||
CE3B3B5A1AC8F365003CEB94 /* SioChatDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CE3B3B591AC8F365003CEB94 /* SioChatDemoTests.m */; };
|
||||
CE3B3B651AC8F385003CEB94 /* CRViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE3B3B641AC8F385003CEB94 /* CRViewController.mm */; };
|
||||
CE3B3B751AC8F438003CEB94 /* libsioclient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE3B3B6A1AC8F438003CEB94 /* libsioclient.a */; };
|
||||
CE3B3E6D1AC8FE59003CEB94 /* libsioclient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE3B3B6A1AC8F438003CEB94 /* libsioclient.a */; };
|
||||
CE3B3E6F1AC9139B003CEB94 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE3B3E6E1AC9139B003CEB94 /* Main.storyboard */; };
|
||||
CE3B3E8C1ACA5446003CEB94 /* sio_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3B3E871ACA5446003CEB94 /* sio_client.cpp */; };
|
||||
CE3B3E8D1ACA5446003CEB94 /* sio_client.h in Headers */ = {isa = PBXBuildFile; fileRef = CE3B3E881ACA5446003CEB94 /* sio_client.h */; };
|
||||
CE3B3E8E1ACA5446003CEB94 /* sio_message.h in Headers */ = {isa = PBXBuildFile; fileRef = CE3B3E891ACA5446003CEB94 /* sio_message.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
CE3B3B541AC8F365003CEB94 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CE3B3B321AC8F365003CEB94 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = CE3B3B391AC8F365003CEB94;
|
||||
remoteInfo = SioChatDemo;
|
||||
};
|
||||
CE3B3B761AC8F438003CEB94 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CE3B3B321AC8F365003CEB94 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = CE3B3B691AC8F438003CEB94;
|
||||
remoteInfo = sioclient;
|
||||
};
|
||||
CE3B3E6B1AC8FE54003CEB94 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = CE3B3B321AC8F365003CEB94 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = CE3B3B691AC8F438003CEB94;
|
||||
remoteInfo = sioclient;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
CE3B3B681AC8F438003CEB94 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
CE1D319E1AD5087800895150 /* sio_packet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sio_packet.cpp; sourceTree = "<group>"; };
|
||||
CE1D319F1AD5087800895150 /* sio_packet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio_packet.h; sourceTree = "<group>"; };
|
||||
CE2958621ACE2CD6000ABD30 /* sio_socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sio_socket.cpp; sourceTree = "<group>"; };
|
||||
CE2958631ACE2CD6000ABD30 /* sio_socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio_socket.h; sourceTree = "<group>"; };
|
||||
CE2958661ACE2CDD000ABD30 /* sio_client_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio_client_impl.h; sourceTree = "<group>"; };
|
||||
CE2958671ACE442F000ABD30 /* sio_client_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sio_client_impl.cpp; sourceTree = "<group>"; };
|
||||
CE3B3B3A1AC8F365003CEB94 /* SioChatDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SioChatDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CE3B3B3E1AC8F365003CEB94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
CE3B3B3F1AC8F365003CEB94 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
CE3B3B411AC8F365003CEB94 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
CE3B3B421AC8F365003CEB94 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
CE3B3B4A1AC8F365003CEB94 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
CE3B3B4D1AC8F365003CEB94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
|
||||
CE3B3B531AC8F365003CEB94 /* SioChatDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SioChatDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CE3B3B581AC8F365003CEB94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
CE3B3B591AC8F365003CEB94 /* SioChatDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SioChatDemoTests.m; sourceTree = "<group>"; };
|
||||
CE3B3B631AC8F385003CEB94 /* CRViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CRViewController.h; sourceTree = "<group>"; };
|
||||
CE3B3B641AC8F385003CEB94 /* CRViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CRViewController.mm; sourceTree = "<group>"; };
|
||||
CE3B3B6A1AC8F438003CEB94 /* libsioclient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libsioclient.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CE3B3B741AC8F438003CEB94 /* sioclientTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = sioclientTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CE3B3B7A1AC8F438003CEB94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
CE3B3E6E1AC9139B003CEB94 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
|
||||
CE3B3E871ACA5446003CEB94 /* sio_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sio_client.cpp; sourceTree = "<group>"; };
|
||||
CE3B3E881ACA5446003CEB94 /* sio_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio_client.h; sourceTree = "<group>"; };
|
||||
CE3B3E891ACA5446003CEB94 /* sio_message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio_message.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
CE3B3B371AC8F365003CEB94 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3E6D1AC8FE59003CEB94 /* libsioclient.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B501AC8F365003CEB94 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B671AC8F438003CEB94 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B711AC8F438003CEB94 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3B751AC8F438003CEB94 /* libsioclient.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
CE2958651ACE2CDD000ABD30 /* internal */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE1D319E1AD5087800895150 /* sio_packet.cpp */,
|
||||
CE1D319F1AD5087800895150 /* sio_packet.h */,
|
||||
CE2958661ACE2CDD000ABD30 /* sio_client_impl.h */,
|
||||
CE2958671ACE442F000ABD30 /* sio_client_impl.cpp */,
|
||||
);
|
||||
path = internal;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B311AC8F365003CEB94 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3E861ACA5446003CEB94 /* src */,
|
||||
CE3B3B3C1AC8F365003CEB94 /* SioChatDemo */,
|
||||
CE3B3B561AC8F365003CEB94 /* SioChatDemoTests */,
|
||||
CE3B3B6B1AC8F438003CEB94 /* sioclient */,
|
||||
CE3B3B781AC8F438003CEB94 /* sioclientTests */,
|
||||
CE3B3B3B1AC8F365003CEB94 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B3B1AC8F365003CEB94 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B3A1AC8F365003CEB94 /* SioChatDemo.app */,
|
||||
CE3B3B531AC8F365003CEB94 /* SioChatDemoTests.xctest */,
|
||||
CE3B3B6A1AC8F438003CEB94 /* libsioclient.a */,
|
||||
CE3B3B741AC8F438003CEB94 /* sioclientTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B3C1AC8F365003CEB94 /* SioChatDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3E6E1AC9139B003CEB94 /* Main.storyboard */,
|
||||
CE3B3B411AC8F365003CEB94 /* AppDelegate.h */,
|
||||
CE3B3B421AC8F365003CEB94 /* AppDelegate.m */,
|
||||
CE3B3B631AC8F385003CEB94 /* CRViewController.h */,
|
||||
CE3B3B641AC8F385003CEB94 /* CRViewController.mm */,
|
||||
CE3B3B4A1AC8F365003CEB94 /* Images.xcassets */,
|
||||
CE3B3B4C1AC8F365003CEB94 /* LaunchScreen.xib */,
|
||||
CE3B3B3D1AC8F365003CEB94 /* Supporting Files */,
|
||||
);
|
||||
path = SioChatDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B3D1AC8F365003CEB94 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B3E1AC8F365003CEB94 /* Info.plist */,
|
||||
CE3B3B3F1AC8F365003CEB94 /* main.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B561AC8F365003CEB94 /* SioChatDemoTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B591AC8F365003CEB94 /* SioChatDemoTests.m */,
|
||||
CE3B3B571AC8F365003CEB94 /* Supporting Files */,
|
||||
);
|
||||
path = SioChatDemoTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B571AC8F365003CEB94 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B581AC8F365003CEB94 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B6B1AC8F438003CEB94 /* sioclient */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = sioclient;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B781AC8F438003CEB94 /* sioclientTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B791AC8F438003CEB94 /* Supporting Files */,
|
||||
);
|
||||
path = sioclientTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3B791AC8F438003CEB94 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE3B3B7A1AC8F438003CEB94 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CE3B3E861ACA5446003CEB94 /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE2958651ACE2CDD000ABD30 /* internal */,
|
||||
CE2958621ACE2CD6000ABD30 /* sio_socket.cpp */,
|
||||
CE2958631ACE2CD6000ABD30 /* sio_socket.h */,
|
||||
CE3B3E871ACA5446003CEB94 /* sio_client.cpp */,
|
||||
CE3B3E881ACA5446003CEB94 /* sio_client.h */,
|
||||
CE3B3E891ACA5446003CEB94 /* sio_message.h */,
|
||||
);
|
||||
name = src;
|
||||
path = ../../../src;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
CE3B3E681AC8F511003CEB94 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3E8E1ACA5446003CEB94 /* sio_message.h in Headers */,
|
||||
CE1D31A11AD5087800895150 /* sio_packet.h in Headers */,
|
||||
CE3B3E8D1ACA5446003CEB94 /* sio_client.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
CE3B3B391AC8F365003CEB94 /* SioChatDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CE3B3B5D1AC8F365003CEB94 /* Build configuration list for PBXNativeTarget "SioChatDemo" */;
|
||||
buildPhases = (
|
||||
CE3B3B361AC8F365003CEB94 /* Sources */,
|
||||
CE3B3B371AC8F365003CEB94 /* Frameworks */,
|
||||
CE3B3B381AC8F365003CEB94 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
CE3B3E6C1AC8FE54003CEB94 /* PBXTargetDependency */,
|
||||
);
|
||||
name = SioChatDemo;
|
||||
productName = SioChatDemo;
|
||||
productReference = CE3B3B3A1AC8F365003CEB94 /* SioChatDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
CE3B3B521AC8F365003CEB94 /* SioChatDemoTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CE3B3B601AC8F365003CEB94 /* Build configuration list for PBXNativeTarget "SioChatDemoTests" */;
|
||||
buildPhases = (
|
||||
CE3B3B4F1AC8F365003CEB94 /* Sources */,
|
||||
CE3B3B501AC8F365003CEB94 /* Frameworks */,
|
||||
CE3B3B511AC8F365003CEB94 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
CE3B3B551AC8F365003CEB94 /* PBXTargetDependency */,
|
||||
);
|
||||
name = SioChatDemoTests;
|
||||
productName = SioChatDemoTests;
|
||||
productReference = CE3B3B531AC8F365003CEB94 /* SioChatDemoTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
CE3B3B691AC8F438003CEB94 /* sioclient */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CE3B3B7B1AC8F438003CEB94 /* Build configuration list for PBXNativeTarget "sioclient" */;
|
||||
buildPhases = (
|
||||
CE3B3B661AC8F438003CEB94 /* Sources */,
|
||||
CE3B3B671AC8F438003CEB94 /* Frameworks */,
|
||||
CE3B3B681AC8F438003CEB94 /* CopyFiles */,
|
||||
CE3B3E681AC8F511003CEB94 /* Headers */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = sioclient;
|
||||
productName = sioclient;
|
||||
productReference = CE3B3B6A1AC8F438003CEB94 /* libsioclient.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
CE3B3B731AC8F438003CEB94 /* sioclientTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CE3B3B7E1AC8F438003CEB94 /* Build configuration list for PBXNativeTarget "sioclientTests" */;
|
||||
buildPhases = (
|
||||
CE3B3B701AC8F438003CEB94 /* Sources */,
|
||||
CE3B3B711AC8F438003CEB94 /* Frameworks */,
|
||||
CE3B3B721AC8F438003CEB94 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
CE3B3B771AC8F438003CEB94 /* PBXTargetDependency */,
|
||||
);
|
||||
name = sioclientTests;
|
||||
productName = sioclientTests;
|
||||
productReference = CE3B3B741AC8F438003CEB94 /* sioclientTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
CE3B3B321AC8F365003CEB94 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0610;
|
||||
ORGANIZATIONNAME = "Melo Yao";
|
||||
TargetAttributes = {
|
||||
CE3B3B391AC8F365003CEB94 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
};
|
||||
CE3B3B521AC8F365003CEB94 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
TestTargetID = CE3B3B391AC8F365003CEB94;
|
||||
};
|
||||
CE3B3B691AC8F438003CEB94 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
};
|
||||
CE3B3B731AC8F438003CEB94 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = CE3B3B351AC8F365003CEB94 /* Build configuration list for PBXProject "SioChatDemo" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = CE3B3B311AC8F365003CEB94;
|
||||
productRefGroup = CE3B3B3B1AC8F365003CEB94 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
CE3B3B391AC8F365003CEB94 /* SioChatDemo */,
|
||||
CE3B3B521AC8F365003CEB94 /* SioChatDemoTests */,
|
||||
CE3B3B691AC8F438003CEB94 /* sioclient */,
|
||||
CE3B3B731AC8F438003CEB94 /* sioclientTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
CE3B3B381AC8F365003CEB94 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3E6F1AC9139B003CEB94 /* Main.storyboard in Resources */,
|
||||
CE3B3B4E1AC8F365003CEB94 /* LaunchScreen.xib in Resources */,
|
||||
CE3B3B4B1AC8F365003CEB94 /* Images.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B511AC8F365003CEB94 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B721AC8F438003CEB94 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
CE3B3B361AC8F365003CEB94 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3B431AC8F365003CEB94 /* AppDelegate.m in Sources */,
|
||||
CE3B3B401AC8F365003CEB94 /* main.m in Sources */,
|
||||
CE3B3B651AC8F385003CEB94 /* CRViewController.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B4F1AC8F365003CEB94 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE3B3B5A1AC8F365003CEB94 /* SioChatDemoTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B661AC8F438003CEB94 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE29586A1ACE4592000ABD30 /* sio_socket.cpp in Sources */,
|
||||
CE1D31A01AD5087800895150 /* sio_packet.cpp in Sources */,
|
||||
CE2958691ACE4589000ABD30 /* sio_client_impl.cpp in Sources */,
|
||||
CE3B3E8C1ACA5446003CEB94 /* sio_client.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
CE3B3B701AC8F438003CEB94 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
CE3B3B551AC8F365003CEB94 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = CE3B3B391AC8F365003CEB94 /* SioChatDemo */;
|
||||
targetProxy = CE3B3B541AC8F365003CEB94 /* PBXContainerItemProxy */;
|
||||
};
|
||||
CE3B3B771AC8F438003CEB94 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = CE3B3B691AC8F438003CEB94 /* sioclient */;
|
||||
targetProxy = CE3B3B761AC8F438003CEB94 /* PBXContainerItemProxy */;
|
||||
};
|
||||
CE3B3E6C1AC8FE54003CEB94 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = CE3B3B691AC8F438003CEB94 /* sioclient */;
|
||||
targetProxy = CE3B3E6B1AC8FE54003CEB94 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
CE3B3B4C1AC8F365003CEB94 /* LaunchScreen.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
CE3B3B4D1AC8F365003CEB94 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
CE3B3B5B1AC8F365003CEB94 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE3B3B5C1AC8F365003CEB94 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CE3B3B5E1AC8F365003CEB94 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = SioChatDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE3B3B5F1AC8F365003CEB94 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = SioChatDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CE3B3B611AC8F365003CEB94 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SioChatDemoTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SioChatDemo.app/SioChatDemo";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE3B3B621AC8F365003CEB94 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SioChatDemoTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SioChatDemo.app/SioChatDemo";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CE3B3B7C1AC8F438003CEB94 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SIOROOT)/lib/websocketpp",
|
||||
"$(SIOROOT)/lib/rapidjson/include",
|
||||
"$(SRCROOT)/boost/ios/prefix/include",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/boost/ios/build/$(CURRENT_ARCH)/";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
OTHER_LIBTOOLFLAGS = "-lboost_random -lboost_date_time -lboost_system";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SIOROOT = "$(SRCROOT)/../../../";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE3B3B7D1AC8F438003CEB94 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SIOROOT)/lib/websocketpp",
|
||||
"$(SIOROOT)/lib/rapidjson/include",
|
||||
"$(SRCROOT)/boost/ios/prefix/include",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/boost/ios/build/$(CURRENT_ARCH)/";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
OTHER_LIBTOOLFLAGS = "-lboost_random -lboost_date_time -lboost_system";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SIOROOT = "$(SRCROOT)/../../../";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
CE3B3B7F1AC8F438003CEB94 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = sioclientTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CE3B3B801AC8F438003CEB94 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = sioclientTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
CE3B3B351AC8F365003CEB94 /* Build configuration list for PBXProject "SioChatDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CE3B3B5B1AC8F365003CEB94 /* Debug */,
|
||||
CE3B3B5C1AC8F365003CEB94 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CE3B3B5D1AC8F365003CEB94 /* Build configuration list for PBXNativeTarget "SioChatDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CE3B3B5E1AC8F365003CEB94 /* Debug */,
|
||||
CE3B3B5F1AC8F365003CEB94 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CE3B3B601AC8F365003CEB94 /* Build configuration list for PBXNativeTarget "SioChatDemoTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CE3B3B611AC8F365003CEB94 /* Debug */,
|
||||
CE3B3B621AC8F365003CEB94 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CE3B3B7B1AC8F438003CEB94 /* Build configuration list for PBXNativeTarget "sioclient" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CE3B3B7C1AC8F438003CEB94 /* Debug */,
|
||||
CE3B3B7D1AC8F438003CEB94 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
CE3B3B7E1AC8F438003CEB94 /* Build configuration list for PBXNativeTarget "sioclientTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
CE3B3B7F1AC8F438003CEB94 /* Debug */,
|
||||
CE3B3B801AC8F438003CEB94 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = CE3B3B321AC8F365003CEB94 /* Project object */;
|
||||
}
|
||||
7
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
7
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:SioChatDemo.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
|
||||
<false/>
|
||||
<key>IDESourceControlProjectIdentifier</key>
|
||||
<string>F1CE472E-3AF3-4EDA-9B64-F9DD83C665BC</string>
|
||||
<key>IDESourceControlProjectName</key>
|
||||
<string>SioChatDemo</string>
|
||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||
<dict>
|
||||
<key>21C71CD5ED4B8C77974DDBAF056104F039A3B593</key>
|
||||
<string>https://github.com/socketio/socket.io-client-cpp.git</string>
|
||||
<key>7448E718372DB7A4B0D01E27524ED3F8AE51A902</key>
|
||||
<string>https://github.com/miloyip/rapidjson.git</string>
|
||||
<key>995AABD49A028E610D29FFC44D560D9DAC1EAC0B</key>
|
||||
<string>https://github.com/zaphoyd/websocketpp.git</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectPath</key>
|
||||
<string>examples/iOS/SioChatDemo/SioChatDemo.xcodeproj</string>
|
||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||
<dict>
|
||||
<key>21C71CD5ED4B8C77974DDBAF056104F039A3B593</key>
|
||||
<string>../../../../..</string>
|
||||
<key>7448E718372DB7A4B0D01E27524ED3F8AE51A902</key>
|
||||
<string>../../../../..lib/rapidjson</string>
|
||||
<key>995AABD49A028E610D29FFC44D560D9DAC1EAC0B</key>
|
||||
<string>../../../../..lib/websocketpp</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectURL</key>
|
||||
<string>https://github.com/socketio/socket.io-client-cpp.git</string>
|
||||
<key>IDESourceControlProjectVersion</key>
|
||||
<integer>111</integer>
|
||||
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||
<string>21C71CD5ED4B8C77974DDBAF056104F039A3B593</string>
|
||||
<key>IDESourceControlProjectWCConfigurations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>7448E718372DB7A4B0D01E27524ED3F8AE51A902</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>rapidjson</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>21C71CD5ED4B8C77974DDBAF056104F039A3B593</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>sioclient</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>995AABD49A028E610D29FFC44D560D9DAC1EAC0B</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>websocketpp</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
17
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/AppDelegate.h
vendored
Normal file
17
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/AppDelegate.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// AppDelegate.h
|
||||
// SioChatDemo
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
// Copyright (c) 2015 Melo Yao. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
45
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/AppDelegate.m
vendored
Normal file
45
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/AppDelegate.m
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// SioChatDemo
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
// Copyright (c) 2015 Melo Yao. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Melo Yao. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
|
||||
<rect key="frame" x="20" y="439" width="441" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SioChatDemo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
|
||||
<rect key="frame" x="20" y="140" width="441" height="43"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
|
||||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
|
||||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
|
||||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
|
||||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<point key="canvasLocation" x="548" y="455"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
12
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/CRViewController.h
vendored
Normal file
12
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/CRViewController.h
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// CRViewController.h
|
||||
// ChatRoom
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CRViewController : UIViewController
|
||||
|
||||
@end
|
||||
453
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/CRViewController.mm
vendored
Normal file
453
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/CRViewController.mm
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
//
|
||||
// CRViewController.m
|
||||
// ChatRoom
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
//
|
||||
|
||||
#import "CRViewController.h"
|
||||
#include "sio_client.h"
|
||||
|
||||
typedef enum MessageFlag
|
||||
{
|
||||
Message_System,
|
||||
Message_Other,
|
||||
Message_You
|
||||
};
|
||||
|
||||
@interface MessageItem : NSObject
|
||||
@property NSString* message;
|
||||
@property MessageFlag flag; //0 system info, 1 other message, 2 your message
|
||||
@end
|
||||
|
||||
@implementation MessageItem
|
||||
|
||||
@end
|
||||
|
||||
@interface CRViewController ()<UITableViewDataSource,UITableViewDelegate,NSURLConnectionDelegate,NSURLConnectionDataDelegate,UITextFieldDelegate>
|
||||
{
|
||||
sio::client *_io;
|
||||
NSMutableArray *_receivedMessage;
|
||||
NSMutableSet *_typingUsers;
|
||||
NSString* _name;
|
||||
NSInteger _userCount;
|
||||
NSTimer* _inputTimer;
|
||||
}
|
||||
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *typingLabel;
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UIView *loginPage;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *nickName;
|
||||
- (IBAction)onSend:(id)sender;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *sendBtn;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *messageField;
|
||||
@property (weak, nonatomic) IBOutlet UIView *messageArea;
|
||||
|
||||
-(void)onNewMessage:(NSString*) message from:(NSString*) name;
|
||||
|
||||
-(void)onUserJoined:(NSString*)user participants:(NSInteger) num;
|
||||
|
||||
-(void)onUserLeft:(NSString*) user participants:(NSInteger) num;
|
||||
|
||||
-(void)onUserTyping:(NSString*) user;
|
||||
|
||||
-(void)onUserStopTyping:(NSString*) user;
|
||||
|
||||
-(void)onLogin:(NSInteger) numParticipants;
|
||||
|
||||
-(void)onConnected;
|
||||
|
||||
-(void)onDisconnected;
|
||||
|
||||
-(void) updateUser:(NSString*)user count:(NSInteger) num joinOrLeft:(BOOL) isJoin;
|
||||
|
||||
@end
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace sio;
|
||||
|
||||
void OnNewMessage(CFTypeRef ctrl,string const& name,sio::message::ptr const& data,bool needACK,sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSString* msg = [NSString stringWithUTF8String:data->get_map()["message"]->get_string().data()];
|
||||
NSString* user = [NSString stringWithUTF8String:data->get_map()["username"]->get_string().data()];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onNewMessage:msg from:user];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnTyping(CFTypeRef ctrl,string const& name,sio::message::ptr const& data,bool needACK,sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSString* user = [NSString stringWithUTF8String:data->get_map()["username"]->get_string().data()];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onUserTyping:user];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void OnStopTyping(CFTypeRef ctrl,string const& name,sio::message::ptr const& data,bool needACK,sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSString* user = [NSString stringWithUTF8String:data->get_map()["username"]->get_string().data()];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onUserStopTyping:user];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void OnUserJoined(CFTypeRef ctrl, string const& name, sio::message::ptr const& data, bool needACK, sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSString* user = [NSString stringWithUTF8String:data->get_map()["username"]->get_string().data()];
|
||||
NSInteger num = data->get_map()["numUsers"]->get_int();
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onUserJoined:user participants:num];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void OnUserLeft(CFTypeRef ctrl, string const& name, sio::message::ptr const& data, bool needACK, sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSString* user = [NSString stringWithUTF8String:data->get_map()["username"]->get_string().data()];
|
||||
NSInteger num = data->get_map()["numUsers"]->get_int();
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onUserLeft:user participants:num];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OnLogin(CFTypeRef ctrl, string const& name, sio::message::ptr const& data, bool needACK, sio::message::list ackResp)
|
||||
{
|
||||
if(data->get_flag() == message::flag_object)
|
||||
{
|
||||
NSInteger num = data->get_map()["numUsers"]->get_int();
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onLogin:num];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void OnConnected(CFTypeRef ctrl,std::string nsp)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onConnected];
|
||||
});
|
||||
}
|
||||
|
||||
void OnFailed(CFTypeRef ctrl)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onDisconnected];
|
||||
});
|
||||
}
|
||||
|
||||
void OnClose(CFTypeRef ctrl,sio::client::close_reason const& reason)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[((__bridge CRViewController*)ctrl) onDisconnected];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@implementation CRViewController
|
||||
|
||||
-(void)awakeFromNib
|
||||
{
|
||||
_receivedMessage = [NSMutableArray array];
|
||||
_typingUsers = [NSMutableSet set];
|
||||
_io = new sio::client();
|
||||
[self.loginPage setFrame:self.view.bounds];
|
||||
[self.view addSubview:self.loginPage];
|
||||
self.nickName.enabled = YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
_io->set_socket_open_listener(std::bind(&OnConnected, (__bridge CFTypeRef)self,std::placeholders::_1));
|
||||
_io->set_close_listener(std::bind(&OnClose, (__bridge CFTypeRef)self, std::placeholders::_1));
|
||||
_io->set_fail_listener(std::bind(&OnFailed, (__bridge CFTypeRef)self));
|
||||
}
|
||||
|
||||
-(void)keyboardWillShow:(NSNotification*)notification
|
||||
{
|
||||
CGFloat height = [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size.height;
|
||||
// Animate the current view out of the way
|
||||
[UIView animateWithDuration:0.35 animations:^{
|
||||
self.messageArea.transform = CGAffineTransformMakeTranslation(0, -height);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
-(void)keyboardWillHide {
|
||||
[UIView animateWithDuration:0.35 animations:^{
|
||||
self.messageArea.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
_io->socket()->off_all();
|
||||
_io->set_open_listener(nullptr);
|
||||
_io->set_close_listener(nullptr);
|
||||
_io->close();
|
||||
}
|
||||
|
||||
-(void)onNewMessage:(NSString*) message from:(NSString*) name
|
||||
{
|
||||
MessageItem *item = [[MessageItem alloc] init];
|
||||
|
||||
item.flag = [name isEqualToString:_name]?Message_You:Message_Other;
|
||||
item.message = item.flag == Message_You? [NSString stringWithFormat:@"%@:%@",message,name]:[NSString stringWithFormat:@"%@:%@",name,message];
|
||||
[_receivedMessage addObject:item];
|
||||
[_tableView reloadData];
|
||||
|
||||
if(![_messageField isFirstResponder])
|
||||
{
|
||||
[_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[_receivedMessage count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)onUserJoined:(NSString*)user participants:(NSInteger) num
|
||||
{
|
||||
_userCount = num;
|
||||
[self updateUser:user count:num joinOrLeft:YES];
|
||||
}
|
||||
|
||||
-(void)onUserLeft:(NSString*) user participants:(NSInteger) num
|
||||
{
|
||||
[_typingUsers removeObject:user];//protective removal.
|
||||
[self updateTyping];
|
||||
_userCount = num;
|
||||
[self updateUser:user count:num joinOrLeft:NO];
|
||||
}
|
||||
|
||||
-(void)onUserTyping:(NSString*) user
|
||||
{
|
||||
[_typingUsers addObject:user];
|
||||
[self updateTyping];
|
||||
}
|
||||
|
||||
-(void)onUserStopTyping:(NSString*) user
|
||||
{
|
||||
[_typingUsers removeObject:user];
|
||||
[self updateTyping];
|
||||
}
|
||||
|
||||
-(void)onLogin:(NSInteger) numParticipants
|
||||
{
|
||||
_name = _nickName.text;
|
||||
_userCount = numParticipants;
|
||||
[self.loginPage removeFromSuperview];
|
||||
|
||||
[self updateUser:nil count:_userCount joinOrLeft:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShow:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (IBAction)onSend:(id)sender {
|
||||
if ([_messageField.text length]>0 && [_name length]>0) {
|
||||
_io->socket()->emit("new message",[_messageField.text UTF8String]);
|
||||
MessageItem *item = [[MessageItem alloc] init];
|
||||
|
||||
item.flag = Message_You;
|
||||
item.message = [NSString stringWithFormat:@"%@:You",_messageField.text];
|
||||
[_receivedMessage addObject:item];
|
||||
[_tableView reloadData];
|
||||
[_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[_receivedMessage count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
}
|
||||
|
||||
self.messageField.text = nil;
|
||||
[self.messageField resignFirstResponder];
|
||||
}
|
||||
|
||||
-(void)onConnected
|
||||
{
|
||||
_io->socket()->emit("add user", [self.nickName.text UTF8String]);
|
||||
}
|
||||
|
||||
-(void)onDisconnected
|
||||
{
|
||||
if([self.loginPage superview] == nil)
|
||||
{
|
||||
[self.view addSubview:self.loginPage];
|
||||
}
|
||||
self.nickName.enabled = YES;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
-(void) updateUser:(NSString*)user count:(NSInteger) num joinOrLeft:(BOOL) isJoin
|
||||
{
|
||||
_userCount = num;
|
||||
MessageItem *item = [[MessageItem alloc] init];
|
||||
|
||||
item.flag = Message_System;
|
||||
if (user) {
|
||||
item.message = [NSString stringWithFormat:@"%@ %@\n%@",user,isJoin?@"joined":@"left",num==1?@"there's 1 participant":[NSString stringWithFormat:@"there are %ld participants",num]];
|
||||
}
|
||||
else
|
||||
{
|
||||
item.message = [NSString stringWithFormat:@"Welcome to Socket.IO Chat-\n%@",num==1?@"there's 1 participant":[NSString stringWithFormat:@"there are %ld participants",num]];
|
||||
}
|
||||
|
||||
[_receivedMessage addObject:item];
|
||||
[_tableView reloadData];
|
||||
if(![_messageField isFirstResponder])
|
||||
{
|
||||
[_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[_receivedMessage count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) inputTimeout
|
||||
{
|
||||
_inputTimer = nil;
|
||||
_io->socket()->emit("stop typing", "");
|
||||
}
|
||||
|
||||
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
if(textField == self.messageField)
|
||||
{
|
||||
if(_inputTimer.valid)
|
||||
{
|
||||
[_inputTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
_io->socket()->emit("typing", "");
|
||||
_inputTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(inputTimeout) userInfo:nil repeats:NO];
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [_receivedMessage count];
|
||||
}
|
||||
|
||||
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
|
||||
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Msg"];
|
||||
MessageItem* item = [_receivedMessage objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = item.message;
|
||||
switch (item.flag) {
|
||||
case Message_System:
|
||||
cell.textLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[cell.textLabel setFont:[UIFont fontWithName:[cell.textLabel.font fontName] size:12]];
|
||||
break;
|
||||
case Message_Other:
|
||||
[cell.textLabel setFont:[UIFont fontWithName:[cell.textLabel.font fontName] size:15]];
|
||||
cell.textLabel.textAlignment = NSTextAlignmentLeft;
|
||||
break;
|
||||
case Message_You:
|
||||
[cell.textLabel setFont:[UIFont fontWithName:[cell.textLabel.font fontName] size:15]];
|
||||
cell.textLabel.textAlignment = NSTextAlignmentRight;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if ([self.messageField isFirstResponder]) {
|
||||
[self.messageField resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL)textFieldShouldReturn:(UITextField *)textField
|
||||
{
|
||||
if (textField == self.nickName) {
|
||||
if ([self.nickName.text length] > 0) {
|
||||
|
||||
using std::placeholders::_1;
|
||||
using std::placeholders::_2;
|
||||
using std::placeholders::_3;
|
||||
using std::placeholders::_4;
|
||||
socket::ptr socket = _io->socket();
|
||||
|
||||
socket->on("new message", std::bind(&OnNewMessage, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
socket->on("typing", std::bind(&OnTyping, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
socket->on("stop typing", std::bind(&OnStopTyping, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
socket->on("user joined", std::bind(&OnUserJoined, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
socket->on("user left", std::bind(&OnUserLeft, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
socket->on("login", std::bind(&OnLogin, (__bridge CFTypeRef)self, _1,_2,_3,_4));
|
||||
_io->connect("ws://localhost:3000");
|
||||
self.nickName.enabled = NO;
|
||||
}
|
||||
}
|
||||
else if(textField == self.messageField)
|
||||
{
|
||||
[self onSend:textField];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)updateTyping
|
||||
{
|
||||
NSString* typingMsg = nil;
|
||||
NSString* name = [_typingUsers anyObject];
|
||||
if (name) {
|
||||
if([_typingUsers count]>1)
|
||||
{
|
||||
typingMsg = [NSString stringWithFormat:@"%@ and %ld more are typing",name,[_typingUsers count]];
|
||||
}
|
||||
else
|
||||
{
|
||||
typingMsg =[NSString stringWithFormat:@"%@ is typing",name];
|
||||
}
|
||||
}
|
||||
self.typingLabel.text = typingMsg;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
delete _io;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
47
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/Info.plist
vendored
Normal file
47
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/Info.plist
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.socketio.melode.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
127
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/Main.storyboard
vendored
Normal file
127
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/Main.storyboard
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="FVA-Ip-uIE">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="4B5-FI-8YR">
|
||||
<objects>
|
||||
<viewController id="FVA-Ip-uIE" customClass="CRViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="j56-Sc-Uve">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Zd9-dA-z1N">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="396"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Msg" textLabel="c7q-ly-Hf0" style="IBUITableViewCellStyleDefault" id="13Y-SW-wci">
|
||||
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="13Y-SW-wci" id="CkG-vX-yh5">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" id="c7q-ly-Hf0">
|
||||
<rect key="frame" x="15" y="0.0" width="290" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="18"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="FVA-Ip-uIE" id="gbf-ws-uXu"/>
|
||||
<outlet property="delegate" destination="FVA-Ip-uIE" id="Y5j-aM-c5q"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<view contentMode="scaleToFill" id="yh5-ME-DKM">
|
||||
<rect key="frame" x="0.0" y="416" width="320" height="64"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Type here..." minimumFontSize="17" id="Eq9-78-qhY">
|
||||
<rect key="frame" x="8" y="26" width="250" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" returnKeyType="send"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="FVA-Ip-uIE" id="tUP-2R-seQ"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="wwz-tj-MLo">
|
||||
<rect key="frame" x="8" y="3" width="250" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
|
||||
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="WZS-UQ-rXy">
|
||||
<rect key="frame" x="266" y="30" width="46" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="18"/>
|
||||
<state key="normal" title="Send">
|
||||
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSend:" destination="FVA-Ip-uIE" eventType="touchUpInside" id="0VT-Nd-fdz"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
|
||||
<connections>
|
||||
<outlet property="loginPage" destination="FDy-KL-ozA" id="zBO-Gk-9OU"/>
|
||||
<outlet property="messageArea" destination="yh5-ME-DKM" id="nFQ-Zd-Gmx"/>
|
||||
<outlet property="messageField" destination="Eq9-78-qhY" id="HDE-p4-jGM"/>
|
||||
<outlet property="nickName" destination="Xat-ec-Oga" id="xyE-A7-aZ5"/>
|
||||
<outlet property="sendBtn" destination="WZS-UQ-rXy" id="nbZ-e0-RoK"/>
|
||||
<outlet property="tableView" destination="Zd9-dA-z1N" id="Ekd-Is-nd5"/>
|
||||
<outlet property="typingLabel" destination="wwz-tj-MLo" id="GxR-Bb-TGT"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="X4s-OP-QGg" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<view contentMode="scaleToFill" id="FDy-KL-ozA">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Your Nickname:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Vbn-qK-OOg">
|
||||
<rect key="frame" x="40" y="200" width="240" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="20"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" id="Xat-ec-Oga">
|
||||
<rect key="frame" x="40" y="269" width="240" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" returnKeyType="done"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="FVA-Ip-uIE" id="fDd-Hi-o32"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="99" y="-451"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
||||
16
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/main.m
vendored
Normal file
16
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemo/main.m
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// main.m
|
||||
// SioChatDemo
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
// Copyright (c) 2015 Melo Yao. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
24
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemoTests/Info.plist
vendored
Normal file
24
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemoTests/Info.plist
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.socketio.melode.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
40
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemoTests/SioChatDemoTests.m
vendored
Normal file
40
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/SioChatDemoTests/SioChatDemoTests.m
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// SioChatDemoTests.m
|
||||
// SioChatDemoTests
|
||||
//
|
||||
// Created by Melo Yao on 3/30/15.
|
||||
// Copyright (c) 2015 Melo Yao. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface SioChatDemoTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation SioChatDemoTests
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testExample {
|
||||
// This is an example of a functional test case.
|
||||
XCTAssert(YES, @"Pass");
|
||||
}
|
||||
|
||||
- (void)testPerformanceExample {
|
||||
// This is an example of a performance test case.
|
||||
[self measureBlock:^{
|
||||
// Put the code you want to measure the time of here.
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
4
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/boost/.gitignore
vendored
Normal file
4
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/boost/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
ios/*
|
||||
osx/*
|
||||
src/*
|
||||
boost_*
|
||||
378
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/boost/boost.sh
vendored
Normal file
378
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/boost/boost.sh
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
#===============================================================================
|
||||
# Filename: boost.sh
|
||||
# Author: Pete Goodliffe
|
||||
# Copyright: (c) Copyright 2009 Pete Goodliffe
|
||||
# Licence: Please feel free to use this, with attribution
|
||||
# Modified version
|
||||
#===============================================================================
|
||||
#
|
||||
# Builds a Boost framework for the iPhone.
|
||||
# Creates a set of universal libraries that can be used on an iPhone and in the
|
||||
# iPhone simulator. Then creates a pseudo-framework to make using boost in Xcode
|
||||
# less painful.
|
||||
#
|
||||
# To configure the script, define:
|
||||
# BOOST_LIBS: which libraries to build
|
||||
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 5.1)
|
||||
#
|
||||
# Then go get the source tar.bz of the boost you want to build, shove it in the
|
||||
# same directory as this script, and run "./boost.sh". Grab a cuppa. And voila.
|
||||
#===============================================================================
|
||||
|
||||
: ${BOOST_LIBS:="random regex graph random chrono thread signals filesystem system date_time"}
|
||||
: ${IPHONE_SDKVERSION:=`xcodebuild -showsdks | grep iphoneos | egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`}
|
||||
: ${OSX_SDKVERSION:=10.8}
|
||||
: ${XCODE_ROOT:=`xcode-select -print-path`}
|
||||
: ${EXTRA_CPPFLAGS:="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -std=c++11 -stdlib=libc++"}
|
||||
|
||||
# The EXTRA_CPPFLAGS definition works around a thread race issue in
|
||||
# shared_ptr. I encountered this historically and have not verified that
|
||||
# the fix is no longer required. Without using the posix thread primitives
|
||||
# an invalid compare-and-swap ARM instruction (non-thread-safe) was used for the
|
||||
# shared_ptr use count causing nasty and subtle bugs.
|
||||
#
|
||||
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
|
||||
|
||||
: ${TARBALLDIR:=`pwd`}
|
||||
: ${SRCDIR:=`pwd`/src}
|
||||
: ${IOSBUILDDIR:=`pwd`/ios/build}
|
||||
: ${OSXBUILDDIR:=`pwd`/osx/build}
|
||||
: ${PREFIXDIR:=`pwd`/ios/prefix}
|
||||
: ${IOSFRAMEWORKDIR:=`pwd`/ios/framework}
|
||||
: ${OSXFRAMEWORKDIR:=`pwd`/osx/framework}
|
||||
: ${COMPILER:="clang++"}
|
||||
|
||||
: ${BOOST_VERSION:=1.55.0}
|
||||
: ${BOOST_VERSION2:=1_55_0}
|
||||
|
||||
BOOST_TARBALL=$TARBALLDIR/boost_$BOOST_VERSION2.tar.bz2
|
||||
BOOST_SRC=$SRCDIR/boost_${BOOST_VERSION2}
|
||||
|
||||
#===============================================================================
|
||||
ARM_DEV_CMD="xcrun --sdk iphoneos"
|
||||
SIM_DEV_CMD="xcrun --sdk iphonesimulator"
|
||||
OSX_DEV_CMD="xcrun --sdk macosx"
|
||||
|
||||
ARM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_arm.a
|
||||
SIM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_x86.a
|
||||
|
||||
#===============================================================================
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Functions
|
||||
#===============================================================================
|
||||
|
||||
abort()
|
||||
{
|
||||
echo
|
||||
echo "Aborted: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
doneSection()
|
||||
{
|
||||
echo
|
||||
echo "================================================================="
|
||||
echo "Done"
|
||||
echo
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
cleanEverythingReadyToStart()
|
||||
{
|
||||
echo Cleaning everything before we start to build...
|
||||
|
||||
rm -rf iphone-build iphonesim-build osx-build
|
||||
rm -rf $IOSBUILDDIR
|
||||
rm -rf $OSXBUILDDIR
|
||||
rm -rf $PREFIXDIR
|
||||
rm -rf $IOSFRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
rm -rf $OSXFRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
downloadBoost()
|
||||
{
|
||||
if [ ! -s $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 ]; then
|
||||
echo "Downloading boost ${BOOST_VERSION}"
|
||||
curl -L -o $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION2}.tar.bz2/download
|
||||
fi
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
unpackBoost()
|
||||
{
|
||||
[ -f "$BOOST_TARBALL" ] || abort "Source tarball missing."
|
||||
|
||||
echo Unpacking boost into $SRCDIR...
|
||||
|
||||
[ -d $SRCDIR ] || mkdir -p $SRCDIR
|
||||
[ -d $BOOST_SRC ] || ( cd $SRCDIR; tar xfj $BOOST_TARBALL )
|
||||
[ -d $BOOST_SRC ] && echo " ...unpacked as $BOOST_SRC"
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
restoreBoost()
|
||||
{
|
||||
cp $BOOST_SRC/tools/build/v2/user-config.jam-bk $BOOST_SRC/tools/build/v2/user-config.jam
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
updateBoost()
|
||||
{
|
||||
echo Updating boost into $BOOST_SRC...
|
||||
|
||||
cp $BOOST_SRC/tools/build/v2/user-config.jam $BOOST_SRC/tools/build/v2/user-config.jam-bk
|
||||
|
||||
cat >> $BOOST_SRC/tools/build/v2/user-config.jam <<EOF
|
||||
using darwin : ${IPHONE_SDKVERSION}~iphone
|
||||
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch armv6 -arch armv7 -arch armv7s -arch arm64 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
|
||||
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
|
||||
: <architecture>arm <target-os>iphone
|
||||
;
|
||||
using darwin : ${IPHONE_SDKVERSION}~iphonesim
|
||||
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch i386 -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
|
||||
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
|
||||
: <architecture>x86 <target-os>iphone
|
||||
;
|
||||
EOF
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
inventMissingHeaders()
|
||||
{
|
||||
# These files are missing in the ARM iPhoneOS SDK, but they are in the simulator.
|
||||
# They are supported on the device, so we copy them from x86 SDK to a staging area
|
||||
# to use them on ARM, too.
|
||||
echo Invent missing headers
|
||||
|
||||
cp $XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDKVERSION}.sdk/usr/include/{crt_externs,bzlib}.h $BOOST_SRC
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
bootstrapBoost()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g")
|
||||
echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)"
|
||||
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
buildBoostForIPhoneOS()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
# Install this one so we can copy the includes for the frameworks...
|
||||
./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage
|
||||
./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install
|
||||
doneSection
|
||||
|
||||
./bjam -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin-${IPHONE_SDKVERSION}~iphonesim architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage
|
||||
doneSection
|
||||
|
||||
# ./b2 -j16 --build-dir=osx-build --stagedir=osx-build/stage toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++" link=static threading=multi stage
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
|
||||
scrunchAllLibsTogetherInOneLibPerPlatform()
|
||||
{
|
||||
cd $BOOST_SRC
|
||||
|
||||
mkdir -p $IOSBUILDDIR/armv6/obj
|
||||
mkdir -p $IOSBUILDDIR/armv7/obj
|
||||
mkdir -p $IOSBUILDDIR/armv7s/obj
|
||||
mkdir -p $IOSBUILDDIR/arm64/obj
|
||||
mkdir -p $IOSBUILDDIR/i386/obj
|
||||
mkdir -p $IOSBUILDDIR/x86_64/obj
|
||||
|
||||
mkdir -p $OSXBUILDDIR/i386/obj
|
||||
mkdir -p $OSXBUILDDIR/x86_64/obj
|
||||
|
||||
ALL_LIBS=""
|
||||
|
||||
echo Splitting all existing fat binaries...
|
||||
|
||||
for NAME in $BOOST_LIBS; do
|
||||
ALL_LIBS="$ALL_LIBS libboost_$NAME.a"
|
||||
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv6 -o $IOSBUILDDIR/armv6/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7 -o $IOSBUILDDIR/armv7/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7s -o $IOSBUILDDIR/armv7s/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin arm64 -o $IOSBUILDDIR/arm64/libboost_$NAME.a
|
||||
|
||||
$ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin i386 -o $IOSBUILDDIR/i386/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $IOSBUILDDIR/x86_64/libboost_$NAME.a
|
||||
|
||||
$ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin i386 -o $OSXBUILDDIR/i386/libboost_$NAME.a
|
||||
$ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $OSXBUILDDIR/x86_64/libboost_$NAME.a
|
||||
done
|
||||
|
||||
echo "Decomposing each architecture's .a files"
|
||||
|
||||
for NAME in $ALL_LIBS; do
|
||||
echo Decomposing $NAME...
|
||||
(cd $IOSBUILDDIR/armv6/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/armv7/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/armv7s/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/arm64/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/i386/obj; ar -x ../$NAME );
|
||||
(cd $IOSBUILDDIR/x86_64/obj; ar -x ../$NAME );
|
||||
|
||||
(cd $OSXBUILDDIR/i386/obj; ar -x ../$NAME );
|
||||
(cd $OSXBUILDDIR/x86_64/obj; ar -x ../$NAME );
|
||||
done
|
||||
|
||||
echo "Linking each architecture into an uberlib ($ALL_LIBS => libboost.a )"
|
||||
|
||||
rm $IOSBUILDDIR/*/libboost.a
|
||||
|
||||
echo ...armv6
|
||||
(cd $IOSBUILDDIR/armv6; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...armv7
|
||||
(cd $IOSBUILDDIR/armv7; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...armv7s
|
||||
(cd $IOSBUILDDIR/armv7s; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...arm64
|
||||
(cd $IOSBUILDDIR/arm64; $ARM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...i386
|
||||
(cd $IOSBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
echo ...x86_64
|
||||
(cd $IOSBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
|
||||
rm $OSXBUILDDIR/*/libboost.a
|
||||
echo ...osx-i386
|
||||
(cd $OSXBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
|
||||
echo ...x86_64
|
||||
(cd $OSXBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; )
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
buildFramework()
|
||||
{
|
||||
: ${1:?}
|
||||
FRAMEWORKDIR=$1
|
||||
BUILDDIR=$2
|
||||
|
||||
VERSION_TYPE=Alpha
|
||||
FRAMEWORK_NAME=boost
|
||||
FRAMEWORK_VERSION=A
|
||||
|
||||
FRAMEWORK_CURRENT_VERSION=$BOOST_VERSION
|
||||
FRAMEWORK_COMPATIBILITY_VERSION=$BOOST_VERSION
|
||||
|
||||
FRAMEWORK_BUNDLE=$FRAMEWORKDIR/$FRAMEWORK_NAME.framework
|
||||
echo "Framework: Building $FRAMEWORK_BUNDLE from $BUILDDIR..."
|
||||
|
||||
rm -rf $FRAMEWORK_BUNDLE
|
||||
|
||||
echo "Framework: Setting up directories..."
|
||||
mkdir -p $FRAMEWORK_BUNDLE
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Resources
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Headers
|
||||
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Documentation
|
||||
|
||||
echo "Framework: Creating symlinks..."
|
||||
ln -s $FRAMEWORK_VERSION $FRAMEWORK_BUNDLE/Versions/Current
|
||||
ln -s Versions/Current/Headers $FRAMEWORK_BUNDLE/Headers
|
||||
ln -s Versions/Current/Resources $FRAMEWORK_BUNDLE/Resources
|
||||
ln -s Versions/Current/Documentation $FRAMEWORK_BUNDLE/Documentation
|
||||
ln -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_BUNDLE/$FRAMEWORK_NAME
|
||||
|
||||
FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_NAME
|
||||
|
||||
echo "Lipoing library into $FRAMEWORK_INSTALL_NAME..."
|
||||
$ARM_DEV_CMD lipo -create $BUILDDIR/*/libboost.a -o "$FRAMEWORK_INSTALL_NAME" || abort "Lipo $1 failed"
|
||||
|
||||
echo "Framework: Copying includes..."
|
||||
cp -r $PREFIXDIR/include/boost/* $FRAMEWORK_BUNDLE/Headers/
|
||||
|
||||
echo "Framework: Creating plist..."
|
||||
cat > $FRAMEWORK_BUNDLE/Resources/Info.plist <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${FRAMEWORK_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.boost</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${FRAMEWORK_CURRENT_VERSION}</string>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
doneSection
|
||||
}
|
||||
|
||||
#===============================================================================
|
||||
# Execution starts here
|
||||
#===============================================================================
|
||||
|
||||
mkdir -p $IOSBUILDDIR
|
||||
|
||||
cleanEverythingReadyToStart #may want to comment if repeatedly running during dev
|
||||
restoreBoost
|
||||
|
||||
echo "BOOST_VERSION: $BOOST_VERSION"
|
||||
echo "BOOST_LIBS: $BOOST_LIBS"
|
||||
echo "BOOST_SRC: $BOOST_SRC"
|
||||
echo "IOSBUILDDIR: $IOSBUILDDIR"
|
||||
echo "OSXBUILDDIR: $OSXBUILDDIR"
|
||||
echo "PREFIXDIR: $PREFIXDIR"
|
||||
echo "IOSFRAMEWORKDIR: $IOSFRAMEWORKDIR"
|
||||
echo "OSXFRAMEWORKDIR: $OSXFRAMEWORKDIR"
|
||||
echo "IPHONE_SDKVERSION: $IPHONE_SDKVERSION"
|
||||
echo "XCODE_ROOT: $XCODE_ROOT"
|
||||
echo "COMPILER: $COMPILER"
|
||||
echo
|
||||
|
||||
downloadBoost
|
||||
unpackBoost
|
||||
inventMissingHeaders
|
||||
bootstrapBoost
|
||||
updateBoost
|
||||
buildBoostForIPhoneOS
|
||||
scrunchAllLibsTogetherInOneLibPerPlatform
|
||||
buildFramework $IOSFRAMEWORKDIR $IOSBUILDDIR
|
||||
buildFramework $OSXFRAMEWORKDIR $OSXBUILDDIR
|
||||
|
||||
restoreBoost
|
||||
|
||||
echo "Completed successfully"
|
||||
|
||||
#===============================================================================
|
||||
24
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/sioclientTests/Info.plist
vendored
Normal file
24
third_party/socket.io-client-cpp/examples/iOS/SioChatDemo/sioclientTests/Info.plist
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.socketio.melode.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
118
third_party/socket.io-client-cpp/lib/asio/.appveyor.yml
vendored
Normal file
118
third_party/socket.io-client-cpp/lib/asio/.appveyor.yml
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
version: "{branch} (#{build})"
|
||||
|
||||
image:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019
|
||||
|
||||
environment:
|
||||
DEBUG: 1
|
||||
WARNINGS: 1
|
||||
matrix:
|
||||
- STANDALONE: 1
|
||||
HEADER_ONLY: 1
|
||||
MSVC: 1
|
||||
- STANDALONE: 1
|
||||
SEPARATE_COMPILATION: 1
|
||||
MSVC: 1
|
||||
- STANDALONE: 1
|
||||
MINGW: 1
|
||||
- STANDALONE: 1
|
||||
CXXLATEST: 1
|
||||
MSVC: 1
|
||||
- STANDALONE: 1
|
||||
HEADER_ONLY: 1
|
||||
WIN9X: 1
|
||||
MSVC: 1
|
||||
- STANDALONE: 1
|
||||
SEPARATE_COMPILATION: 1
|
||||
WIN9X: 1
|
||||
MSVC: 1
|
||||
- USING_BOOST: 1
|
||||
HEADER_ONLY: 1
|
||||
MSVC: 1
|
||||
- USING_BOOST: 1
|
||||
SEPARATE_COMPILATION: 1
|
||||
MSVC: 1
|
||||
- USING_BOOST: 1
|
||||
MINGW: 1
|
||||
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2015
|
||||
MSVC: 1
|
||||
environment:
|
||||
BOOSTDIR: C:\Libraries\boost_1_67_0
|
||||
build_script:
|
||||
- call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
|
||||
- cd asio\src
|
||||
- nmake -f Makefile.msc
|
||||
- nmake -f Makefile.msc check
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2017
|
||||
MSVC: 1
|
||||
environment:
|
||||
BOOSTDIR: C:\Libraries\boost_1_69_0
|
||||
_WIN32_WINNT: 0x0603
|
||||
build_script:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
|
||||
- cd asio\src
|
||||
- nmake -f Makefile.msc
|
||||
- nmake -f Makefile.msc check
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2019
|
||||
MSVC: 1
|
||||
environment:
|
||||
BOOSTDIR: C:\Libraries\boost_1_83_0
|
||||
_WIN32_WINNT: 0x0A00
|
||||
build_script:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
|
||||
- cd asio\src
|
||||
- nmake -f Makefile.msc
|
||||
- nmake -f Makefile.msc check
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2019
|
||||
MINGW: 1
|
||||
environment:
|
||||
BOOSTDIR: C:/Libraries/boost_1_83_0
|
||||
build_script:
|
||||
- PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\msys64\usr\bin;%PATH%
|
||||
- cd asio\src
|
||||
- mingw32-make -f Makefile.mgw
|
||||
- mingw32-make -f Makefile.mgw check
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- image: Visual Studio 2015
|
||||
HEADER_ONLY: 1
|
||||
- image: Visual Studio 2015
|
||||
CXXLATEST: 1
|
||||
- image: Visual Studio 2015
|
||||
WIN9X: 1
|
||||
- image: Visual Studio 2015
|
||||
USING_BOOST: 1
|
||||
- image: Visual Studio 2015
|
||||
MINGW: 1
|
||||
- image: Visual Studio 2017
|
||||
SEPARATE_COMPILATION: 1
|
||||
- image: Visual Studio 2017
|
||||
CXXLATEST: 1
|
||||
- image: Visual Studio 2017
|
||||
WIN9X: 1
|
||||
- image: Visual Studio 2017
|
||||
USING_BOOST: 1
|
||||
- image: Visual Studio 2017
|
||||
MINGW: 1
|
||||
- image: Visual Studio 2019
|
||||
HEADER_ONLY: 1
|
||||
- image: Visual Studio 2019
|
||||
WIN9X: 1
|
||||
16
third_party/socket.io-client-cpp/lib/asio/.cirrus.yml
vendored
Normal file
16
third_party/socket.io-client-cpp/lib/asio/.cirrus.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-0
|
||||
cpu: 1
|
||||
|
||||
env:
|
||||
CXXFLAGS: -std=c++14 -Wall -Wextra -O2
|
||||
|
||||
task:
|
||||
install_script:
|
||||
- pkg install -y autoconf automake pkgconf
|
||||
build_script:
|
||||
- cd asio
|
||||
- ./autogen.sh
|
||||
- ./configure --with-boost=no
|
||||
- make
|
||||
- make check
|
||||
343
third_party/socket.io-client-cpp/lib/asio/.github/workflows/ci.yml
vendored
Normal file
343
third_party/socket.io-client-cpp/lib/asio/.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
name: asio CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, citest-* ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build-type: ['sanity']
|
||||
runs-on: [ubuntu-20.04, ubuntu-22.04, macos-latest]
|
||||
compiler: [g++-8, g++-9, g++-10, g++-12, clang++-10, clang++-14, g++]
|
||||
cxx-std: ['c++11', 'c++14', 'c++17', 'c++2a', 'c++20']
|
||||
separate-compilation: ['', '--enable-separate-compilation']
|
||||
optim-level: ['-O0']
|
||||
no-deprecated: ['']
|
||||
select-reactor: ['', '-DASIO_DISABLE_EPOLL', '-DASIO_DISABLE_KQUEUE']
|
||||
handler-tracking: ['']
|
||||
boost: ['']
|
||||
boost-url: ['']
|
||||
exclude:
|
||||
# New compilers don't run on ubuntu 20.04
|
||||
- runs-on: ubuntu-20.04
|
||||
compiler: g++-12
|
||||
- runs-on: ubuntu-20.04
|
||||
compiler: clang++-14
|
||||
# Older compilers don't run on ubuntu 22.04
|
||||
- runs-on: ubuntu-22.04
|
||||
compiler: g++-8
|
||||
- runs-on: ubuntu-22.04
|
||||
compiler: clang++-10
|
||||
# Unversioned g++ doesn't run on ubuntu
|
||||
- runs-on: ubuntu-20.04
|
||||
compiler: g++
|
||||
- runs-on: ubuntu-22.04
|
||||
compiler: g++
|
||||
# Versioned g++ and clang++ don't run on macOS
|
||||
- runs-on: macos-latest
|
||||
compiler: g++-8
|
||||
- runs-on: macos-latest
|
||||
compiler: g++-9
|
||||
- runs-on: macos-latest
|
||||
compiler: g++-10
|
||||
- runs-on: macos-latest
|
||||
compiler: g++-12
|
||||
- runs-on: macos-latest
|
||||
compiler: clang++-10
|
||||
- runs-on: macos-latest
|
||||
compiler: clang++-14
|
||||
# Older compilers don't support newer std variants
|
||||
- compiler: g++-8
|
||||
cxx-std: c++20
|
||||
- compiler: g++-9
|
||||
cxx-std: c++20
|
||||
- compiler: g++-10
|
||||
cxx-std: c++2a
|
||||
- compiler: g++-12
|
||||
cxx-std: c++2a
|
||||
- compiler: clang++-10
|
||||
cxx-std: c++20
|
||||
- compiler: clang++-14
|
||||
cxx-std: c++20
|
||||
- compiler: clang++-14
|
||||
cxx-std: c++2a
|
||||
- runs-on: macos-latest
|
||||
cxx-std: c++20
|
||||
# Specifying the select reactor is OS-specific
|
||||
- runs-on: ubuntu-20.04
|
||||
select-reactor: -DASIO_DISABLE_KQUEUE
|
||||
- runs-on: ubuntu-22.04
|
||||
select-reactor: -DASIO_DISABLE_KQUEUE
|
||||
- runs-on: macos-latest
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
# Trim builds that use separate compilation
|
||||
- compiler: g++-8
|
||||
separate-compilation: --enable-separate-compilation
|
||||
- compiler: g++-9
|
||||
separate-compilation: --enable-separate-compilation
|
||||
- compiler: g++-10
|
||||
separate-compilation: --enable-separate-compilation
|
||||
- runs-on: macos-latest
|
||||
cxx-std: c++14
|
||||
separate-compilation: --enable-separate-compilation
|
||||
- runs-on: macos-latest
|
||||
cxx-std: c++17
|
||||
separate-compilation: --enable-separate-compilation
|
||||
# Trim builds that use select reactor
|
||||
- compiler: g++-8
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
- compiler: g++-9
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
- compiler: g++-10
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
include:
|
||||
#
|
||||
# Linux / g++-12 -std=c++20 -fcoroutines / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-22.04
|
||||
compiler: g++-12
|
||||
cxx-std: c++20 -fcoroutines
|
||||
optim-level: -O2
|
||||
#
|
||||
# Linux / g++-12 -std=c++17 / -O2 / boost 1.76
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-22.04
|
||||
compiler: g++-12
|
||||
cxx-std: c++17
|
||||
optim-level: -O2
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_76_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2
|
||||
#
|
||||
# Linux / g++-10 / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
optim-level: -O2
|
||||
#
|
||||
# Linux / g++-10 / -O0 / standalone / handler tracking
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
optim-level: -O0
|
||||
handler-tracking: -DASIO_ENABLE_HANDLER_TRACKING
|
||||
#
|
||||
# Linux / g++-10 / -O0 / standalone / epoll disabled
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
optim-level: -O0
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
#
|
||||
# Linux / g++-10 / -O0 / standalone / separate compilation / handler tracking
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
handler-tracking: -DASIO_ENABLE_HANDLER_TRACKING
|
||||
#
|
||||
# Linux / g++-10 / -O0 / standalone / separate compilation / epoll disabled
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
#
|
||||
# Linux / g++-10 / -O2 / boost 1.83
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
optim-level: -O2
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
#
|
||||
# Linux / g++-10 / -O0 / boost 1.83 / epoll disabled
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
optim-level: -O0
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
select-reactor: -DASIO_DISABLE_EPOLL
|
||||
#
|
||||
# Linux / g++-10 / -O0 / boost 1.83 / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-10
|
||||
cxx-std: c++14
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
#
|
||||
# Linux / g++-8 / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-8
|
||||
cxx-std: c++11
|
||||
optim-level: -O2
|
||||
#
|
||||
# Linux / g++-8 / -O0 / standalone / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-8
|
||||
cxx-std: c++11
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
#
|
||||
# Linux / g++-8 -std=c++11 / -O2 / boost 1.83
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: g++-8
|
||||
cxx-std: c++11
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O2
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
#
|
||||
# Linux / clang++-14 -std=c++2a / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-22.04
|
||||
compiler: clang++-14
|
||||
cxx-std: c++2a
|
||||
cxx-stdlib: -stdlib=libc++
|
||||
optim-level: -O2
|
||||
#
|
||||
# Linux / clang++-14 -std=c++11 / -O0 / standalone / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-22.04
|
||||
compiler: clang++-14
|
||||
cxx-std: c++11
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
#
|
||||
# Linux / clang++-14 -std=c++20 / -O2 / standalone / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-22.04
|
||||
compiler: clang++-14
|
||||
cxx-std: c++20
|
||||
cxx-stdlib: -stdlib=libc++
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O2
|
||||
#
|
||||
# Linux / clang++-10 -std=c++11 / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: ubuntu-20.04
|
||||
compiler: clang++-10
|
||||
cxx-std: c++11
|
||||
optim-level: -O2
|
||||
#
|
||||
# macOS / c++2a -fcoroutines-ts / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++2a -fcoroutines-ts
|
||||
optim-level: -O2
|
||||
#
|
||||
# macOS / c++11 / -O2 / standalone
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++11
|
||||
optim-level: -O2
|
||||
#
|
||||
# macOS / c++11 / -O0 / standalone / kqueue disabled
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++11
|
||||
optim-level: -O0
|
||||
select-reactor: -DASIO_DISABLE_KQUEUE
|
||||
#
|
||||
# macOS / c++11 / -O0 / standalone / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++11
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
#
|
||||
# macOS / c++11 / -O2 / boost 1.83
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++11
|
||||
optim-level: -O2
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
#
|
||||
# macOS / c++11 / -O2 / boost 1.83 / separate compilation
|
||||
#
|
||||
- build-type: full
|
||||
runs-on: macos-latest
|
||||
compiler: g++
|
||||
cxx-std: c++11
|
||||
separate-compilation: --enable-separate-compilation
|
||||
optim-level: -O0
|
||||
with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_83_0
|
||||
boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
CXXFLAGS: -std=${{ matrix.cxx-std }} ${{ matrix.cxx-stdlib }} ${{ matrix.optim-level }} -Wall -Wextra ${{ matrix.no-deprecated }} ${{ matrix.select-reactor }} ${{ matrix.handler-tracking }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install autotools
|
||||
if: startsWith(matrix.runs-on, 'macos')
|
||||
run: brew install automake
|
||||
- name: Install compiler
|
||||
if: startsWith(matrix.runs-on, 'ubuntu')
|
||||
run: sudo apt-get install -y ${{ matrix.compiler }}
|
||||
- name: Install boost
|
||||
if: startsWith(matrix.with-boost, '--with-boost=$GITHUB_WORKSPACE')
|
||||
run: |
|
||||
wget --quiet -O - ${{ matrix.boost-url }} | tar -xj
|
||||
- name: Configure
|
||||
working-directory: asio
|
||||
run: |
|
||||
./autogen.sh
|
||||
./configure ${{ matrix.separate-compilation }} ${{ matrix.with-boost }}
|
||||
- name: Line length check
|
||||
working-directory: asio
|
||||
run: perl ./boostify.pl --includes-only
|
||||
- name: Sanity check
|
||||
if: startsWith(matrix.build-type, 'sanity')
|
||||
working-directory: asio/src/tests
|
||||
run: make unit/io_context.log unit/ip/tcp.log unit/ts/net.log
|
||||
- name: Build
|
||||
if: startsWith(matrix.build-type, 'full')
|
||||
working-directory: asio
|
||||
run: make && make check
|
||||
3
third_party/socket.io-client-cpp/lib/asio/.gitignore
vendored
Normal file
3
third_party/socket.io-client-cpp/lib/asio/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*.cpp
|
||||
/*.hpp
|
||||
/boost
|
||||
24
third_party/socket.io-client-cpp/lib/asio/asio/.gitignore
vendored
Normal file
24
third_party/socket.io-client-cpp/lib/asio/asio/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
asio.pc
|
||||
autom4te.cache
|
||||
compile
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
test-driver
|
||||
/doc
|
||||
/lib
|
||||
/boostified
|
||||
/tsified
|
||||
*.gz
|
||||
*.bz2
|
||||
*.zip
|
||||
/*.cpp
|
||||
/*.hpp
|
||||
4
third_party/socket.io-client-cpp/lib/asio/asio/COPYING
vendored
Normal file
4
third_party/socket.io-client-cpp/lib/asio/asio/COPYING
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
5
third_party/socket.io-client-cpp/lib/asio/asio/INSTALL
vendored
Normal file
5
third_party/socket.io-client-cpp/lib/asio/asio/INSTALL
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
See doc/index.html for information on:
|
||||
- External dependencies
|
||||
- Using, building, and configuring Asio
|
||||
- Supported platforms
|
||||
- How to build the tests and examples
|
||||
23
third_party/socket.io-client-cpp/lib/asio/asio/LICENSE_1_0.txt
vendored
Normal file
23
third_party/socket.io-client-cpp/lib/asio/asio/LICENSE_1_0.txt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
22
third_party/socket.io-client-cpp/lib/asio/asio/Makefile.am
vendored
Normal file
22
third_party/socket.io-client-cpp/lib/asio/asio/Makefile.am
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
AUTOMAKE_OPTIONS = foreign dist-bzip2 dist-zip
|
||||
|
||||
pkgconfig_DATA = asio.pc
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
SUBDIRS = include src
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
$(srcdir)/aclocal.m4 \
|
||||
$(srcdir)/configure \
|
||||
$(srcdir)/config.guess \
|
||||
$(srcdir)/config.sub \
|
||||
$(srcdir)/depcomp \
|
||||
$(srcdir)/install-sh \
|
||||
$(srcdir)/missing \
|
||||
$(srcdir)/mkinstalldirs \
|
||||
$(srcdir)/Makefile.in \
|
||||
asio-*.tar.gz
|
||||
|
||||
EXTRA_DIST = \
|
||||
LICENSE_1_0.txt \
|
||||
doc
|
||||
4
third_party/socket.io-client-cpp/lib/asio/asio/README
vendored
Normal file
4
third_party/socket.io-client-cpp/lib/asio/asio/README
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
asio version 1.31.0
|
||||
Released Monday, 05 August 2024.
|
||||
|
||||
See doc/index.html for API documentation and a tutorial.
|
||||
7116
third_party/socket.io-client-cpp/lib/asio/asio/asio.manifest
vendored
Normal file
7116
third_party/socket.io-client-cpp/lib/asio/asio/asio.manifest
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
third_party/socket.io-client-cpp/lib/asio/asio/asio.pc.in
vendored
Normal file
11
third_party/socket.io-client-cpp/lib/asio/asio/asio.pc.in
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: @PACKAGE_NAME@
|
||||
Description: A cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
|
||||
Version: @PACKAGE_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
Lflags:
|
||||
Requires:
|
||||
Requires.private:
|
||||
55
third_party/socket.io-client-cpp/lib/asio/asio/autogen.sh
vendored
Executable file
55
third_party/socket.io-client-cpp/lib/asio/asio/autogen.sh
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Helps bootstrapping the application when checked out from CVS.
|
||||
# Requires GNU autoconf, GNU automake and GNU which.
|
||||
#
|
||||
# Copyright (C) 2004, by
|
||||
#
|
||||
# Carlo Wood, Run on IRC <carlo@alinoe.com>
|
||||
# RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
|
||||
# Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
|
||||
#
|
||||
|
||||
# Do sanity checks.
|
||||
# Directory check.
|
||||
if [ ! -f autogen.sh ]; then
|
||||
echo "Run ./autogen.sh from the directory it exists in."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AUTOMAKE=${AUTOMAKE:-automake}
|
||||
ACLOCAL=${ACLOCAL:-aclocal}
|
||||
AUTOCONF=${AUTOCONF:-autoconf}
|
||||
|
||||
($AUTOCONF --version) >/dev/null 2>/dev/null || (echo "You need GNU autoconf to install from CVS (ftp://ftp.gnu.org/gnu/autoconf/)"; exit 1) || exit 1
|
||||
($AUTOMAKE --version) >/dev/null 2>/dev/null || (echo "You need GNU automake 1.7 or higher to install from CVS (ftp://ftp.gnu.org/gnu/automake/)"; exit 1) || exit 1
|
||||
|
||||
# Determine the version of automake.
|
||||
automake_version=`$AUTOMAKE --version | head -n 1 | sed -e 's/[^12]*\([12]\.[0-9][^ ]*\).*/\1/'`
|
||||
automake_major=`echo $automake_version | cut -f1 -d.`
|
||||
automake_minor=`echo $automake_version | cut -f2 -d.`
|
||||
automake_version_number=`expr "$automake_major" \* 1000 \+ "$automake_minor"`
|
||||
|
||||
# Require automake 1.7.
|
||||
if expr "1007" \> "$automake_version_number" >/dev/null; then
|
||||
$AUTOMAKE --version | head -n 1
|
||||
echo ""
|
||||
echo "Fatal error: automake 1.7 or higher is required. Please set \$AUTOMAKE"
|
||||
echo "to point to a newer automake, or upgrade."
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run()
|
||||
{
|
||||
echo "Running $1 ..."
|
||||
$1
|
||||
}
|
||||
|
||||
# This is needed when someone just upgraded automake and this cache is still generated by an old version.
|
||||
rm -rf autom4te.cache config.cache
|
||||
|
||||
run "$ACLOCAL"
|
||||
run "$AUTOCONF"
|
||||
run "$AUTOMAKE --add-missing --foreign"
|
||||
|
||||
7761
third_party/socket.io-client-cpp/lib/asio/asio/boost_asio.manifest
vendored
Normal file
7761
third_party/socket.io-client-cpp/lib/asio/asio/boost_asio.manifest
vendored
Normal file
File diff suppressed because it is too large
Load Diff
700
third_party/socket.io-client-cpp/lib/asio/asio/boostify.pl
vendored
Executable file
700
third_party/socket.io-client-cpp/lib/asio/asio/boostify.pl
vendored
Executable file
@@ -0,0 +1,700 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use File::Path;
|
||||
|
||||
our $boost_dir = "boostified";
|
||||
our $bad_lines = 0;
|
||||
|
||||
sub print_line
|
||||
{
|
||||
my ($output, $line, $from, $lineno) = @_;
|
||||
|
||||
# Warn if the resulting line is >80 characters wide.
|
||||
if (length($line) > 80)
|
||||
{
|
||||
if ($from =~ /\.[chi]pp$/)
|
||||
{
|
||||
++$bad_lines;
|
||||
print("Warning: $from:$lineno: output >80 characters wide.\n");
|
||||
}
|
||||
}
|
||||
|
||||
# Write the output.
|
||||
print($output $line . "\n");
|
||||
}
|
||||
|
||||
sub source_contains_asio_thread_usage
|
||||
{
|
||||
my ($from) = @_;
|
||||
|
||||
# Open the input file.
|
||||
open(my $input, "<$from") or die("Can't open $from for reading");
|
||||
|
||||
# Check file for use of asio::thread.
|
||||
while (my $line = <$input>)
|
||||
{
|
||||
chomp($line);
|
||||
if ($line =~ /asio::thread/)
|
||||
{
|
||||
close($input);
|
||||
return 1;
|
||||
}
|
||||
elsif ($line =~ /^ *thread /)
|
||||
{
|
||||
close($input);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
close($input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub source_contains_asio_include
|
||||
{
|
||||
my ($from) = @_;
|
||||
|
||||
# Open the input file.
|
||||
open(my $input, "<$from") or die("Can't open $from for reading");
|
||||
|
||||
# Check file for inclusion of asio.hpp.
|
||||
while (my $line = <$input>)
|
||||
{
|
||||
chomp($line);
|
||||
if ($line =~ /# *include [<"]asio\.hpp[>"]/)
|
||||
{
|
||||
close($input);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
close($input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub copy_source_file
|
||||
{
|
||||
my ($from, $to) = @_;
|
||||
|
||||
# Ensure the output directory exists.
|
||||
my $dir = $to;
|
||||
$dir =~ s/[^\/]*$//;
|
||||
mkpath($dir);
|
||||
|
||||
# First determine whether the file makes any use of asio::thread.
|
||||
my $uses_asio_thread = source_contains_asio_thread_usage($from);
|
||||
|
||||
my $includes_asio = source_contains_asio_include($from);
|
||||
|
||||
my $is_asio_hpp = 0;
|
||||
$is_asio_hpp = 1 if ($from =~ /asio\.hpp/);
|
||||
|
||||
my $needs_doc_link = 0;
|
||||
$needs_doc_link = 1 if ($is_asio_hpp);
|
||||
|
||||
my $is_error_hpp = 0;
|
||||
$is_error_hpp = 1 if ($from =~ /asio\/error\.hpp/);
|
||||
|
||||
my $is_qbk = 0;
|
||||
$is_qbk = 1 if ($from =~ /.qbk$/);
|
||||
|
||||
my $is_xsl = 0;
|
||||
$is_xsl = 1 if ($from =~ /.xsl$/);
|
||||
|
||||
my $is_quickref = 0;
|
||||
$is_quickref = 1 if ($from =~ /quickref.xml$/);
|
||||
|
||||
my $is_test = 0;
|
||||
$is_test = 1 if ($from =~ /tests\/unit/);
|
||||
|
||||
my $is_coroutine_related = 0;
|
||||
$is_coroutine_related = 1 if ($from =~ /await/ || $from =~ /partial_promise/ || $from =~ /co_composed/);
|
||||
|
||||
my $is_hash_related = 0;
|
||||
$is_hash_related = 1 if ($from =~ /ip\/address/ || $from =~ /ip\/basic_endpoint/);
|
||||
|
||||
# Open the files.
|
||||
open(my $input, "<$from") or die("Can't open $from for reading");
|
||||
open(my $output, ">$to") or die("Can't open $to for writing");
|
||||
|
||||
# Copy the content.
|
||||
my $lineno = 1;
|
||||
while (my $line = <$input>)
|
||||
{
|
||||
chomp($line);
|
||||
|
||||
# Unconditional replacements.
|
||||
$line =~ s/[\\@]ref boost_bind/boost::bind()/g;
|
||||
if ($from =~ /.*\.txt$/)
|
||||
{
|
||||
$line =~ s/[\\@]ref async_read/boost::asio::async_read()/g;
|
||||
$line =~ s/[\\@]ref async_write/boost::asio::async_write()/g;
|
||||
}
|
||||
if ($line =~ /asio_detail_posix_thread_function/)
|
||||
{
|
||||
$line =~ s/asio_detail_posix_thread_function/boost_asio_detail_posix_thread_function/g;
|
||||
}
|
||||
if ($line =~ /asio_signal_handler/)
|
||||
{
|
||||
$line =~ s/asio_signal_handler/boost_asio_signal_handler/g;
|
||||
}
|
||||
if ($line =~ /ASIO_/ && !($line =~ /BOOST_ASIO_/))
|
||||
{
|
||||
$line =~ s/ASIO_/BOOST_ASIO_/g;
|
||||
}
|
||||
|
||||
# Extra replacements for quickbook, XSL and quickref.xml source only.
|
||||
if ($is_qbk || $is_xsl || $is_quickref)
|
||||
{
|
||||
$line =~ s/asio\.examples/boost_asio.examples/g;
|
||||
$line =~ s/asio\.history/boost_asio.history/g;
|
||||
$line =~ s/asio\.index/boost_asio.index/g;
|
||||
$line =~ s/asio\.net_ts/boost_asio.net_ts/g;
|
||||
$line =~ s/asio\.std_executors/boost_asio.std_executors/g;
|
||||
$line =~ s/asio\.overview/boost_asio.overview/g;
|
||||
$line =~ s/asio\.reference/boost_asio.reference/g;
|
||||
$line =~ s/asio\.tutorial/boost_asio.tutorial/g;
|
||||
$line =~ s/asio\.using/boost_asio.using/g;
|
||||
$line =~ s/Asio/Boost.Asio/g;
|
||||
$line =~ s/changes made in each release/changes made in each Boost release/g;
|
||||
$line =~ s/\[\$/[\$boost_asio\//g;
|
||||
$line =~ s/\[@\.\.\/src\/examples/[\@boost_asio\/example/g;
|
||||
$line =~ s/asio\//boost\/asio\//g if $is_xsl;
|
||||
$line =~ s/include\/asio/boost\/asio/g;
|
||||
$line =~ s/\^asio/^boost\/asio/g;
|
||||
$line =~ s/namespaceasio/namespaceboost_1_1asio/g;
|
||||
$line =~ s/ \(\[\@examples\/diffs.*$//;
|
||||
$line =~ s/boost\/tools\/boostbook/tools\/boostbook/g;
|
||||
}
|
||||
|
||||
# Conditional replacements.
|
||||
if ($line =~ /^( *)namespace asio \{/)
|
||||
{
|
||||
if ($is_qbk)
|
||||
{
|
||||
print_line($output, $1 . "namespace boost { namespace asio {", $from, $lineno);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $1 . "namespace boost {", $from, $lineno);
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^( *)} \/\/ namespace asio$/)
|
||||
{
|
||||
if ($is_qbk)
|
||||
{
|
||||
print_line($output, $1 . "} } // namespace boost::asio", $from, $lineno);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $line, $from, $lineno);
|
||||
print_line($output, $1 . "} // namespace boost", $from, $lineno);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^(# *include )[<"](asio\.hpp)[>"]$/)
|
||||
{
|
||||
print_line($output, $1 . "<boost/" . $2 . ">", $from, $lineno);
|
||||
if ($uses_asio_thread)
|
||||
{
|
||||
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno) if (!$is_test);
|
||||
$uses_asio_thread = 0;
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^(# *include )[<"]boost\/.*[>"].*$/)
|
||||
{
|
||||
if (!$includes_asio && $uses_asio_thread)
|
||||
{
|
||||
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno) if (!$is_test);
|
||||
$uses_asio_thread = 0;
|
||||
}
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /^(# *include )[<"]asio\/thread\.hpp[>"]/)
|
||||
{
|
||||
if ($is_test)
|
||||
{
|
||||
print_line($output, $1 . "<boost/asio/detail/thread.hpp>", $from, $lineno);
|
||||
}
|
||||
else
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /(# *include )[<"]asio\/error_code\.hpp[>"]/)
|
||||
{
|
||||
if ($is_asio_hpp)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $1 . "<boost/cerrno.hpp>", $from, $lineno) if ($is_error_hpp);
|
||||
print_line($output, $1 . "<boost/system/error_code.hpp>", $from, $lineno);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /# *include [<"]asio\/impl\/error_code\.[hi]pp[>"]/)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
elsif ($line =~ /(# *include )[<"]asio\/system_error\.hpp[>"]/)
|
||||
{
|
||||
if ($is_asio_hpp)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $1 . "<boost/system/system_error.hpp>", $from, $lineno);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /(^.*# *include )[<"](asio\/[^>"]*)[>"](.*)$/)
|
||||
{
|
||||
print_line($output, $1 . "<boost/" . $2 . ">" . $3, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /#.*defined\(.*ASIO_HAS_STD_SYSTEM_ERROR\)$/)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
elsif ($line =~ /asio::thread\b/)
|
||||
{
|
||||
if ($is_test)
|
||||
{
|
||||
$line =~ s/asio::thread/asio::detail::thread/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$line =~ s/asio::thread/boost::thread/g;
|
||||
}
|
||||
if (!($line =~ /boost::asio::/))
|
||||
{
|
||||
$line =~ s/asio::/boost::asio::/g;
|
||||
}
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /^( *)thread( .*)$/ && !$is_qbk)
|
||||
{
|
||||
if ($is_test)
|
||||
{
|
||||
print_line($output, $1 . "boost::asio::detail::thread" . $2, $from, $lineno);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $1 . "boost::thread" . $2, $from, $lineno);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /namespace std \{ *$/ && !$is_coroutine_related && !$is_hash_related)
|
||||
{
|
||||
print_line($output, "namespace boost {", $from, $lineno);
|
||||
print_line($output, "namespace system {", $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /std::error_code/)
|
||||
{
|
||||
$line =~ s/std::error_code/boost::system::error_code/g;
|
||||
$line =~ s/asio::/boost::asio::/g if !$is_xsl;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /std::system_error/)
|
||||
{
|
||||
$line =~ s/std::system_error/boost::system::system_error/g;
|
||||
$line =~ s/asio::/boost::asio::/g if !$is_xsl;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /ec\.assign\(0, ec\.category\(\)\)/)
|
||||
{
|
||||
$line =~ s/ec\.assign\(0, ec\.category\(\)\)/ec = boost::system::error_code()/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /^} \/\/ namespace std/ && !$is_coroutine_related && !$is_hash_related)
|
||||
{
|
||||
print_line($output, "} // namespace system", $from, $lineno);
|
||||
print_line($output, "} // namespace boost", $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio::/ && !($line =~ /boost::asio::/))
|
||||
{
|
||||
$line =~ s/asio::error_code/boost::system::error_code/g;
|
||||
$line =~ s/asio::error_category/boost::system::error_category/g;
|
||||
$line =~ s/asio::system_category/boost::system::system_category/g;
|
||||
$line =~ s/asio::system_error/boost::system::system_error/g;
|
||||
$line =~ s/asio::/boost::asio::/g if !$is_xsl;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /using namespace asio/)
|
||||
{
|
||||
$line =~ s/using namespace asio/using namespace boost::asio/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio_handler_alloc_helpers/)
|
||||
{
|
||||
$line =~ s/asio_handler_alloc_helpers/boost_asio_handler_alloc_helpers/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio_handler_cont_helpers/)
|
||||
{
|
||||
$line =~ s/asio_handler_cont_helpers/boost_asio_handler_cont_helpers/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio_handler_invoke_helpers/)
|
||||
{
|
||||
$line =~ s/asio_handler_invoke_helpers/boost_asio_handler_invoke_helpers/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio_(prefer|query|require|require_concept)_fn/)
|
||||
{
|
||||
$line =~ s/asio_(prefer|query|require|require_concept)_fn/boost_asio_$1_fn/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /asio_execution_/ && !($line =~ /_is_unspecialised/))
|
||||
{
|
||||
$line =~ s/asio_execution_/boost_asio_execution_/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /[\\@]ref boost_bind/)
|
||||
{
|
||||
$line =~ s/[\\@]ref boost_bind/boost::bind()/g;
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /( *)\[category template\]/)
|
||||
{
|
||||
print_line($output, $1 . "[authors [Kohlhoff, Christopher]]", $from, $lineno);
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($line =~ /boostify: non-boost docs start here/)
|
||||
{
|
||||
while ($line = <$input>)
|
||||
{
|
||||
last if $line =~ /boostify: non-boost docs end here/;
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /boostify: non-boost code starts here/)
|
||||
{
|
||||
while ($line = <$input>)
|
||||
{
|
||||
last if $line =~ /boostify: non-boost code ends here/;
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^$/ && $needs_doc_link)
|
||||
{
|
||||
$needs_doc_link = 0;
|
||||
print_line($output, "// See www.boost.org/libs/asio for documentation.", $from, $lineno);
|
||||
print_line($output, "//", $from, $lineno);
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
elsif ($is_quickref)
|
||||
{
|
||||
if ($line =~ /asio\.reference\.error_code">/)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
elsif ($line =~ /asio\.reference\.system_error">/)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
elsif ($line =~ /asio\.reference\.thread">/)
|
||||
{
|
||||
# Line is removed.
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_line($output, $line, $from, $lineno);
|
||||
}
|
||||
++$lineno;
|
||||
}
|
||||
|
||||
# Ok, we're done.
|
||||
close($input);
|
||||
close($output);
|
||||
}
|
||||
|
||||
sub copy_include_files
|
||||
{
|
||||
my @dirs = (
|
||||
"include",
|
||||
"include/asio",
|
||||
"include/asio/detail",
|
||||
"include/asio/detail/impl",
|
||||
"include/asio/execution",
|
||||
"include/asio/execution/detail",
|
||||
"include/asio/execution/impl",
|
||||
"include/asio/experimental",
|
||||
"include/asio/experimental/detail",
|
||||
"include/asio/experimental/detail/impl",
|
||||
"include/asio/experimental/impl",
|
||||
"include/asio/generic",
|
||||
"include/asio/generic/detail",
|
||||
"include/asio/generic/detail/impl",
|
||||
"include/asio/impl",
|
||||
"include/asio/ip",
|
||||
"include/asio/ip/impl",
|
||||
"include/asio/ip/detail",
|
||||
"include/asio/ip/detail/impl",
|
||||
"include/asio/local",
|
||||
"include/asio/local/detail",
|
||||
"include/asio/local/detail/impl",
|
||||
"include/asio/posix",
|
||||
"include/asio/ssl",
|
||||
"include/asio/ssl/detail",
|
||||
"include/asio/ssl/detail/impl",
|
||||
"include/asio/ssl/impl",
|
||||
"include/asio/ssl/old",
|
||||
"include/asio/ssl/old/detail",
|
||||
"include/asio/traits",
|
||||
"include/asio/ts",
|
||||
"include/asio/windows");
|
||||
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
our $boost_dir;
|
||||
my @files = ( glob("$dir/*.hpp"), glob("$dir/*.ipp") );
|
||||
foreach my $file (@files)
|
||||
{
|
||||
if ($file ne "include/asio/thread.hpp"
|
||||
and $file ne "include/asio/error_code.hpp"
|
||||
and $file ne "include/asio/system_error.hpp"
|
||||
and $file ne "include/asio/impl/error_code.hpp"
|
||||
and $file ne "include/asio/impl/error_code.ipp")
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^include\//$boost_dir\/libs\/asio\/include\/boost\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub create_lib_directory
|
||||
{
|
||||
my @dirs = (
|
||||
"doc",
|
||||
"example",
|
||||
"test");
|
||||
|
||||
our $boost_dir;
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
mkpath("$boost_dir/libs/asio/$dir");
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_unit_tests
|
||||
{
|
||||
my @dirs = (
|
||||
"src/tests/unit",
|
||||
"src/tests/unit/archetypes",
|
||||
"src/tests/unit/execution",
|
||||
"src/tests/unit/experimental",
|
||||
"src/tests/unit/experimental/coro",
|
||||
"src/tests/unit/generic",
|
||||
"src/tests/unit/ip",
|
||||
"src/tests/unit/local",
|
||||
"src/tests/unit/posix",
|
||||
"src/tests/unit/ssl",
|
||||
"src/tests/unit/ts",
|
||||
"src/tests/unit/windows");
|
||||
|
||||
our $boost_dir;
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
my @files = ( glob("$dir/*.*pp"), glob("$dir/Jamfile*") );
|
||||
foreach my $file (@files)
|
||||
{
|
||||
if ($file ne "src/tests/unit/thread.cpp"
|
||||
and $file ne "src/tests/unit/error_handler.cpp"
|
||||
and $file ne "src/tests/unit/unit_test.cpp")
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/tests\/unit\//$boost_dir\/libs\/asio\/test\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_latency_tests
|
||||
{
|
||||
my @dirs = (
|
||||
"src/tests/latency");
|
||||
|
||||
our $boost_dir;
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
my @files = ( glob("$dir/*.*pp"), glob("$dir/Jamfile*") );
|
||||
foreach my $file (@files)
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/tests\/latency\//$boost_dir\/libs\/asio\/test\/latency\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_properties_tests
|
||||
{
|
||||
my @dirs = (
|
||||
"src/tests/properties/cpp03",
|
||||
"src/tests/properties/cpp11",
|
||||
"src/tests/properties/cpp14");
|
||||
|
||||
our $boost_dir;
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
my @files = ( glob("$dir/*.*pp"), glob("$dir/Jamfile*") );
|
||||
foreach my $file (@files)
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/tests\/properties\//$boost_dir\/libs\/asio\/test\/properties\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_examples
|
||||
{
|
||||
my @dirs = (
|
||||
"src/examples/cpp11/allocation",
|
||||
"src/examples/cpp11/buffers",
|
||||
"src/examples/cpp11/chat",
|
||||
"src/examples/cpp11/deferred",
|
||||
"src/examples/cpp11/echo",
|
||||
"src/examples/cpp11/executors",
|
||||
"src/examples/cpp11/files",
|
||||
"src/examples/cpp11/fork",
|
||||
"src/examples/cpp11/futures",
|
||||
"src/examples/cpp11/handler_tracking",
|
||||
"src/examples/cpp11/http/client",
|
||||
"src/examples/cpp11/http/doc_root",
|
||||
"src/examples/cpp11/http/server",
|
||||
"src/examples/cpp11/http/server2",
|
||||
"src/examples/cpp11/http/server3",
|
||||
"src/examples/cpp11/http/server4",
|
||||
"src/examples/cpp11/icmp",
|
||||
"src/examples/cpp11/invocation",
|
||||
"src/examples/cpp11/iostreams",
|
||||
"src/examples/cpp11/local",
|
||||
"src/examples/cpp11/multicast",
|
||||
"src/examples/cpp11/nonblocking",
|
||||
"src/examples/cpp11/operations",
|
||||
"src/examples/cpp11/parallel_group",
|
||||
"src/examples/cpp11/porthopper",
|
||||
"src/examples/cpp11/serialization",
|
||||
"src/examples/cpp11/services",
|
||||
"src/examples/cpp11/socks4",
|
||||
"src/examples/cpp11/spawn",
|
||||
"src/examples/cpp11/ssl",
|
||||
"src/examples/cpp11/timeouts",
|
||||
"src/examples/cpp11/timers",
|
||||
"src/examples/cpp11/tutorial",
|
||||
"src/examples/cpp11/tutorial/daytime1",
|
||||
"src/examples/cpp11/tutorial/daytime2",
|
||||
"src/examples/cpp11/tutorial/daytime3",
|
||||
"src/examples/cpp11/tutorial/daytime4",
|
||||
"src/examples/cpp11/tutorial/daytime5",
|
||||
"src/examples/cpp11/tutorial/daytime6",
|
||||
"src/examples/cpp11/tutorial/daytime7",
|
||||
"src/examples/cpp11/tutorial/timer1",
|
||||
"src/examples/cpp11/tutorial/timer2",
|
||||
"src/examples/cpp11/tutorial/timer3",
|
||||
"src/examples/cpp11/tutorial/timer4",
|
||||
"src/examples/cpp11/tutorial/timer5",
|
||||
"src/examples/cpp11/type_erasure",
|
||||
"src/examples/cpp11/windows",
|
||||
"src/examples/cpp14/deferred",
|
||||
"src/examples/cpp14/echo",
|
||||
"src/examples/cpp14/executors",
|
||||
"src/examples/cpp14/iostreams",
|
||||
"src/examples/cpp14/operations",
|
||||
"src/examples/cpp14/parallel_group",
|
||||
"src/examples/cpp17/coroutines_ts",
|
||||
"src/examples/cpp20/channels",
|
||||
"src/examples/cpp20/coroutines",
|
||||
"src/examples/cpp20/invocation",
|
||||
"src/examples/cpp20/operations",
|
||||
"src/examples/cpp20/type_erasure");
|
||||
|
||||
our $boost_dir;
|
||||
foreach my $dir (@dirs)
|
||||
{
|
||||
my @files = (
|
||||
glob("$dir/*.*pp"),
|
||||
glob("$dir/*.html"),
|
||||
glob("$dir/Jamfile*"),
|
||||
glob("$dir/*.pem"),
|
||||
glob("$dir/README*"),
|
||||
glob("$dir/*.txt"));
|
||||
foreach my $file (@files)
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/examples\//$boost_dir\/libs\/asio\/example\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_doc
|
||||
{
|
||||
our $boost_dir;
|
||||
my @files = (
|
||||
"src/doc/asio.qbk",
|
||||
"src/doc/examples.qbk",
|
||||
"src/doc/net_ts.qbk",
|
||||
"src/doc/overview.qbk",
|
||||
"src/doc/quickref.xml",
|
||||
"src/doc/reference.xsl",
|
||||
"src/doc/std_executors.qbk",
|
||||
"src/doc/tutorial.xsl",
|
||||
glob("src/doc/overview/*.qbk"),
|
||||
glob("src/doc/overview/model/*.qbk"),
|
||||
glob("src/doc/requirements/*.qbk"));
|
||||
foreach my $file (@files)
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/doc\//$boost_dir\/libs\/asio\/doc\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_tools
|
||||
{
|
||||
our $boost_dir;
|
||||
my @files = (
|
||||
glob("src/tools/*.pl"));
|
||||
foreach my $file (@files)
|
||||
{
|
||||
my $from = $file;
|
||||
my $to = $file;
|
||||
$to =~ s/^src\/tools\//$boost_dir\/libs\/asio\/tools\//;
|
||||
copy_source_file($from, $to);
|
||||
}
|
||||
}
|
||||
|
||||
my $includes_only = 0;
|
||||
if (scalar(@ARGV) == 1 && $ARGV[0] eq "--includes-only")
|
||||
{
|
||||
$includes_only = 1;
|
||||
}
|
||||
|
||||
copy_include_files();
|
||||
if (not $includes_only)
|
||||
{
|
||||
create_lib_directory();
|
||||
copy_unit_tests();
|
||||
copy_latency_tests();
|
||||
copy_properties_tests();
|
||||
copy_examples();
|
||||
copy_doc();
|
||||
copy_tools();
|
||||
}
|
||||
|
||||
exit($bad_lines > 0 ? 1 : 0);
|
||||
259
third_party/socket.io-client-cpp/lib/asio/asio/configure.ac
vendored
Normal file
259
third_party/socket.io-client-cpp/lib/asio/asio/configure.ac
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
AC_INIT([asio],[1.31.0])
|
||||
AC_CONFIG_SRCDIR(include/asio.hpp)
|
||||
AM_MAINTAINER_MODE
|
||||
AM_INIT_AUTOMAKE([tar-pax])
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_LANG(C++)
|
||||
AC_PROG_RANLIB
|
||||
PKG_INSTALLDIR
|
||||
|
||||
AC_DEFINE(_REENTRANT, [1], [Define this])
|
||||
|
||||
AC_ARG_WITH(boost,
|
||||
AS_HELP_STRING([--with-boost=DIR],[location of boost distribution]),
|
||||
[
|
||||
if test "${withval}" = no; then
|
||||
STANDALONE="yes"
|
||||
else
|
||||
if test "${withval}" != system; then
|
||||
CPPFLAGS="$CPPFLAGS -I${withval}"
|
||||
LIBS="$LIBS -L${withval}/stage/lib"
|
||||
fi
|
||||
CPPFLAGS="$CPPFLAGS -DASIO_ENABLE_BOOST -DBOOST_CHRONO_HEADER_ONLY -DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING"
|
||||
fi
|
||||
],
|
||||
[
|
||||
STANDALONE="yes"
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(separate-compilation,
|
||||
[ --enable-separate-compilation separate compilation of asio source],
|
||||
[
|
||||
SEPARATE_COMPILATION=yes
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(boost-coroutine,
|
||||
[ --enable-boost-coroutine use Boost.Coroutine to implement stackful coroutines],
|
||||
[
|
||||
HAVE_BOOST_COROUTINE=yes
|
||||
])
|
||||
|
||||
if test "$STANDALONE" != yes; then
|
||||
AC_CHECK_HEADER([boost/noncopyable.hpp],,
|
||||
[
|
||||
echo "Can't find boost headers. Please check the location of the boost"
|
||||
echo "distribution and rerun configure using the --with-boost=DIR option."
|
||||
echo "Alternatively, run with --without-boost to enable standalone build."
|
||||
exit 1
|
||||
],[])
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(openssl,
|
||||
AS_HELP_STRING([--with-openssl=DIR],[location of openssl]),
|
||||
[
|
||||
CPPFLAGS="$CPPFLAGS -I${withval}/include"
|
||||
LIBS="$LIBS -L${withval}/lib"
|
||||
],[])
|
||||
|
||||
AC_CHECK_HEADER([openssl/ssl.h],,
|
||||
[
|
||||
OPENSSL_FOUND=no
|
||||
],[])
|
||||
|
||||
if test x$OPENSSL_FOUND != xno; then
|
||||
LIBS="$LIBS -lssl -lcrypto"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_OPENSSL,test x$OPENSSL_FOUND != xno)
|
||||
|
||||
WINDOWS=no
|
||||
case $host in
|
||||
*-*-linux*)
|
||||
CXXFLAGS="$CXXFLAGS -pthread"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
LIBS="$LIBS -lrt"
|
||||
;;
|
||||
*-*-solaris*)
|
||||
if test "$GXX" = yes; then
|
||||
CXXFLAGS="$CXXFLAGS -D_PTHREADS"
|
||||
else
|
||||
# We'll assume Sun's CC.
|
||||
CXXFLAGS="$CXXFLAGS -mt"
|
||||
fi
|
||||
LIBS="$LIBS -lsocket -lnsl -lpthread"
|
||||
;;
|
||||
*-*-mingw32*)
|
||||
CXXFLAGS="$CXXFLAGS -mthreads"
|
||||
LDFLAGS="$LDFLAGS -mthreads"
|
||||
LIBS="$LIBS -lws2_32 -lmswsock"
|
||||
WINDOWS=yes
|
||||
;;
|
||||
*-*-mingw64*)
|
||||
CXXFLAGS="$CXXFLAGS -mthreads"
|
||||
LDFLAGS="$LDFLAGS -mthreads"
|
||||
LIBS="$LIBS -lws2_32 -lmswsock"
|
||||
WINDOWS=yes
|
||||
;;
|
||||
*-pc-cygwin*)
|
||||
CXXFLAGS="$CXXFLAGS -D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0601"
|
||||
LIBS="$LIBS -lws2_32 -lmswsock"
|
||||
WINDOWS=yes
|
||||
;;
|
||||
*-apple-darwin*)
|
||||
CXXFLAGS="$CXXFLAGS"
|
||||
LDFLAGS="$LDFLAGS"
|
||||
;;
|
||||
*-*-freebsd*)
|
||||
CXXFLAGS="$CXXFLAGS -pthread"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
;;
|
||||
*-*-netbsd*)
|
||||
CXXFLAGS="$CXXFLAGS -pthread"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
;;
|
||||
*-*-haiku*)
|
||||
CXXFLAGS="$CXXFLAGS -lnetwork"
|
||||
LDFLAGS="$LDFLAGS -lnetwork"
|
||||
|
||||
esac
|
||||
|
||||
if test "$GXX" = yes; then
|
||||
CXXFLAGS="$CXXFLAGS -ftemplate-depth-256"
|
||||
fi
|
||||
|
||||
if test "$STANDALONE" = yes; then
|
||||
CPPFLAGS="$CPPFLAGS -DASIO_STANDALONE"
|
||||
fi
|
||||
|
||||
if test "$SEPARATE_COMPILATION" = yes; then
|
||||
CPPFLAGS="$CPPFLAGS -DASIO_SEPARATE_COMPILATION"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether C++11 is enabled])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if __cplusplus < 201103L]]
|
||||
[[#error C++11 not available]]
|
||||
[[#endif]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_CXX11=yes;],
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_CXX11=no;])
|
||||
|
||||
AC_MSG_CHECKING([whether C++14 is enabled])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if defined(__GNUC__) && !defined(__clang__)]]
|
||||
[[# if (__GNUC__ <= 6)]]
|
||||
[[# error C++14 support on this compiler not sufficiently compliant]]
|
||||
[[# endif]]
|
||||
[[#endif]]
|
||||
[[#if __cplusplus < 201402L]]
|
||||
[[#error C++14 not available]]
|
||||
[[#endif]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_CXX14=yes;],
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_CXX14=no;])
|
||||
|
||||
AC_MSG_CHECKING([whether C++17 is enabled])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if __cplusplus < 201703L]]
|
||||
[[#error C++17 not available]]
|
||||
[[#endif]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_CXX17=yes;],
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_CXX17=no;])
|
||||
|
||||
AC_MSG_CHECKING([whether C++20 is enabled])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if __cplusplus < 202002L]]
|
||||
[[#error C++20 not available]]
|
||||
[[#endif]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_CXX20=yes;],
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_CXX20=no;])
|
||||
|
||||
AC_MSG_CHECKING([whether coroutines are enabled])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#if defined(__clang__)]]
|
||||
[[# if (__clang_major__ >= 14)]]
|
||||
[[# if (__cplusplus >= 202002) && (__cpp_impl_coroutine >= 201902)]]
|
||||
[[# if __has_include(<coroutine>)]]
|
||||
[[# define ASIO_HAS_CO_AWAIT 1]]
|
||||
[[# endif]]
|
||||
[[# elif (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)]]
|
||||
[[# if __has_include(<experimental/coroutine>)]]
|
||||
[[# define ASIO_HAS_CO_AWAIT 1]]
|
||||
[[# endif]]
|
||||
[[# endif]]
|
||||
[[# else]]
|
||||
[[# if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)]]
|
||||
[[# if __has_include(<experimental/coroutine>)]]
|
||||
[[# define ASIO_HAS_CO_AWAIT 1]]
|
||||
[[# endif]]
|
||||
[[# endif]]
|
||||
[[# endif]]
|
||||
[[#elif defined(__GNUC__)]]
|
||||
[[# if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)]]
|
||||
[[# if __has_include(<coroutine>)]]
|
||||
[[# define ASIO_HAS_CO_AWAIT 1]]
|
||||
[[# endif]]
|
||||
[[# endif]]
|
||||
[[#endif]]
|
||||
[[#ifndef ASIO_HAS_CO_AWAIT]]
|
||||
[[# error coroutines not available]]
|
||||
[[#endif]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_COROUTINES=yes;],
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_COROUTINES=no;])
|
||||
|
||||
if test "$GXX" = yes; then
|
||||
if test "$STANDALONE" = yes; then
|
||||
if test "$HAVE_CXX11" = no; then
|
||||
HAVE_CXX11=yes
|
||||
CPPFLAGS="-std=c++0x $CPPFLAGS"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(STANDALONE,test x$STANDALONE = xyes)
|
||||
|
||||
AM_CONDITIONAL(SEPARATE_COMPILATION,test x$SEPARATE_COMPILATION = xyes)
|
||||
|
||||
AM_CONDITIONAL(HAVE_BOOST_COROUTINE,test x$HAVE_BOOST_COROUTINE = xyes)
|
||||
|
||||
AM_CONDITIONAL(WINDOWS_TARGET,test x$WINDOWS != xno)
|
||||
|
||||
AM_CONDITIONAL(HAVE_CXX11,test x$HAVE_CXX11 = xyes)
|
||||
|
||||
AM_CONDITIONAL(HAVE_CXX14,test x$HAVE_CXX14 = xyes)
|
||||
|
||||
AM_CONDITIONAL(HAVE_CXX17,test x$HAVE_CXX17 = xyes)
|
||||
|
||||
AM_CONDITIONAL(HAVE_CXX20,test x$HAVE_CXX20 = xyes)
|
||||
|
||||
AM_CONDITIONAL(HAVE_COROUTINES,test x$HAVE_COROUTINES = xyes)
|
||||
|
||||
AC_CONFIG_FILES([asio.pc])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
src/tests/Makefile
|
||||
src/tests/properties/Makefile
|
||||
src/examples/cpp11/Makefile
|
||||
src/examples/cpp14/Makefile
|
||||
src/examples/cpp17/Makefile
|
||||
src/examples/cpp20/Makefile])
|
||||
AC_OUTPUT
|
||||
2
third_party/socket.io-client-cpp/lib/asio/asio/include/.gitignore
vendored
Normal file
2
third_party/socket.io-client-cpp/lib/asio/asio/include/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
635
third_party/socket.io-client-cpp/lib/asio/asio/include/Makefile.am
vendored
Normal file
635
third_party/socket.io-client-cpp/lib/asio/asio/include/Makefile.am
vendored
Normal file
@@ -0,0 +1,635 @@
|
||||
# find . -name "*.*pp" | sed -e 's/^\.\///' | sed -e 's/^.*$/ & \\/' | sort
|
||||
nobase_include_HEADERS = \
|
||||
asio/any_completion_executor.hpp \
|
||||
asio/any_completion_handler.hpp \
|
||||
asio/any_io_executor.hpp \
|
||||
asio/append.hpp \
|
||||
asio/as_tuple.hpp \
|
||||
asio/associated_allocator.hpp \
|
||||
asio/associated_cancellation_slot.hpp \
|
||||
asio/associated_executor.hpp \
|
||||
asio/associated_immediate_executor.hpp \
|
||||
asio/associator.hpp \
|
||||
asio/async_result.hpp \
|
||||
asio/awaitable.hpp \
|
||||
asio/basic_datagram_socket.hpp \
|
||||
asio/basic_deadline_timer.hpp \
|
||||
asio/basic_file.hpp \
|
||||
asio/basic_io_object.hpp \
|
||||
asio/basic_random_access_file.hpp \
|
||||
asio/basic_raw_socket.hpp \
|
||||
asio/basic_readable_pipe.hpp \
|
||||
asio/basic_seq_packet_socket.hpp \
|
||||
asio/basic_serial_port.hpp \
|
||||
asio/basic_signal_set.hpp \
|
||||
asio/basic_socket_acceptor.hpp \
|
||||
asio/basic_socket.hpp \
|
||||
asio/basic_socket_iostream.hpp \
|
||||
asio/basic_socket_streambuf.hpp \
|
||||
asio/basic_streambuf_fwd.hpp \
|
||||
asio/basic_streambuf.hpp \
|
||||
asio/basic_stream_file.hpp \
|
||||
asio/basic_stream_socket.hpp \
|
||||
asio/basic_waitable_timer.hpp \
|
||||
asio/basic_writable_pipe.hpp \
|
||||
asio/bind_allocator.hpp \
|
||||
asio/bind_cancellation_slot.hpp \
|
||||
asio/bind_executor.hpp \
|
||||
asio/bind_immediate_executor.hpp \
|
||||
asio/buffered_read_stream_fwd.hpp \
|
||||
asio/buffered_read_stream.hpp \
|
||||
asio/buffered_stream_fwd.hpp \
|
||||
asio/buffered_stream.hpp \
|
||||
asio/buffered_write_stream_fwd.hpp \
|
||||
asio/buffered_write_stream.hpp \
|
||||
asio/buffer.hpp \
|
||||
asio/buffer_registration.hpp \
|
||||
asio/buffers_iterator.hpp \
|
||||
asio/cancel_after.hpp \
|
||||
asio/cancel_at.hpp \
|
||||
asio/cancellation_signal.hpp \
|
||||
asio/cancellation_state.hpp \
|
||||
asio/cancellation_type.hpp \
|
||||
asio/co_composed.hpp \
|
||||
asio/co_spawn.hpp \
|
||||
asio/completion_condition.hpp \
|
||||
asio/compose.hpp \
|
||||
asio/composed.hpp \
|
||||
asio/connect.hpp \
|
||||
asio/connect_pipe.hpp \
|
||||
asio/consign.hpp \
|
||||
asio/coroutine.hpp \
|
||||
asio/deadline_timer.hpp \
|
||||
asio/defer.hpp \
|
||||
asio/deferred.hpp \
|
||||
asio/default_completion_token.hpp \
|
||||
asio/detached.hpp \
|
||||
asio/detail/array_fwd.hpp \
|
||||
asio/detail/array.hpp \
|
||||
asio/detail/assert.hpp \
|
||||
asio/detail/atomic_count.hpp \
|
||||
asio/detail/base_from_cancellation_state.hpp \
|
||||
asio/detail/base_from_completion_cond.hpp \
|
||||
asio/detail/bind_handler.hpp \
|
||||
asio/detail/blocking_executor_op.hpp \
|
||||
asio/detail/buffered_stream_storage.hpp \
|
||||
asio/detail/buffer_resize_guard.hpp \
|
||||
asio/detail/buffer_sequence_adapter.hpp \
|
||||
asio/detail/call_stack.hpp \
|
||||
asio/detail/chrono.hpp \
|
||||
asio/detail/chrono_time_traits.hpp \
|
||||
asio/detail/completion_handler.hpp \
|
||||
asio/detail/completion_message.hpp \
|
||||
asio/detail/completion_payload.hpp \
|
||||
asio/detail/completion_payload_handler.hpp \
|
||||
asio/detail/composed_work.hpp \
|
||||
asio/detail/concurrency_hint.hpp \
|
||||
asio/detail/conditionally_enabled_event.hpp \
|
||||
asio/detail/conditionally_enabled_mutex.hpp \
|
||||
asio/detail/config.hpp \
|
||||
asio/detail/consuming_buffers.hpp \
|
||||
asio/detail/cstddef.hpp \
|
||||
asio/detail/cstdint.hpp \
|
||||
asio/detail/date_time_fwd.hpp \
|
||||
asio/detail/deadline_timer_service.hpp \
|
||||
asio/detail/dependent_type.hpp \
|
||||
asio/detail/descriptor_ops.hpp \
|
||||
asio/detail/descriptor_read_op.hpp \
|
||||
asio/detail/descriptor_write_op.hpp \
|
||||
asio/detail/dev_poll_reactor.hpp \
|
||||
asio/detail/epoll_reactor.hpp \
|
||||
asio/detail/eventfd_select_interrupter.hpp \
|
||||
asio/detail/event.hpp \
|
||||
asio/detail/exception.hpp \
|
||||
asio/detail/executor_function.hpp \
|
||||
asio/detail/executor_op.hpp \
|
||||
asio/detail/fd_set_adapter.hpp \
|
||||
asio/detail/fenced_block.hpp \
|
||||
asio/detail/functional.hpp \
|
||||
asio/detail/future.hpp \
|
||||
asio/detail/global.hpp \
|
||||
asio/detail/handler_alloc_helpers.hpp \
|
||||
asio/detail/handler_cont_helpers.hpp \
|
||||
asio/detail/handler_tracking.hpp \
|
||||
asio/detail/handler_type_requirements.hpp \
|
||||
asio/detail/handler_work.hpp \
|
||||
asio/detail/hash_map.hpp \
|
||||
asio/detail/impl/buffer_sequence_adapter.ipp \
|
||||
asio/detail/impl/descriptor_ops.ipp \
|
||||
asio/detail/impl/dev_poll_reactor.hpp \
|
||||
asio/detail/impl/dev_poll_reactor.ipp \
|
||||
asio/detail/impl/epoll_reactor.hpp \
|
||||
asio/detail/impl/epoll_reactor.ipp \
|
||||
asio/detail/impl/eventfd_select_interrupter.ipp \
|
||||
asio/detail/impl/handler_tracking.ipp \
|
||||
asio/detail/impl/io_uring_descriptor_service.ipp \
|
||||
asio/detail/impl/io_uring_file_service.ipp \
|
||||
asio/detail/impl/io_uring_service.hpp \
|
||||
asio/detail/impl/io_uring_service.ipp \
|
||||
asio/detail/impl/io_uring_socket_service_base.ipp \
|
||||
asio/detail/impl/kqueue_reactor.hpp \
|
||||
asio/detail/impl/kqueue_reactor.ipp \
|
||||
asio/detail/impl/null_event.ipp \
|
||||
asio/detail/impl/pipe_select_interrupter.ipp \
|
||||
asio/detail/impl/posix_event.ipp \
|
||||
asio/detail/impl/posix_mutex.ipp \
|
||||
asio/detail/impl/posix_serial_port_service.ipp \
|
||||
asio/detail/impl/posix_thread.ipp \
|
||||
asio/detail/impl/posix_tss_ptr.ipp \
|
||||
asio/detail/impl/reactive_descriptor_service.ipp \
|
||||
asio/detail/impl/reactive_socket_service_base.ipp \
|
||||
asio/detail/impl/resolver_service_base.ipp \
|
||||
asio/detail/impl/scheduler.ipp \
|
||||
asio/detail/impl/select_reactor.hpp \
|
||||
asio/detail/impl/select_reactor.ipp \
|
||||
asio/detail/impl/service_registry.hpp \
|
||||
asio/detail/impl/service_registry.ipp \
|
||||
asio/detail/impl/signal_set_service.ipp \
|
||||
asio/detail/impl/socket_ops.ipp \
|
||||
asio/detail/impl/socket_select_interrupter.ipp \
|
||||
asio/detail/impl/strand_executor_service.hpp \
|
||||
asio/detail/impl/strand_executor_service.ipp \
|
||||
asio/detail/impl/strand_service.hpp \
|
||||
asio/detail/impl/strand_service.ipp \
|
||||
asio/detail/impl/thread_context.ipp \
|
||||
asio/detail/impl/throw_error.ipp \
|
||||
asio/detail/impl/timer_queue_ptime.ipp \
|
||||
asio/detail/impl/timer_queue_set.ipp \
|
||||
asio/detail/impl/win_event.ipp \
|
||||
asio/detail/impl/win_iocp_file_service.ipp \
|
||||
asio/detail/impl/win_iocp_handle_service.ipp \
|
||||
asio/detail/impl/win_iocp_io_context.hpp \
|
||||
asio/detail/impl/win_iocp_io_context.ipp \
|
||||
asio/detail/impl/win_iocp_serial_port_service.ipp \
|
||||
asio/detail/impl/win_iocp_socket_service_base.ipp \
|
||||
asio/detail/impl/win_mutex.ipp \
|
||||
asio/detail/impl/win_object_handle_service.ipp \
|
||||
asio/detail/impl/winrt_ssocket_service_base.ipp \
|
||||
asio/detail/impl/winrt_timer_scheduler.hpp \
|
||||
asio/detail/impl/winrt_timer_scheduler.ipp \
|
||||
asio/detail/impl/winsock_init.ipp \
|
||||
asio/detail/impl/win_static_mutex.ipp \
|
||||
asio/detail/impl/win_thread.ipp \
|
||||
asio/detail/impl/win_tss_ptr.ipp \
|
||||
asio/detail/initiate_defer.hpp \
|
||||
asio/detail/initiate_dispatch.hpp \
|
||||
asio/detail/initiate_post.hpp \
|
||||
asio/detail/initiation_base.hpp \
|
||||
asio/detail/io_control.hpp \
|
||||
asio/detail/io_object_impl.hpp \
|
||||
asio/detail/io_uring_descriptor_read_at_op.hpp \
|
||||
asio/detail/io_uring_descriptor_read_op.hpp \
|
||||
asio/detail/io_uring_descriptor_service.hpp \
|
||||
asio/detail/io_uring_descriptor_write_at_op.hpp \
|
||||
asio/detail/io_uring_descriptor_write_op.hpp \
|
||||
asio/detail/io_uring_file_service.hpp \
|
||||
asio/detail/io_uring_null_buffers_op.hpp \
|
||||
asio/detail/io_uring_operation.hpp \
|
||||
asio/detail/io_uring_service.hpp \
|
||||
asio/detail/io_uring_socket_accept_op.hpp \
|
||||
asio/detail/io_uring_socket_connect_op.hpp \
|
||||
asio/detail/io_uring_socket_recvfrom_op.hpp \
|
||||
asio/detail/io_uring_socket_recvmsg_op.hpp \
|
||||
asio/detail/io_uring_socket_recv_op.hpp \
|
||||
asio/detail/io_uring_socket_send_op.hpp \
|
||||
asio/detail/io_uring_socket_sendto_op.hpp \
|
||||
asio/detail/io_uring_socket_service_base.hpp \
|
||||
asio/detail/io_uring_socket_service.hpp \
|
||||
asio/detail/io_uring_wait_op.hpp \
|
||||
asio/detail/is_buffer_sequence.hpp \
|
||||
asio/detail/is_executor.hpp \
|
||||
asio/detail/keyword_tss_ptr.hpp \
|
||||
asio/detail/kqueue_reactor.hpp \
|
||||
asio/detail/limits.hpp \
|
||||
asio/detail/local_free_on_block_exit.hpp \
|
||||
asio/detail/memory.hpp \
|
||||
asio/detail/mutex.hpp \
|
||||
asio/detail/non_const_lvalue.hpp \
|
||||
asio/detail/noncopyable.hpp \
|
||||
asio/detail/null_event.hpp \
|
||||
asio/detail/null_fenced_block.hpp \
|
||||
asio/detail/null_global.hpp \
|
||||
asio/detail/null_mutex.hpp \
|
||||
asio/detail/null_reactor.hpp \
|
||||
asio/detail/null_signal_blocker.hpp \
|
||||
asio/detail/null_socket_service.hpp \
|
||||
asio/detail/null_static_mutex.hpp \
|
||||
asio/detail/null_thread.hpp \
|
||||
asio/detail/null_tss_ptr.hpp \
|
||||
asio/detail/object_pool.hpp \
|
||||
asio/detail/old_win_sdk_compat.hpp \
|
||||
asio/detail/operation.hpp \
|
||||
asio/detail/op_queue.hpp \
|
||||
asio/detail/pipe_select_interrupter.hpp \
|
||||
asio/detail/pop_options.hpp \
|
||||
asio/detail/posix_event.hpp \
|
||||
asio/detail/posix_fd_set_adapter.hpp \
|
||||
asio/detail/posix_global.hpp \
|
||||
asio/detail/posix_mutex.hpp \
|
||||
asio/detail/posix_serial_port_service.hpp \
|
||||
asio/detail/posix_signal_blocker.hpp \
|
||||
asio/detail/posix_static_mutex.hpp \
|
||||
asio/detail/posix_thread.hpp \
|
||||
asio/detail/posix_tss_ptr.hpp \
|
||||
asio/detail/push_options.hpp \
|
||||
asio/detail/reactive_descriptor_service.hpp \
|
||||
asio/detail/reactive_null_buffers_op.hpp \
|
||||
asio/detail/reactive_socket_accept_op.hpp \
|
||||
asio/detail/reactive_socket_connect_op.hpp \
|
||||
asio/detail/reactive_socket_recvfrom_op.hpp \
|
||||
asio/detail/reactive_socket_recvmsg_op.hpp \
|
||||
asio/detail/reactive_socket_recv_op.hpp \
|
||||
asio/detail/reactive_socket_send_op.hpp \
|
||||
asio/detail/reactive_socket_sendto_op.hpp \
|
||||
asio/detail/reactive_socket_service_base.hpp \
|
||||
asio/detail/reactive_socket_service.hpp \
|
||||
asio/detail/reactive_wait_op.hpp \
|
||||
asio/detail/reactor.hpp \
|
||||
asio/detail/reactor_op.hpp \
|
||||
asio/detail/reactor_op_queue.hpp \
|
||||
asio/detail/recycling_allocator.hpp \
|
||||
asio/detail/regex_fwd.hpp \
|
||||
asio/detail/resolve_endpoint_op.hpp \
|
||||
asio/detail/resolve_op.hpp \
|
||||
asio/detail/resolve_query_op.hpp \
|
||||
asio/detail/resolver_service_base.hpp \
|
||||
asio/detail/resolver_service.hpp \
|
||||
asio/detail/scheduler.hpp \
|
||||
asio/detail/scheduler_operation.hpp \
|
||||
asio/detail/scheduler_task.hpp \
|
||||
asio/detail/scheduler_thread_info.hpp \
|
||||
asio/detail/scoped_lock.hpp \
|
||||
asio/detail/scoped_ptr.hpp \
|
||||
asio/detail/select_interrupter.hpp \
|
||||
asio/detail/select_reactor.hpp \
|
||||
asio/detail/service_registry.hpp \
|
||||
asio/detail/signal_blocker.hpp \
|
||||
asio/detail/signal_handler.hpp \
|
||||
asio/detail/signal_init.hpp \
|
||||
asio/detail/signal_op.hpp \
|
||||
asio/detail/signal_set_service.hpp \
|
||||
asio/detail/socket_holder.hpp \
|
||||
asio/detail/socket_ops.hpp \
|
||||
asio/detail/socket_option.hpp \
|
||||
asio/detail/socket_select_interrupter.hpp \
|
||||
asio/detail/socket_types.hpp \
|
||||
asio/detail/source_location.hpp \
|
||||
asio/detail/static_mutex.hpp \
|
||||
asio/detail/std_event.hpp \
|
||||
asio/detail/std_fenced_block.hpp \
|
||||
asio/detail/std_global.hpp \
|
||||
asio/detail/std_mutex.hpp \
|
||||
asio/detail/std_static_mutex.hpp \
|
||||
asio/detail/std_thread.hpp \
|
||||
asio/detail/strand_executor_service.hpp \
|
||||
asio/detail/strand_service.hpp \
|
||||
asio/detail/string_view.hpp \
|
||||
asio/detail/thread_context.hpp \
|
||||
asio/detail/thread_group.hpp \
|
||||
asio/detail/thread.hpp \
|
||||
asio/detail/thread_info_base.hpp \
|
||||
asio/detail/throw_error.hpp \
|
||||
asio/detail/throw_exception.hpp \
|
||||
asio/detail/timed_cancel_op.hpp \
|
||||
asio/detail/timer_queue_base.hpp \
|
||||
asio/detail/timer_queue.hpp \
|
||||
asio/detail/timer_queue_ptime.hpp \
|
||||
asio/detail/timer_queue_set.hpp \
|
||||
asio/detail/timer_scheduler_fwd.hpp \
|
||||
asio/detail/timer_scheduler.hpp \
|
||||
asio/detail/tss_ptr.hpp \
|
||||
asio/detail/type_traits.hpp \
|
||||
asio/detail/utility.hpp \
|
||||
asio/detail/wait_handler.hpp \
|
||||
asio/detail/wait_op.hpp \
|
||||
asio/detail/winapp_thread.hpp \
|
||||
asio/detail/wince_thread.hpp \
|
||||
asio/detail/win_event.hpp \
|
||||
asio/detail/win_fd_set_adapter.hpp \
|
||||
asio/detail/win_global.hpp \
|
||||
asio/detail/win_iocp_file_service.hpp \
|
||||
asio/detail/win_iocp_handle_read_op.hpp \
|
||||
asio/detail/win_iocp_handle_service.hpp \
|
||||
asio/detail/win_iocp_handle_write_op.hpp \
|
||||
asio/detail/win_iocp_io_context.hpp \
|
||||
asio/detail/win_iocp_null_buffers_op.hpp \
|
||||
asio/detail/win_iocp_operation.hpp \
|
||||
asio/detail/win_iocp_overlapped_op.hpp \
|
||||
asio/detail/win_iocp_overlapped_ptr.hpp \
|
||||
asio/detail/win_iocp_serial_port_service.hpp \
|
||||
asio/detail/win_iocp_socket_accept_op.hpp \
|
||||
asio/detail/win_iocp_socket_connect_op.hpp \
|
||||
asio/detail/win_iocp_socket_recvfrom_op.hpp \
|
||||
asio/detail/win_iocp_socket_recvmsg_op.hpp \
|
||||
asio/detail/win_iocp_socket_recv_op.hpp \
|
||||
asio/detail/win_iocp_socket_send_op.hpp \
|
||||
asio/detail/win_iocp_socket_service_base.hpp \
|
||||
asio/detail/win_iocp_socket_service.hpp \
|
||||
asio/detail/win_iocp_thread_info.hpp \
|
||||
asio/detail/win_iocp_wait_op.hpp \
|
||||
asio/detail/win_mutex.hpp \
|
||||
asio/detail/win_object_handle_service.hpp \
|
||||
asio/detail/winrt_async_manager.hpp \
|
||||
asio/detail/winrt_async_op.hpp \
|
||||
asio/detail/winrt_resolve_op.hpp \
|
||||
asio/detail/winrt_resolver_service.hpp \
|
||||
asio/detail/winrt_socket_connect_op.hpp \
|
||||
asio/detail/winrt_socket_recv_op.hpp \
|
||||
asio/detail/winrt_socket_send_op.hpp \
|
||||
asio/detail/winrt_ssocket_service_base.hpp \
|
||||
asio/detail/winrt_ssocket_service.hpp \
|
||||
asio/detail/winrt_timer_scheduler.hpp \
|
||||
asio/detail/winrt_utils.hpp \
|
||||
asio/detail/winsock_init.hpp \
|
||||
asio/detail/win_static_mutex.hpp \
|
||||
asio/detail/win_thread.hpp \
|
||||
asio/detail/win_tss_ptr.hpp \
|
||||
asio/detail/work_dispatcher.hpp \
|
||||
asio/detail/wrapped_handler.hpp \
|
||||
asio/dispatch.hpp \
|
||||
asio/error_code.hpp \
|
||||
asio/error.hpp \
|
||||
asio/execution.hpp \
|
||||
asio/execution_context.hpp \
|
||||
asio/execution/allocator.hpp \
|
||||
asio/execution/any_executor.hpp \
|
||||
asio/execution/bad_executor.hpp \
|
||||
asio/execution/blocking.hpp \
|
||||
asio/execution/blocking_adaptation.hpp \
|
||||
asio/execution/context.hpp \
|
||||
asio/execution/context_as.hpp \
|
||||
asio/execution/executor.hpp \
|
||||
asio/execution/impl/bad_executor.ipp \
|
||||
asio/execution/invocable_archetype.hpp \
|
||||
asio/execution/mapping.hpp \
|
||||
asio/execution/occupancy.hpp \
|
||||
asio/execution/outstanding_work.hpp \
|
||||
asio/execution/prefer_only.hpp \
|
||||
asio/execution/relationship.hpp \
|
||||
asio/executor.hpp \
|
||||
asio/executor_work_guard.hpp \
|
||||
asio/experimental/append.hpp \
|
||||
asio/experimental/as_single.hpp \
|
||||
asio/experimental/as_tuple.hpp \
|
||||
asio/experimental/awaitable_operators.hpp \
|
||||
asio/experimental/basic_channel.hpp \
|
||||
asio/experimental/basic_concurrent_channel.hpp \
|
||||
asio/experimental/cancellation_condition.hpp \
|
||||
asio/experimental/channel.hpp \
|
||||
asio/experimental/channel_error.hpp \
|
||||
asio/experimental/channel_traits.hpp \
|
||||
asio/experimental/co_composed.hpp \
|
||||
asio/experimental/co_spawn.hpp \
|
||||
asio/experimental/concurrent_channel.hpp \
|
||||
asio/experimental/coro.hpp \
|
||||
asio/experimental/coro_traits.hpp \
|
||||
asio/experimental/deferred.hpp \
|
||||
asio/experimental/detail/channel_operation.hpp \
|
||||
asio/experimental/detail/channel_receive_op.hpp \
|
||||
asio/experimental/detail/channel_send_functions.hpp \
|
||||
asio/experimental/detail/channel_send_op.hpp \
|
||||
asio/experimental/detail/channel_service.hpp \
|
||||
asio/experimental/detail/coro_completion_handler.hpp \
|
||||
asio/experimental/detail/coro_promise_allocator.hpp \
|
||||
asio/experimental/detail/has_signature.hpp \
|
||||
asio/experimental/detail/impl/channel_service.hpp \
|
||||
asio/experimental/detail/partial_promise.hpp \
|
||||
asio/experimental/impl/as_single.hpp \
|
||||
asio/experimental/impl/channel_error.ipp \
|
||||
asio/experimental/impl/coro.hpp \
|
||||
asio/experimental/impl/parallel_group.hpp \
|
||||
asio/experimental/impl/promise.hpp \
|
||||
asio/experimental/impl/use_coro.hpp \
|
||||
asio/experimental/impl/use_promise.hpp \
|
||||
asio/experimental/parallel_group.hpp \
|
||||
asio/experimental/prepend.hpp \
|
||||
asio/experimental/promise.hpp \
|
||||
asio/experimental/use_coro.hpp \
|
||||
asio/experimental/use_promise.hpp \
|
||||
asio/file_base.hpp \
|
||||
asio/generic/basic_endpoint.hpp \
|
||||
asio/generic/datagram_protocol.hpp \
|
||||
asio/generic/detail/endpoint.hpp \
|
||||
asio/generic/detail/impl/endpoint.ipp \
|
||||
asio/generic/raw_protocol.hpp \
|
||||
asio/generic/seq_packet_protocol.hpp \
|
||||
asio/generic/stream_protocol.hpp \
|
||||
asio/handler_continuation_hook.hpp \
|
||||
asio/high_resolution_timer.hpp \
|
||||
asio.hpp \
|
||||
asio/immediate.hpp \
|
||||
asio/impl/any_completion_executor.ipp \
|
||||
asio/impl/any_io_executor.ipp \
|
||||
asio/impl/append.hpp \
|
||||
asio/impl/as_tuple.hpp \
|
||||
asio/impl/awaitable.hpp \
|
||||
asio/impl/buffered_read_stream.hpp \
|
||||
asio/impl/buffered_write_stream.hpp \
|
||||
asio/impl/cancel_after.hpp \
|
||||
asio/impl/cancel_at.hpp \
|
||||
asio/impl/cancellation_signal.ipp \
|
||||
asio/impl/co_spawn.hpp \
|
||||
asio/impl/connect.hpp \
|
||||
asio/impl/connect_pipe.hpp \
|
||||
asio/impl/connect_pipe.ipp \
|
||||
asio/impl/consign.hpp \
|
||||
asio/impl/deferred.hpp \
|
||||
asio/impl/detached.hpp \
|
||||
asio/impl/error_code.ipp \
|
||||
asio/impl/error.ipp \
|
||||
asio/impl/execution_context.hpp \
|
||||
asio/impl/execution_context.ipp \
|
||||
asio/impl/executor.hpp \
|
||||
asio/impl/executor.ipp \
|
||||
asio/impl/io_context.hpp \
|
||||
asio/impl/io_context.ipp \
|
||||
asio/impl/multiple_exceptions.ipp \
|
||||
asio/impl/prepend.hpp \
|
||||
asio/impl/read_at.hpp \
|
||||
asio/impl/read.hpp \
|
||||
asio/impl/read_until.hpp \
|
||||
asio/impl/redirect_error.hpp \
|
||||
asio/impl/serial_port_base.hpp \
|
||||
asio/impl/serial_port_base.ipp \
|
||||
asio/impl/spawn.hpp \
|
||||
asio/impl/src.hpp \
|
||||
asio/impl/system_context.hpp \
|
||||
asio/impl/system_context.ipp \
|
||||
asio/impl/system_executor.hpp \
|
||||
asio/impl/thread_pool.hpp \
|
||||
asio/impl/thread_pool.ipp \
|
||||
asio/impl/use_awaitable.hpp \
|
||||
asio/impl/use_future.hpp \
|
||||
asio/impl/write_at.hpp \
|
||||
asio/impl/write.hpp \
|
||||
asio/io_context.hpp \
|
||||
asio/io_context_strand.hpp \
|
||||
asio/io_service.hpp \
|
||||
asio/io_service_strand.hpp \
|
||||
asio/ip/address.hpp \
|
||||
asio/ip/address_v4.hpp \
|
||||
asio/ip/address_v4_iterator.hpp \
|
||||
asio/ip/address_v4_range.hpp \
|
||||
asio/ip/address_v6.hpp \
|
||||
asio/ip/address_v6_iterator.hpp \
|
||||
asio/ip/address_v6_range.hpp \
|
||||
asio/ip/bad_address_cast.hpp \
|
||||
asio/ip/basic_endpoint.hpp \
|
||||
asio/ip/basic_resolver_entry.hpp \
|
||||
asio/ip/basic_resolver.hpp \
|
||||
asio/ip/basic_resolver_iterator.hpp \
|
||||
asio/ip/basic_resolver_query.hpp \
|
||||
asio/ip/basic_resolver_results.hpp \
|
||||
asio/ip/detail/endpoint.hpp \
|
||||
asio/ip/detail/impl/endpoint.ipp \
|
||||
asio/ip/detail/socket_option.hpp \
|
||||
asio/ip/host_name.hpp \
|
||||
asio/ip/icmp.hpp \
|
||||
asio/ip/impl/address.hpp \
|
||||
asio/ip/impl/address.ipp \
|
||||
asio/ip/impl/address_v4.hpp \
|
||||
asio/ip/impl/address_v4.ipp \
|
||||
asio/ip/impl/address_v6.hpp \
|
||||
asio/ip/impl/address_v6.ipp \
|
||||
asio/ip/impl/basic_endpoint.hpp \
|
||||
asio/ip/impl/host_name.ipp \
|
||||
asio/ip/impl/network_v4.hpp \
|
||||
asio/ip/impl/network_v4.ipp \
|
||||
asio/ip/impl/network_v6.hpp \
|
||||
asio/ip/impl/network_v6.ipp \
|
||||
asio/ip/multicast.hpp \
|
||||
asio/ip/network_v4.hpp \
|
||||
asio/ip/network_v6.hpp \
|
||||
asio/ip/resolver_base.hpp \
|
||||
asio/ip/resolver_query_base.hpp \
|
||||
asio/ip/tcp.hpp \
|
||||
asio/ip/udp.hpp \
|
||||
asio/ip/unicast.hpp \
|
||||
asio/ip/v6_only.hpp \
|
||||
asio/is_applicable_property.hpp \
|
||||
asio/is_contiguous_iterator.hpp \
|
||||
asio/is_executor.hpp \
|
||||
asio/is_read_buffered.hpp \
|
||||
asio/is_write_buffered.hpp \
|
||||
asio/local/basic_endpoint.hpp \
|
||||
asio/local/connect_pair.hpp \
|
||||
asio/local/datagram_protocol.hpp \
|
||||
asio/local/detail/endpoint.hpp \
|
||||
asio/local/detail/impl/endpoint.ipp \
|
||||
asio/local/seq_packet_protocol.hpp \
|
||||
asio/local/stream_protocol.hpp \
|
||||
asio/multiple_exceptions.hpp \
|
||||
asio/packaged_task.hpp \
|
||||
asio/placeholders.hpp \
|
||||
asio/posix/basic_descriptor.hpp \
|
||||
asio/posix/basic_stream_descriptor.hpp \
|
||||
asio/posix/descriptor_base.hpp \
|
||||
asio/posix/descriptor.hpp \
|
||||
asio/posix/stream_descriptor.hpp \
|
||||
asio/post.hpp \
|
||||
asio/prefer.hpp \
|
||||
asio/prepend.hpp \
|
||||
asio/query.hpp \
|
||||
asio/random_access_file.hpp \
|
||||
asio/read_at.hpp \
|
||||
asio/read.hpp \
|
||||
asio/read_until.hpp \
|
||||
asio/readable_pipe.hpp \
|
||||
asio/recycling_allocator.hpp \
|
||||
asio/redirect_error.hpp \
|
||||
asio/registered_buffer.hpp \
|
||||
asio/require.hpp \
|
||||
asio/require_concept.hpp \
|
||||
asio/serial_port_base.hpp \
|
||||
asio/serial_port.hpp \
|
||||
asio/signal_set_base.hpp \
|
||||
asio/signal_set.hpp \
|
||||
asio/socket_base.hpp \
|
||||
asio/spawn.hpp \
|
||||
asio/ssl/context_base.hpp \
|
||||
asio/ssl/context.hpp \
|
||||
asio/ssl/detail/buffered_handshake_op.hpp \
|
||||
asio/ssl/detail/engine.hpp \
|
||||
asio/ssl/detail/handshake_op.hpp \
|
||||
asio/ssl/detail/impl/engine.ipp \
|
||||
asio/ssl/detail/impl/openssl_init.ipp \
|
||||
asio/ssl/detail/io.hpp \
|
||||
asio/ssl/detail/openssl_init.hpp \
|
||||
asio/ssl/detail/openssl_types.hpp \
|
||||
asio/ssl/detail/password_callback.hpp \
|
||||
asio/ssl/detail/read_op.hpp \
|
||||
asio/ssl/detail/shutdown_op.hpp \
|
||||
asio/ssl/detail/stream_core.hpp \
|
||||
asio/ssl/detail/verify_callback.hpp \
|
||||
asio/ssl/detail/write_op.hpp \
|
||||
asio/ssl/error.hpp \
|
||||
asio/ssl.hpp \
|
||||
asio/ssl/host_name_verification.hpp \
|
||||
asio/ssl/impl/context.hpp \
|
||||
asio/ssl/impl/context.ipp \
|
||||
asio/ssl/impl/error.ipp \
|
||||
asio/ssl/impl/host_name_verification.ipp \
|
||||
asio/ssl/impl/rfc2818_verification.ipp \
|
||||
asio/ssl/impl/src.hpp \
|
||||
asio/ssl/rfc2818_verification.hpp \
|
||||
asio/ssl/stream_base.hpp \
|
||||
asio/ssl/stream.hpp \
|
||||
asio/ssl/verify_context.hpp \
|
||||
asio/ssl/verify_mode.hpp \
|
||||
asio/static_thread_pool.hpp \
|
||||
asio/steady_timer.hpp \
|
||||
asio/strand.hpp \
|
||||
asio/streambuf.hpp \
|
||||
asio/stream_file.hpp \
|
||||
asio/system_context.hpp \
|
||||
asio/system_error.hpp \
|
||||
asio/system_executor.hpp \
|
||||
asio/system_timer.hpp \
|
||||
asio/this_coro.hpp \
|
||||
asio/thread.hpp \
|
||||
asio/thread_pool.hpp \
|
||||
asio/time_traits.hpp \
|
||||
asio/traits/equality_comparable.hpp \
|
||||
asio/traits/execute_member.hpp \
|
||||
asio/traits/prefer_free.hpp \
|
||||
asio/traits/prefer_member.hpp \
|
||||
asio/traits/query_free.hpp \
|
||||
asio/traits/query_member.hpp \
|
||||
asio/traits/query_static_constexpr_member.hpp \
|
||||
asio/traits/require_concept_free.hpp \
|
||||
asio/traits/require_concept_member.hpp \
|
||||
asio/traits/require_free.hpp \
|
||||
asio/traits/require_member.hpp \
|
||||
asio/traits/static_query.hpp \
|
||||
asio/traits/static_require.hpp \
|
||||
asio/traits/static_require_concept.hpp \
|
||||
asio/ts/buffer.hpp \
|
||||
asio/ts/executor.hpp \
|
||||
asio/ts/internet.hpp \
|
||||
asio/ts/io_context.hpp \
|
||||
asio/ts/netfwd.hpp \
|
||||
asio/ts/net.hpp \
|
||||
asio/ts/socket.hpp \
|
||||
asio/ts/timer.hpp \
|
||||
asio/unyield.hpp \
|
||||
asio/use_awaitable.hpp \
|
||||
asio/use_future.hpp \
|
||||
asio/uses_executor.hpp \
|
||||
asio/version.hpp \
|
||||
asio/wait_traits.hpp \
|
||||
asio/windows/basic_object_handle.hpp \
|
||||
asio/windows/basic_overlapped_handle.hpp \
|
||||
asio/windows/basic_random_access_handle.hpp \
|
||||
asio/windows/basic_stream_handle.hpp \
|
||||
asio/windows/object_handle.hpp \
|
||||
asio/windows/overlapped_handle.hpp \
|
||||
asio/windows/overlapped_ptr.hpp \
|
||||
asio/windows/random_access_handle.hpp \
|
||||
asio/windows/stream_handle.hpp \
|
||||
asio/writable_pipe.hpp \
|
||||
asio/write_at.hpp \
|
||||
asio/write.hpp \
|
||||
asio/yield.hpp
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
$(srcdir)/Makefile.in
|
||||
205
third_party/socket.io-client-cpp/lib/asio/asio/include/asio.hpp
vendored
Normal file
205
third_party/socket.io-client-cpp/lib/asio/asio/include/asio.hpp
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// asio.hpp
|
||||
// ~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_HPP
|
||||
#define ASIO_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/any_completion_executor.hpp"
|
||||
#include "asio/any_completion_handler.hpp"
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/append.hpp"
|
||||
#include "asio/as_tuple.hpp"
|
||||
#include "asio/associated_allocator.hpp"
|
||||
#include "asio/associated_cancellation_slot.hpp"
|
||||
#include "asio/associated_executor.hpp"
|
||||
#include "asio/associated_immediate_executor.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/awaitable.hpp"
|
||||
#include "asio/basic_datagram_socket.hpp"
|
||||
#include "asio/basic_deadline_timer.hpp"
|
||||
#include "asio/basic_file.hpp"
|
||||
#include "asio/basic_io_object.hpp"
|
||||
#include "asio/basic_random_access_file.hpp"
|
||||
#include "asio/basic_raw_socket.hpp"
|
||||
#include "asio/basic_readable_pipe.hpp"
|
||||
#include "asio/basic_seq_packet_socket.hpp"
|
||||
#include "asio/basic_serial_port.hpp"
|
||||
#include "asio/basic_signal_set.hpp"
|
||||
#include "asio/basic_socket.hpp"
|
||||
#include "asio/basic_socket_acceptor.hpp"
|
||||
#include "asio/basic_socket_iostream.hpp"
|
||||
#include "asio/basic_socket_streambuf.hpp"
|
||||
#include "asio/basic_stream_file.hpp"
|
||||
#include "asio/basic_stream_socket.hpp"
|
||||
#include "asio/basic_streambuf.hpp"
|
||||
#include "asio/basic_waitable_timer.hpp"
|
||||
#include "asio/basic_writable_pipe.hpp"
|
||||
#include "asio/bind_allocator.hpp"
|
||||
#include "asio/bind_cancellation_slot.hpp"
|
||||
#include "asio/bind_executor.hpp"
|
||||
#include "asio/bind_immediate_executor.hpp"
|
||||
#include "asio/buffer.hpp"
|
||||
#include "asio/buffer_registration.hpp"
|
||||
#include "asio/buffered_read_stream_fwd.hpp"
|
||||
#include "asio/buffered_read_stream.hpp"
|
||||
#include "asio/buffered_stream_fwd.hpp"
|
||||
#include "asio/buffered_stream.hpp"
|
||||
#include "asio/buffered_write_stream_fwd.hpp"
|
||||
#include "asio/buffered_write_stream.hpp"
|
||||
#include "asio/buffers_iterator.hpp"
|
||||
#include "asio/cancel_after.hpp"
|
||||
#include "asio/cancel_at.hpp"
|
||||
#include "asio/cancellation_signal.hpp"
|
||||
#include "asio/cancellation_state.hpp"
|
||||
#include "asio/cancellation_type.hpp"
|
||||
#include "asio/co_composed.hpp"
|
||||
#include "asio/co_spawn.hpp"
|
||||
#include "asio/completion_condition.hpp"
|
||||
#include "asio/compose.hpp"
|
||||
#include "asio/composed.hpp"
|
||||
#include "asio/connect.hpp"
|
||||
#include "asio/connect_pipe.hpp"
|
||||
#include "asio/consign.hpp"
|
||||
#include "asio/coroutine.hpp"
|
||||
#include "asio/deadline_timer.hpp"
|
||||
#include "asio/defer.hpp"
|
||||
#include "asio/deferred.hpp"
|
||||
#include "asio/default_completion_token.hpp"
|
||||
#include "asio/detached.hpp"
|
||||
#include "asio/dispatch.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/error_code.hpp"
|
||||
#include "asio/execution.hpp"
|
||||
#include "asio/execution/allocator.hpp"
|
||||
#include "asio/execution/any_executor.hpp"
|
||||
#include "asio/execution/blocking.hpp"
|
||||
#include "asio/execution/blocking_adaptation.hpp"
|
||||
#include "asio/execution/context.hpp"
|
||||
#include "asio/execution/context_as.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/execution/invocable_archetype.hpp"
|
||||
#include "asio/execution/mapping.hpp"
|
||||
#include "asio/execution/occupancy.hpp"
|
||||
#include "asio/execution/outstanding_work.hpp"
|
||||
#include "asio/execution/prefer_only.hpp"
|
||||
#include "asio/execution/relationship.hpp"
|
||||
#include "asio/executor.hpp"
|
||||
#include "asio/executor_work_guard.hpp"
|
||||
#include "asio/file_base.hpp"
|
||||
#include "asio/generic/basic_endpoint.hpp"
|
||||
#include "asio/generic/datagram_protocol.hpp"
|
||||
#include "asio/generic/raw_protocol.hpp"
|
||||
#include "asio/generic/seq_packet_protocol.hpp"
|
||||
#include "asio/generic/stream_protocol.hpp"
|
||||
#include "asio/handler_continuation_hook.hpp"
|
||||
#include "asio/high_resolution_timer.hpp"
|
||||
#include "asio/immediate.hpp"
|
||||
#include "asio/io_context.hpp"
|
||||
#include "asio/io_context_strand.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/io_service_strand.hpp"
|
||||
#include "asio/ip/address.hpp"
|
||||
#include "asio/ip/address_v4.hpp"
|
||||
#include "asio/ip/address_v4_iterator.hpp"
|
||||
#include "asio/ip/address_v4_range.hpp"
|
||||
#include "asio/ip/address_v6.hpp"
|
||||
#include "asio/ip/address_v6_iterator.hpp"
|
||||
#include "asio/ip/address_v6_range.hpp"
|
||||
#include "asio/ip/network_v4.hpp"
|
||||
#include "asio/ip/network_v6.hpp"
|
||||
#include "asio/ip/bad_address_cast.hpp"
|
||||
#include "asio/ip/basic_endpoint.hpp"
|
||||
#include "asio/ip/basic_resolver.hpp"
|
||||
#include "asio/ip/basic_resolver_entry.hpp"
|
||||
#include "asio/ip/basic_resolver_iterator.hpp"
|
||||
#include "asio/ip/basic_resolver_query.hpp"
|
||||
#include "asio/ip/host_name.hpp"
|
||||
#include "asio/ip/icmp.hpp"
|
||||
#include "asio/ip/multicast.hpp"
|
||||
#include "asio/ip/resolver_base.hpp"
|
||||
#include "asio/ip/resolver_query_base.hpp"
|
||||
#include "asio/ip/tcp.hpp"
|
||||
#include "asio/ip/udp.hpp"
|
||||
#include "asio/ip/unicast.hpp"
|
||||
#include "asio/ip/v6_only.hpp"
|
||||
#include "asio/is_applicable_property.hpp"
|
||||
#include "asio/is_contiguous_iterator.hpp"
|
||||
#include "asio/is_executor.hpp"
|
||||
#include "asio/is_read_buffered.hpp"
|
||||
#include "asio/is_write_buffered.hpp"
|
||||
#include "asio/local/basic_endpoint.hpp"
|
||||
#include "asio/local/connect_pair.hpp"
|
||||
#include "asio/local/datagram_protocol.hpp"
|
||||
#include "asio/local/seq_packet_protocol.hpp"
|
||||
#include "asio/local/stream_protocol.hpp"
|
||||
#include "asio/multiple_exceptions.hpp"
|
||||
#include "asio/packaged_task.hpp"
|
||||
#include "asio/placeholders.hpp"
|
||||
#include "asio/posix/basic_descriptor.hpp"
|
||||
#include "asio/posix/basic_stream_descriptor.hpp"
|
||||
#include "asio/posix/descriptor.hpp"
|
||||
#include "asio/posix/descriptor_base.hpp"
|
||||
#include "asio/posix/stream_descriptor.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/prefer.hpp"
|
||||
#include "asio/prepend.hpp"
|
||||
#include "asio/query.hpp"
|
||||
#include "asio/random_access_file.hpp"
|
||||
#include "asio/read.hpp"
|
||||
#include "asio/read_at.hpp"
|
||||
#include "asio/read_until.hpp"
|
||||
#include "asio/readable_pipe.hpp"
|
||||
#include "asio/recycling_allocator.hpp"
|
||||
#include "asio/redirect_error.hpp"
|
||||
#include "asio/registered_buffer.hpp"
|
||||
#include "asio/require.hpp"
|
||||
#include "asio/require_concept.hpp"
|
||||
#include "asio/serial_port.hpp"
|
||||
#include "asio/serial_port_base.hpp"
|
||||
#include "asio/signal_set.hpp"
|
||||
#include "asio/signal_set_base.hpp"
|
||||
#include "asio/socket_base.hpp"
|
||||
#include "asio/static_thread_pool.hpp"
|
||||
#include "asio/steady_timer.hpp"
|
||||
#include "asio/strand.hpp"
|
||||
#include "asio/stream_file.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "asio/system_context.hpp"
|
||||
#include "asio/system_error.hpp"
|
||||
#include "asio/system_executor.hpp"
|
||||
#include "asio/system_timer.hpp"
|
||||
#include "asio/this_coro.hpp"
|
||||
#include "asio/thread.hpp"
|
||||
#include "asio/thread_pool.hpp"
|
||||
#include "asio/time_traits.hpp"
|
||||
#include "asio/use_awaitable.hpp"
|
||||
#include "asio/use_future.hpp"
|
||||
#include "asio/uses_executor.hpp"
|
||||
#include "asio/version.hpp"
|
||||
#include "asio/wait_traits.hpp"
|
||||
#include "asio/windows/basic_object_handle.hpp"
|
||||
#include "asio/windows/basic_overlapped_handle.hpp"
|
||||
#include "asio/windows/basic_random_access_handle.hpp"
|
||||
#include "asio/windows/basic_stream_handle.hpp"
|
||||
#include "asio/windows/object_handle.hpp"
|
||||
#include "asio/windows/overlapped_handle.hpp"
|
||||
#include "asio/windows/overlapped_ptr.hpp"
|
||||
#include "asio/windows/random_access_handle.hpp"
|
||||
#include "asio/windows/stream_handle.hpp"
|
||||
#include "asio/writable_pipe.hpp"
|
||||
#include "asio/write.hpp"
|
||||
#include "asio/write_at.hpp"
|
||||
|
||||
#endif // ASIO_HPP
|
||||
336
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_completion_executor.hpp
vendored
Normal file
336
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_completion_executor.hpp
vendored
Normal file
@@ -0,0 +1,336 @@
|
||||
//
|
||||
// any_completion_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ANY_COMPLETION_EXECUTOR_HPP
|
||||
#define ASIO_ANY_COMPLETION_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/executor.hpp"
|
||||
#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/execution.hpp"
|
||||
#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
typedef executor any_completion_executor;
|
||||
|
||||
#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
/// Polymorphic executor type for use with I/O objects.
|
||||
/**
|
||||
* The @c any_completion_executor type is a polymorphic executor that supports
|
||||
* the set of properties required for the execution of completion handlers. It
|
||||
* is defined as the execution::any_executor class template parameterised as
|
||||
* follows:
|
||||
* @code execution::any_executor<
|
||||
* execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
* execution::prefer_only<execution::outstanding_work_t::untracked_t>
|
||||
* execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
* execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
* > @endcode
|
||||
*/
|
||||
class any_completion_executor :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
public execution::any_executor<...>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
public execution::any_executor<
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
public:
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
typedef execution::any_executor<
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
> base_type;
|
||||
|
||||
typedef void supportable_properties_type(
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
);
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Default constructor.
|
||||
ASIO_DECL any_completion_executor() noexcept;
|
||||
|
||||
/// Construct in an empty state. Equivalent effects to default constructor.
|
||||
ASIO_DECL any_completion_executor(nullptr_t) noexcept;
|
||||
|
||||
/// Copy constructor.
|
||||
ASIO_DECL any_completion_executor(
|
||||
const any_completion_executor& e) noexcept;
|
||||
|
||||
/// Move constructor.
|
||||
ASIO_DECL any_completion_executor(
|
||||
any_completion_executor&& e) noexcept;
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <class... OtherSupportableProperties>
|
||||
any_completion_executor(
|
||||
execution::any_executor<OtherSupportableProperties...> e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename OtherAnyExecutor>
|
||||
any_completion_executor(OtherAnyExecutor e,
|
||||
constraint_t<
|
||||
conditional<
|
||||
!is_same<OtherAnyExecutor, any_completion_executor>::value
|
||||
&& is_base_of<execution::detail::any_executor_base,
|
||||
OtherAnyExecutor>::value,
|
||||
typename execution::detail::supportable_properties<
|
||||
0, supportable_properties_type>::template
|
||||
is_valid_target<OtherAnyExecutor>,
|
||||
false_type
|
||||
>::type::value
|
||||
> = 0)
|
||||
: base_type(static_cast<OtherAnyExecutor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <class... OtherSupportableProperties>
|
||||
any_completion_executor(std::nothrow_t,
|
||||
execution::any_executor<OtherSupportableProperties...> e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename OtherAnyExecutor>
|
||||
any_completion_executor(std::nothrow_t, OtherAnyExecutor e,
|
||||
constraint_t<
|
||||
conditional<
|
||||
!is_same<OtherAnyExecutor, any_completion_executor>::value
|
||||
&& is_base_of<execution::detail::any_executor_base,
|
||||
OtherAnyExecutor>::value,
|
||||
typename execution::detail::supportable_properties<
|
||||
0, supportable_properties_type>::template
|
||||
is_valid_target<OtherAnyExecutor>,
|
||||
false_type
|
||||
>::type::value
|
||||
> = 0) noexcept
|
||||
: base_type(std::nothrow, static_cast<OtherAnyExecutor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
ASIO_DECL any_completion_executor(std::nothrow_t,
|
||||
const any_completion_executor& e) noexcept;
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
ASIO_DECL any_completion_executor(std::nothrow_t,
|
||||
any_completion_executor&& e) noexcept;
|
||||
|
||||
/// Construct a polymorphic wrapper for the specified executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_completion_executor(Executor e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_completion_executor(Executor e,
|
||||
constraint_t<
|
||||
conditional<
|
||||
!is_same<Executor, any_completion_executor>::value
|
||||
&& !is_base_of<execution::detail::any_executor_base,
|
||||
Executor>::value,
|
||||
execution::detail::is_valid_target_executor<
|
||||
Executor, supportable_properties_type>,
|
||||
false_type
|
||||
>::type::value
|
||||
> = 0)
|
||||
: base_type(static_cast<Executor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct a polymorphic wrapper for the specified executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_completion_executor(std::nothrow_t, Executor e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_completion_executor(std::nothrow_t, Executor e,
|
||||
constraint_t<
|
||||
conditional<
|
||||
!is_same<Executor, any_completion_executor>::value
|
||||
&& !is_base_of<execution::detail::any_executor_base,
|
||||
Executor>::value,
|
||||
execution::detail::is_valid_target_executor<
|
||||
Executor, supportable_properties_type>,
|
||||
false_type
|
||||
>::type::value
|
||||
> = 0) noexcept
|
||||
: base_type(std::nothrow, static_cast<Executor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Assignment operator.
|
||||
ASIO_DECL any_completion_executor& operator=(
|
||||
const any_completion_executor& e) noexcept;
|
||||
|
||||
/// Move assignment operator.
|
||||
ASIO_DECL any_completion_executor& operator=(
|
||||
any_completion_executor&& e) noexcept;
|
||||
|
||||
/// Assignment operator that sets the polymorphic wrapper to the empty state.
|
||||
ASIO_DECL any_completion_executor& operator=(nullptr_t);
|
||||
|
||||
/// Destructor.
|
||||
ASIO_DECL ~any_completion_executor();
|
||||
|
||||
/// Swap targets with another polymorphic wrapper.
|
||||
ASIO_DECL void swap(any_completion_executor& other) noexcept;
|
||||
|
||||
/// Obtain a polymorphic wrapper with the specified property.
|
||||
/**
|
||||
* Do not call this function directly. It is intended for use with the
|
||||
* asio::require and asio::prefer customisation points.
|
||||
*
|
||||
* For example:
|
||||
* @code any_completion_executor ex = ...;
|
||||
* auto ex2 = asio::require(ex, execution::relationship.fork); @endcode
|
||||
*/
|
||||
template <typename Property>
|
||||
any_completion_executor require(const Property& p,
|
||||
constraint_t<
|
||||
traits::require_member<const base_type&, const Property&>::is_valid
|
||||
> = 0) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).require(p);
|
||||
}
|
||||
|
||||
/// Obtain a polymorphic wrapper with the specified property.
|
||||
/**
|
||||
* Do not call this function directly. It is intended for use with the
|
||||
* asio::prefer customisation point.
|
||||
*
|
||||
* For example:
|
||||
* @code any_completion_executor ex = ...;
|
||||
* auto ex2 = asio::prefer(ex, execution::relationship.fork); @endcode
|
||||
*/
|
||||
template <typename Property>
|
||||
any_completion_executor prefer(const Property& p,
|
||||
constraint_t<
|
||||
traits::prefer_member<const base_type&, const Property&>::is_valid
|
||||
> = 0) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_completion_executor any_completion_executor::prefer(
|
||||
const execution::outstanding_work_t::tracked_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_completion_executor any_completion_executor::prefer(
|
||||
const execution::outstanding_work_t::untracked_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_completion_executor any_completion_executor::prefer(
|
||||
const execution::relationship_t::fork_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_completion_executor any_completion_executor::prefer(
|
||||
const execution::relationship_t::continuation_t&, int) const;
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
|
||||
template <>
|
||||
struct equality_comparable<any_completion_executor>
|
||||
{
|
||||
static const bool is_valid = true;
|
||||
static const bool is_noexcept = true;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
|
||||
|
||||
template <typename F>
|
||||
struct execute_member<any_completion_executor, F>
|
||||
{
|
||||
static const bool is_valid = true;
|
||||
static const bool is_noexcept = false;
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct query_member<any_completion_executor, Prop> :
|
||||
query_member<any_completion_executor::base_type, Prop>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct require_member<any_completion_executor, Prop> :
|
||||
require_member<any_completion_executor::base_type, Prop>
|
||||
{
|
||||
typedef any_completion_executor result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct prefer_member<any_completion_executor, Prop> :
|
||||
prefer_member<any_completion_executor::base_type, Prop>
|
||||
{
|
||||
typedef any_completion_executor result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#if defined(ASIO_HEADER_ONLY) \
|
||||
&& !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/impl/any_completion_executor.ipp"
|
||||
#endif // defined(ASIO_HEADER_ONLY)
|
||||
// && !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#endif // ASIO_ANY_COMPLETION_EXECUTOR_HPP
|
||||
822
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_completion_handler.hpp
vendored
Normal file
822
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_completion_handler.hpp
vendored
Normal file
@@ -0,0 +1,822 @@
|
||||
//
|
||||
// any_completion_handler.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ANY_COMPLETION_HANDLER_HPP
|
||||
#define ASIO_ANY_COMPLETION_HANDLER_HPP
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include "asio/any_completion_executor.hpp"
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/associated_allocator.hpp"
|
||||
#include "asio/associated_cancellation_slot.hpp"
|
||||
#include "asio/associated_executor.hpp"
|
||||
#include "asio/associated_immediate_executor.hpp"
|
||||
#include "asio/cancellation_state.hpp"
|
||||
#include "asio/recycling_allocator.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class any_completion_handler_impl_base
|
||||
{
|
||||
public:
|
||||
template <typename S>
|
||||
explicit any_completion_handler_impl_base(S&& slot)
|
||||
: cancel_state_(static_cast<S&&>(slot), enable_total_cancellation())
|
||||
{
|
||||
}
|
||||
|
||||
cancellation_slot get_cancellation_slot() const noexcept
|
||||
{
|
||||
return cancel_state_.slot();
|
||||
}
|
||||
|
||||
private:
|
||||
cancellation_state cancel_state_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
class any_completion_handler_impl :
|
||||
public any_completion_handler_impl_base
|
||||
{
|
||||
public:
|
||||
template <typename S, typename H>
|
||||
any_completion_handler_impl(S&& slot, H&& h)
|
||||
: any_completion_handler_impl_base(static_cast<S&&>(slot)),
|
||||
handler_(static_cast<H&&>(h))
|
||||
{
|
||||
}
|
||||
|
||||
struct uninit_deleter
|
||||
{
|
||||
typename std::allocator_traits<
|
||||
associated_allocator_t<Handler,
|
||||
asio::recycling_allocator<void>>>::template
|
||||
rebind_alloc<any_completion_handler_impl> alloc;
|
||||
|
||||
void operator()(any_completion_handler_impl* ptr)
|
||||
{
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1);
|
||||
}
|
||||
};
|
||||
|
||||
struct deleter
|
||||
{
|
||||
typename std::allocator_traits<
|
||||
associated_allocator_t<Handler,
|
||||
asio::recycling_allocator<void>>>::template
|
||||
rebind_alloc<any_completion_handler_impl> alloc;
|
||||
|
||||
void operator()(any_completion_handler_impl* ptr)
|
||||
{
|
||||
std::allocator_traits<decltype(alloc)>::destroy(alloc, ptr);
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename S, typename H>
|
||||
static any_completion_handler_impl* create(S&& slot, H&& h)
|
||||
{
|
||||
uninit_deleter d{
|
||||
(get_associated_allocator)(h,
|
||||
asio::recycling_allocator<void>())};
|
||||
|
||||
std::unique_ptr<any_completion_handler_impl, uninit_deleter> uninit_ptr(
|
||||
std::allocator_traits<decltype(d.alloc)>::allocate(d.alloc, 1), d);
|
||||
|
||||
any_completion_handler_impl* ptr =
|
||||
new (uninit_ptr.get()) any_completion_handler_impl(
|
||||
static_cast<S&&>(slot), static_cast<H&&>(h));
|
||||
|
||||
uninit_ptr.release();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
deleter d{
|
||||
(get_associated_allocator)(handler_,
|
||||
asio::recycling_allocator<void>())};
|
||||
|
||||
d(this);
|
||||
}
|
||||
|
||||
any_completion_executor executor(
|
||||
const any_completion_executor& candidate) const noexcept
|
||||
{
|
||||
return any_completion_executor(std::nothrow,
|
||||
(get_associated_executor)(handler_, candidate));
|
||||
}
|
||||
|
||||
any_completion_executor immediate_executor(
|
||||
const any_io_executor& candidate) const noexcept
|
||||
{
|
||||
return any_completion_executor(std::nothrow,
|
||||
(get_associated_immediate_executor)(handler_, candidate));
|
||||
}
|
||||
|
||||
void* allocate(std::size_t size, std::size_t align) const
|
||||
{
|
||||
typename std::allocator_traits<
|
||||
associated_allocator_t<Handler,
|
||||
asio::recycling_allocator<void>>>::template
|
||||
rebind_alloc<unsigned char> alloc(
|
||||
(get_associated_allocator)(handler_,
|
||||
asio::recycling_allocator<void>()));
|
||||
|
||||
std::size_t space = size + align - 1;
|
||||
unsigned char* base =
|
||||
std::allocator_traits<decltype(alloc)>::allocate(
|
||||
alloc, space + sizeof(std::ptrdiff_t));
|
||||
|
||||
void* p = base;
|
||||
if (detail::align(align, size, p, space))
|
||||
{
|
||||
std::ptrdiff_t off = static_cast<unsigned char*>(p) - base;
|
||||
std::memcpy(static_cast<unsigned char*>(p) + size, &off, sizeof(off));
|
||||
return p;
|
||||
}
|
||||
|
||||
std::bad_alloc ex;
|
||||
asio::detail::throw_exception(ex);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void deallocate(void* p, std::size_t size, std::size_t align) const
|
||||
{
|
||||
if (p)
|
||||
{
|
||||
typename std::allocator_traits<
|
||||
associated_allocator_t<Handler,
|
||||
asio::recycling_allocator<void>>>::template
|
||||
rebind_alloc<unsigned char> alloc(
|
||||
(get_associated_allocator)(handler_,
|
||||
asio::recycling_allocator<void>()));
|
||||
|
||||
std::ptrdiff_t off;
|
||||
std::memcpy(&off, static_cast<unsigned char*>(p) + size, sizeof(off));
|
||||
unsigned char* base = static_cast<unsigned char*>(p) - off;
|
||||
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(
|
||||
alloc, base, size + align -1 + sizeof(std::ptrdiff_t));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void call(Args&&... args)
|
||||
{
|
||||
deleter d{
|
||||
(get_associated_allocator)(handler_,
|
||||
asio::recycling_allocator<void>())};
|
||||
|
||||
std::unique_ptr<any_completion_handler_impl, deleter> ptr(this, d);
|
||||
Handler handler(static_cast<Handler&&>(handler_));
|
||||
ptr.reset();
|
||||
|
||||
static_cast<Handler&&>(handler)(
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
Handler handler_;
|
||||
};
|
||||
|
||||
template <typename Signature>
|
||||
class any_completion_handler_call_fn;
|
||||
|
||||
template <typename R, typename... Args>
|
||||
class any_completion_handler_call_fn<R(Args...)>
|
||||
{
|
||||
public:
|
||||
using type = void(*)(any_completion_handler_impl_base*, Args...);
|
||||
|
||||
constexpr any_completion_handler_call_fn(type fn)
|
||||
: call_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
void call(any_completion_handler_impl_base* impl, Args... args) const
|
||||
{
|
||||
call_fn_(impl, static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static void impl(any_completion_handler_impl_base* impl, Args... args)
|
||||
{
|
||||
static_cast<any_completion_handler_impl<Handler>*>(impl)->call(
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
type call_fn_;
|
||||
};
|
||||
|
||||
template <typename... Signatures>
|
||||
class any_completion_handler_call_fns;
|
||||
|
||||
template <typename Signature>
|
||||
class any_completion_handler_call_fns<Signature> :
|
||||
public any_completion_handler_call_fn<Signature>
|
||||
{
|
||||
public:
|
||||
using any_completion_handler_call_fn<
|
||||
Signature>::any_completion_handler_call_fn;
|
||||
using any_completion_handler_call_fn<Signature>::call;
|
||||
};
|
||||
|
||||
template <typename Signature, typename... Signatures>
|
||||
class any_completion_handler_call_fns<Signature, Signatures...> :
|
||||
public any_completion_handler_call_fn<Signature>,
|
||||
public any_completion_handler_call_fns<Signatures...>
|
||||
{
|
||||
public:
|
||||
template <typename CallFn, typename... CallFns>
|
||||
constexpr any_completion_handler_call_fns(CallFn fn, CallFns... fns)
|
||||
: any_completion_handler_call_fn<Signature>(fn),
|
||||
any_completion_handler_call_fns<Signatures...>(fns...)
|
||||
{
|
||||
}
|
||||
|
||||
using any_completion_handler_call_fn<Signature>::call;
|
||||
using any_completion_handler_call_fns<Signatures...>::call;
|
||||
};
|
||||
|
||||
class any_completion_handler_destroy_fn
|
||||
{
|
||||
public:
|
||||
using type = void(*)(any_completion_handler_impl_base*);
|
||||
|
||||
constexpr any_completion_handler_destroy_fn(type fn)
|
||||
: destroy_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
void destroy(any_completion_handler_impl_base* impl) const
|
||||
{
|
||||
destroy_fn_(impl);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static void impl(any_completion_handler_impl_base* impl)
|
||||
{
|
||||
static_cast<any_completion_handler_impl<Handler>*>(impl)->destroy();
|
||||
}
|
||||
|
||||
private:
|
||||
type destroy_fn_;
|
||||
};
|
||||
|
||||
class any_completion_handler_executor_fn
|
||||
{
|
||||
public:
|
||||
using type = any_completion_executor(*)(
|
||||
any_completion_handler_impl_base*, const any_completion_executor&);
|
||||
|
||||
constexpr any_completion_handler_executor_fn(type fn)
|
||||
: executor_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor executor(any_completion_handler_impl_base* impl,
|
||||
const any_completion_executor& candidate) const
|
||||
{
|
||||
return executor_fn_(impl, candidate);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static any_completion_executor impl(any_completion_handler_impl_base* impl,
|
||||
const any_completion_executor& candidate)
|
||||
{
|
||||
return static_cast<any_completion_handler_impl<Handler>*>(impl)->executor(
|
||||
candidate);
|
||||
}
|
||||
|
||||
private:
|
||||
type executor_fn_;
|
||||
};
|
||||
|
||||
class any_completion_handler_immediate_executor_fn
|
||||
{
|
||||
public:
|
||||
using type = any_completion_executor(*)(
|
||||
any_completion_handler_impl_base*, const any_io_executor&);
|
||||
|
||||
constexpr any_completion_handler_immediate_executor_fn(type fn)
|
||||
: immediate_executor_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
any_completion_executor immediate_executor(
|
||||
any_completion_handler_impl_base* impl,
|
||||
const any_io_executor& candidate) const
|
||||
{
|
||||
return immediate_executor_fn_(impl, candidate);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static any_completion_executor impl(any_completion_handler_impl_base* impl,
|
||||
const any_io_executor& candidate)
|
||||
{
|
||||
return static_cast<any_completion_handler_impl<Handler>*>(
|
||||
impl)->immediate_executor(candidate);
|
||||
}
|
||||
|
||||
private:
|
||||
type immediate_executor_fn_;
|
||||
};
|
||||
|
||||
class any_completion_handler_allocate_fn
|
||||
{
|
||||
public:
|
||||
using type = void*(*)(any_completion_handler_impl_base*,
|
||||
std::size_t, std::size_t);
|
||||
|
||||
constexpr any_completion_handler_allocate_fn(type fn)
|
||||
: allocate_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
void* allocate(any_completion_handler_impl_base* impl,
|
||||
std::size_t size, std::size_t align) const
|
||||
{
|
||||
return allocate_fn_(impl, size, align);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static void* impl(any_completion_handler_impl_base* impl,
|
||||
std::size_t size, std::size_t align)
|
||||
{
|
||||
return static_cast<any_completion_handler_impl<Handler>*>(impl)->allocate(
|
||||
size, align);
|
||||
}
|
||||
|
||||
private:
|
||||
type allocate_fn_;
|
||||
};
|
||||
|
||||
class any_completion_handler_deallocate_fn
|
||||
{
|
||||
public:
|
||||
using type = void(*)(any_completion_handler_impl_base*,
|
||||
void*, std::size_t, std::size_t);
|
||||
|
||||
constexpr any_completion_handler_deallocate_fn(type fn)
|
||||
: deallocate_fn_(fn)
|
||||
{
|
||||
}
|
||||
|
||||
void deallocate(any_completion_handler_impl_base* impl,
|
||||
void* p, std::size_t size, std::size_t align) const
|
||||
{
|
||||
deallocate_fn_(impl, p, size, align);
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
static void impl(any_completion_handler_impl_base* impl,
|
||||
void* p, std::size_t size, std::size_t align)
|
||||
{
|
||||
static_cast<any_completion_handler_impl<Handler>*>(impl)->deallocate(
|
||||
p, size, align);
|
||||
}
|
||||
|
||||
private:
|
||||
type deallocate_fn_;
|
||||
};
|
||||
|
||||
template <typename... Signatures>
|
||||
class any_completion_handler_fn_table
|
||||
: private any_completion_handler_destroy_fn,
|
||||
private any_completion_handler_executor_fn,
|
||||
private any_completion_handler_immediate_executor_fn,
|
||||
private any_completion_handler_allocate_fn,
|
||||
private any_completion_handler_deallocate_fn,
|
||||
private any_completion_handler_call_fns<Signatures...>
|
||||
{
|
||||
public:
|
||||
template <typename... CallFns>
|
||||
constexpr any_completion_handler_fn_table(
|
||||
any_completion_handler_destroy_fn::type destroy_fn,
|
||||
any_completion_handler_executor_fn::type executor_fn,
|
||||
any_completion_handler_immediate_executor_fn::type immediate_executor_fn,
|
||||
any_completion_handler_allocate_fn::type allocate_fn,
|
||||
any_completion_handler_deallocate_fn::type deallocate_fn,
|
||||
CallFns... call_fns)
|
||||
: any_completion_handler_destroy_fn(destroy_fn),
|
||||
any_completion_handler_executor_fn(executor_fn),
|
||||
any_completion_handler_immediate_executor_fn(immediate_executor_fn),
|
||||
any_completion_handler_allocate_fn(allocate_fn),
|
||||
any_completion_handler_deallocate_fn(deallocate_fn),
|
||||
any_completion_handler_call_fns<Signatures...>(call_fns...)
|
||||
{
|
||||
}
|
||||
|
||||
using any_completion_handler_destroy_fn::destroy;
|
||||
using any_completion_handler_executor_fn::executor;
|
||||
using any_completion_handler_immediate_executor_fn::immediate_executor;
|
||||
using any_completion_handler_allocate_fn::allocate;
|
||||
using any_completion_handler_deallocate_fn::deallocate;
|
||||
using any_completion_handler_call_fns<Signatures...>::call;
|
||||
};
|
||||
|
||||
template <typename Handler, typename... Signatures>
|
||||
struct any_completion_handler_fn_table_instance
|
||||
{
|
||||
static constexpr any_completion_handler_fn_table<Signatures...>
|
||||
value = any_completion_handler_fn_table<Signatures...>(
|
||||
&any_completion_handler_destroy_fn::impl<Handler>,
|
||||
&any_completion_handler_executor_fn::impl<Handler>,
|
||||
&any_completion_handler_immediate_executor_fn::impl<Handler>,
|
||||
&any_completion_handler_allocate_fn::impl<Handler>,
|
||||
&any_completion_handler_deallocate_fn::impl<Handler>,
|
||||
&any_completion_handler_call_fn<Signatures>::template impl<Handler>...);
|
||||
};
|
||||
|
||||
template <typename Handler, typename... Signatures>
|
||||
constexpr any_completion_handler_fn_table<Signatures...>
|
||||
any_completion_handler_fn_table_instance<Handler, Signatures...>::value;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename... Signatures>
|
||||
class any_completion_handler;
|
||||
|
||||
/// An allocator type that forwards memory allocation operations through an
|
||||
/// instance of @c any_completion_handler.
|
||||
template <typename T, typename... Signatures>
|
||||
class any_completion_handler_allocator
|
||||
{
|
||||
private:
|
||||
template <typename...>
|
||||
friend class any_completion_handler;
|
||||
|
||||
template <typename, typename...>
|
||||
friend class any_completion_handler_allocator;
|
||||
|
||||
const detail::any_completion_handler_fn_table<Signatures...>* fn_table_;
|
||||
detail::any_completion_handler_impl_base* impl_;
|
||||
|
||||
constexpr any_completion_handler_allocator(int,
|
||||
const any_completion_handler<Signatures...>& h) noexcept
|
||||
: fn_table_(h.fn_table_),
|
||||
impl_(h.impl_)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
/// The type of objects that may be allocated by the allocator.
|
||||
typedef T value_type;
|
||||
|
||||
/// Rebinds an allocator to another value type.
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
/// Specifies the type of the rebound allocator.
|
||||
typedef any_completion_handler_allocator<U, Signatures...> other;
|
||||
};
|
||||
|
||||
/// Construct from another @c any_completion_handler_allocator.
|
||||
template <typename U>
|
||||
constexpr any_completion_handler_allocator(
|
||||
const any_completion_handler_allocator<U, Signatures...>& a)
|
||||
noexcept
|
||||
: fn_table_(a.fn_table_),
|
||||
impl_(a.impl_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Equality operator.
|
||||
constexpr bool operator==(
|
||||
const any_completion_handler_allocator& other) const noexcept
|
||||
{
|
||||
return fn_table_ == other.fn_table_ && impl_ == other.impl_;
|
||||
}
|
||||
|
||||
/// Inequality operator.
|
||||
constexpr bool operator!=(
|
||||
const any_completion_handler_allocator& other) const noexcept
|
||||
{
|
||||
return fn_table_ != other.fn_table_ || impl_ != other.impl_;
|
||||
}
|
||||
|
||||
/// Allocate space for @c n objects of the allocator's value type.
|
||||
T* allocate(std::size_t n) const
|
||||
{
|
||||
if (fn_table_)
|
||||
{
|
||||
return static_cast<T*>(
|
||||
fn_table_->allocate(
|
||||
impl_, sizeof(T) * n, alignof(T)));
|
||||
}
|
||||
std::bad_alloc ex;
|
||||
asio::detail::throw_exception(ex);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Deallocate space for @c n objects of the allocator's value type.
|
||||
void deallocate(T* p, std::size_t n) const
|
||||
{
|
||||
fn_table_->deallocate(impl_, p, sizeof(T) * n, alignof(T));
|
||||
}
|
||||
};
|
||||
|
||||
/// A protoco-allocator type that may be rebound to obtain an allocator that
|
||||
/// forwards memory allocation operations through an instance of
|
||||
/// @c any_completion_handler.
|
||||
template <typename... Signatures>
|
||||
class any_completion_handler_allocator<void, Signatures...>
|
||||
{
|
||||
private:
|
||||
template <typename...>
|
||||
friend class any_completion_handler;
|
||||
|
||||
template <typename, typename...>
|
||||
friend class any_completion_handler_allocator;
|
||||
|
||||
const detail::any_completion_handler_fn_table<Signatures...>* fn_table_;
|
||||
detail::any_completion_handler_impl_base* impl_;
|
||||
|
||||
constexpr any_completion_handler_allocator(int,
|
||||
const any_completion_handler<Signatures...>& h) noexcept
|
||||
: fn_table_(h.fn_table_),
|
||||
impl_(h.impl_)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
/// @c void as no objects can be allocated through a proto-allocator.
|
||||
typedef void value_type;
|
||||
|
||||
/// Rebinds an allocator to another value type.
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
/// Specifies the type of the rebound allocator.
|
||||
typedef any_completion_handler_allocator<U, Signatures...> other;
|
||||
};
|
||||
|
||||
/// Construct from another @c any_completion_handler_allocator.
|
||||
template <typename U>
|
||||
constexpr any_completion_handler_allocator(
|
||||
const any_completion_handler_allocator<U, Signatures...>& a)
|
||||
noexcept
|
||||
: fn_table_(a.fn_table_),
|
||||
impl_(a.impl_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Equality operator.
|
||||
constexpr bool operator==(
|
||||
const any_completion_handler_allocator& other) const noexcept
|
||||
{
|
||||
return fn_table_ == other.fn_table_ && impl_ == other.impl_;
|
||||
}
|
||||
|
||||
/// Inequality operator.
|
||||
constexpr bool operator!=(
|
||||
const any_completion_handler_allocator& other) const noexcept
|
||||
{
|
||||
return fn_table_ != other.fn_table_ || impl_ != other.impl_;
|
||||
}
|
||||
};
|
||||
|
||||
/// Polymorphic wrapper for completion handlers.
|
||||
/**
|
||||
* The @c any_completion_handler class template is a polymorphic wrapper for
|
||||
* completion handlers that propagates the associated executor, associated
|
||||
* allocator, and associated cancellation slot through a type-erasing interface.
|
||||
*
|
||||
* When using @c any_completion_handler, specify one or more completion
|
||||
* signatures as template parameters. These will dictate the arguments that may
|
||||
* be passed to the handler through the polymorphic interface.
|
||||
*
|
||||
* Typical uses for @c any_completion_handler include:
|
||||
*
|
||||
* @li Separate compilation of asynchronous operation implementations.
|
||||
*
|
||||
* @li Enabling interoperability between asynchronous operations and virtual
|
||||
* functions.
|
||||
*/
|
||||
template <typename... Signatures>
|
||||
class any_completion_handler
|
||||
{
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
private:
|
||||
template <typename, typename...>
|
||||
friend class any_completion_handler_allocator;
|
||||
|
||||
template <typename, typename>
|
||||
friend struct associated_executor;
|
||||
|
||||
template <typename, typename>
|
||||
friend struct associated_immediate_executor;
|
||||
|
||||
const detail::any_completion_handler_fn_table<Signatures...>* fn_table_;
|
||||
detail::any_completion_handler_impl_base* impl_;
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
public:
|
||||
/// The associated allocator type.
|
||||
using allocator_type = any_completion_handler_allocator<void, Signatures...>;
|
||||
|
||||
/// The associated cancellation slot type.
|
||||
using cancellation_slot_type = cancellation_slot;
|
||||
|
||||
/// Construct an @c any_completion_handler in an empty state, without a target
|
||||
/// object.
|
||||
constexpr any_completion_handler()
|
||||
: fn_table_(nullptr),
|
||||
impl_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an @c any_completion_handler in an empty state, without a target
|
||||
/// object.
|
||||
constexpr any_completion_handler(nullptr_t)
|
||||
: fn_table_(nullptr),
|
||||
impl_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct an @c any_completion_handler to contain the specified target.
|
||||
template <typename H, typename Handler = decay_t<H>>
|
||||
any_completion_handler(H&& h,
|
||||
constraint_t<
|
||||
!is_same<decay_t<H>, any_completion_handler>::value
|
||||
> = 0)
|
||||
: fn_table_(
|
||||
&detail::any_completion_handler_fn_table_instance<
|
||||
Handler, Signatures...>::value),
|
||||
impl_(detail::any_completion_handler_impl<Handler>::create(
|
||||
(get_associated_cancellation_slot)(h), static_cast<H&&>(h)))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-construct an @c any_completion_handler from another.
|
||||
/**
|
||||
* After the operation, the moved-from object @c other has no target.
|
||||
*/
|
||||
any_completion_handler(any_completion_handler&& other) noexcept
|
||||
: fn_table_(other.fn_table_),
|
||||
impl_(other.impl_)
|
||||
{
|
||||
other.fn_table_ = nullptr;
|
||||
other.impl_ = nullptr;
|
||||
}
|
||||
|
||||
/// Move-assign an @c any_completion_handler from another.
|
||||
/**
|
||||
* After the operation, the moved-from object @c other has no target.
|
||||
*/
|
||||
any_completion_handler& operator=(
|
||||
any_completion_handler&& other) noexcept
|
||||
{
|
||||
any_completion_handler(
|
||||
static_cast<any_completion_handler&&>(other)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assignment operator that sets the polymorphic wrapper to the empty state.
|
||||
any_completion_handler& operator=(nullptr_t) noexcept
|
||||
{
|
||||
any_completion_handler().swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
~any_completion_handler()
|
||||
{
|
||||
if (impl_)
|
||||
fn_table_->destroy(impl_);
|
||||
}
|
||||
|
||||
/// Test if the polymorphic wrapper is empty.
|
||||
constexpr explicit operator bool() const noexcept
|
||||
{
|
||||
return impl_ != nullptr;
|
||||
}
|
||||
|
||||
/// Test if the polymorphic wrapper is non-empty.
|
||||
constexpr bool operator!() const noexcept
|
||||
{
|
||||
return impl_ == nullptr;
|
||||
}
|
||||
|
||||
/// Swap the content of an @c any_completion_handler with another.
|
||||
void swap(any_completion_handler& other) noexcept
|
||||
{
|
||||
std::swap(fn_table_, other.fn_table_);
|
||||
std::swap(impl_, other.impl_);
|
||||
}
|
||||
|
||||
/// Get the associated allocator.
|
||||
allocator_type get_allocator() const noexcept
|
||||
{
|
||||
return allocator_type(0, *this);
|
||||
}
|
||||
|
||||
/// Get the associated cancellation slot.
|
||||
cancellation_slot_type get_cancellation_slot() const noexcept
|
||||
{
|
||||
return impl_ ? impl_->get_cancellation_slot() : cancellation_slot_type();
|
||||
}
|
||||
|
||||
/// Function call operator.
|
||||
/**
|
||||
* Invokes target completion handler with the supplied arguments.
|
||||
*
|
||||
* This function may only be called once, as the target handler is moved from.
|
||||
* The polymorphic wrapper is left in an empty state.
|
||||
*
|
||||
* Throws @c std::bad_function_call if the polymorphic wrapper is empty.
|
||||
*/
|
||||
template <typename... Args>
|
||||
auto operator()(Args&&... args)
|
||||
-> decltype(fn_table_->call(impl_, static_cast<Args&&>(args)...))
|
||||
{
|
||||
if (detail::any_completion_handler_impl_base* impl = impl_)
|
||||
{
|
||||
impl_ = nullptr;
|
||||
return fn_table_->call(impl, static_cast<Args&&>(args)...);
|
||||
}
|
||||
std::bad_function_call ex;
|
||||
asio::detail::throw_exception(ex);
|
||||
}
|
||||
|
||||
/// Equality operator.
|
||||
friend constexpr bool operator==(
|
||||
const any_completion_handler& a, nullptr_t) noexcept
|
||||
{
|
||||
return a.impl_ == nullptr;
|
||||
}
|
||||
|
||||
/// Equality operator.
|
||||
friend constexpr bool operator==(
|
||||
nullptr_t, const any_completion_handler& b) noexcept
|
||||
{
|
||||
return nullptr == b.impl_;
|
||||
}
|
||||
|
||||
/// Inequality operator.
|
||||
friend constexpr bool operator!=(
|
||||
const any_completion_handler& a, nullptr_t) noexcept
|
||||
{
|
||||
return a.impl_ != nullptr;
|
||||
}
|
||||
|
||||
/// Inequality operator.
|
||||
friend constexpr bool operator!=(
|
||||
nullptr_t, const any_completion_handler& b) noexcept
|
||||
{
|
||||
return nullptr != b.impl_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Signatures, typename Candidate>
|
||||
struct associated_executor<any_completion_handler<Signatures...>, Candidate>
|
||||
{
|
||||
using type = any_completion_executor;
|
||||
|
||||
static type get(const any_completion_handler<Signatures...>& handler,
|
||||
const Candidate& candidate = Candidate()) noexcept
|
||||
{
|
||||
any_completion_executor any_candidate(std::nothrow, candidate);
|
||||
return handler.fn_table_
|
||||
? handler.fn_table_->executor(handler.impl_, any_candidate)
|
||||
: any_candidate;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Signatures, typename Candidate>
|
||||
struct associated_immediate_executor<
|
||||
any_completion_handler<Signatures...>, Candidate>
|
||||
{
|
||||
using type = any_completion_executor;
|
||||
|
||||
static type get(const any_completion_handler<Signatures...>& handler,
|
||||
const Candidate& candidate = Candidate()) noexcept
|
||||
{
|
||||
any_io_executor any_candidate(std::nothrow, candidate);
|
||||
return handler.fn_table_
|
||||
? handler.fn_table_->immediate_executor(handler.impl_, any_candidate)
|
||||
: any_candidate;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ANY_COMPLETION_HANDLER_HPP
|
||||
351
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_io_executor.hpp
vendored
Normal file
351
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/any_io_executor.hpp
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
//
|
||||
// any_io_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ANY_IO_EXECUTOR_HPP
|
||||
#define ASIO_ANY_IO_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/executor.hpp"
|
||||
#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/execution.hpp"
|
||||
# include "asio/execution_context.hpp"
|
||||
#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
typedef executor any_io_executor;
|
||||
|
||||
#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
/// Polymorphic executor type for use with I/O objects.
|
||||
/**
|
||||
* The @c any_io_executor type is a polymorphic executor that supports the set
|
||||
* of properties required by I/O objects. It is defined as the
|
||||
* execution::any_executor class template parameterised as follows:
|
||||
* @code execution::any_executor<
|
||||
* execution::context_as_t<execution_context&>,
|
||||
* execution::blocking_t::never_t,
|
||||
* execution::prefer_only<execution::blocking_t::possibly_t>,
|
||||
* execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
* execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
* execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
* execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
* > @endcode
|
||||
*/
|
||||
class any_io_executor :
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
public execution::any_executor<...>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
public execution::any_executor<
|
||||
execution::context_as_t<execution_context&>,
|
||||
execution::blocking_t::never_t,
|
||||
execution::prefer_only<execution::blocking_t::possibly_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
public:
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
typedef execution::any_executor<
|
||||
execution::context_as_t<execution_context&>,
|
||||
execution::blocking_t::never_t,
|
||||
execution::prefer_only<execution::blocking_t::possibly_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
> base_type;
|
||||
|
||||
typedef void supportable_properties_type(
|
||||
execution::context_as_t<execution_context&>,
|
||||
execution::blocking_t::never_t,
|
||||
execution::prefer_only<execution::blocking_t::possibly_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::tracked_t>,
|
||||
execution::prefer_only<execution::outstanding_work_t::untracked_t>,
|
||||
execution::prefer_only<execution::relationship_t::fork_t>,
|
||||
execution::prefer_only<execution::relationship_t::continuation_t>
|
||||
);
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Default constructor.
|
||||
ASIO_DECL any_io_executor() noexcept;
|
||||
|
||||
/// Construct in an empty state. Equivalent effects to default constructor.
|
||||
ASIO_DECL any_io_executor(nullptr_t) noexcept;
|
||||
|
||||
/// Copy constructor.
|
||||
ASIO_DECL any_io_executor(const any_io_executor& e) noexcept;
|
||||
|
||||
/// Move constructor.
|
||||
ASIO_DECL any_io_executor(any_io_executor&& e) noexcept;
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <class... OtherSupportableProperties>
|
||||
any_io_executor(execution::any_executor<OtherSupportableProperties...> e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename OtherAnyExecutor>
|
||||
any_io_executor(OtherAnyExecutor e,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<OtherAnyExecutor, any_io_executor>::value
|
||||
&& is_base_of<execution::detail::any_executor_base,
|
||||
OtherAnyExecutor>::value,
|
||||
typename execution::detail::supportable_properties<
|
||||
0, supportable_properties_type>::template
|
||||
is_valid_target<OtherAnyExecutor>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0)
|
||||
: base_type(static_cast<OtherAnyExecutor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <class... OtherSupportableProperties>
|
||||
any_io_executor(std::nothrow_t,
|
||||
execution::any_executor<OtherSupportableProperties...> e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename OtherAnyExecutor>
|
||||
any_io_executor(std::nothrow_t, OtherAnyExecutor e,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<OtherAnyExecutor, any_io_executor>::value
|
||||
&& is_base_of<execution::detail::any_executor_base,
|
||||
OtherAnyExecutor>::value,
|
||||
typename execution::detail::supportable_properties<
|
||||
0, supportable_properties_type>::template
|
||||
is_valid_target<OtherAnyExecutor>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0) noexcept
|
||||
: base_type(std::nothrow, static_cast<OtherAnyExecutor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
ASIO_DECL any_io_executor(std::nothrow_t,
|
||||
const any_io_executor& e) noexcept;
|
||||
|
||||
/// Construct to point to the same target as another any_executor.
|
||||
ASIO_DECL any_io_executor(std::nothrow_t, any_io_executor&& e) noexcept;
|
||||
|
||||
/// Construct a polymorphic wrapper for the specified executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_io_executor(Executor e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_io_executor(Executor e,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<Executor, any_io_executor>::value
|
||||
&& !is_base_of<execution::detail::any_executor_base,
|
||||
Executor>::value,
|
||||
execution::detail::is_valid_target_executor<
|
||||
Executor, supportable_properties_type>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0)
|
||||
: base_type(static_cast<Executor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct a polymorphic wrapper for the specified executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_io_executor(std::nothrow_t, Executor e);
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <ASIO_EXECUTION_EXECUTOR Executor>
|
||||
any_io_executor(std::nothrow_t, Executor e,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<Executor, any_io_executor>::value
|
||||
&& !is_base_of<execution::detail::any_executor_base,
|
||||
Executor>::value,
|
||||
execution::detail::is_valid_target_executor<
|
||||
Executor, supportable_properties_type>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0) noexcept
|
||||
: base_type(std::nothrow, static_cast<Executor&&>(e))
|
||||
{
|
||||
}
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Assignment operator.
|
||||
ASIO_DECL any_io_executor& operator=(
|
||||
const any_io_executor& e) noexcept;
|
||||
|
||||
/// Move assignment operator.
|
||||
ASIO_DECL any_io_executor& operator=(any_io_executor&& e) noexcept;
|
||||
|
||||
/// Assignment operator that sets the polymorphic wrapper to the empty state.
|
||||
ASIO_DECL any_io_executor& operator=(nullptr_t);
|
||||
|
||||
/// Destructor.
|
||||
ASIO_DECL ~any_io_executor();
|
||||
|
||||
/// Swap targets with another polymorphic wrapper.
|
||||
ASIO_DECL void swap(any_io_executor& other) noexcept;
|
||||
|
||||
/// Obtain a polymorphic wrapper with the specified property.
|
||||
/**
|
||||
* Do not call this function directly. It is intended for use with the
|
||||
* asio::require and asio::prefer customisation points.
|
||||
*
|
||||
* For example:
|
||||
* @code any_io_executor ex = ...;
|
||||
* auto ex2 = asio::require(ex, execution::blocking.possibly); @endcode
|
||||
*/
|
||||
template <typename Property>
|
||||
any_io_executor require(const Property& p,
|
||||
constraint_t<
|
||||
traits::require_member<const base_type&, const Property&>::is_valid
|
||||
> = 0) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).require(p);
|
||||
}
|
||||
|
||||
/// Obtain a polymorphic wrapper with the specified property.
|
||||
/**
|
||||
* Do not call this function directly. It is intended for use with the
|
||||
* asio::prefer customisation point.
|
||||
*
|
||||
* For example:
|
||||
* @code any_io_executor ex = ...;
|
||||
* auto ex2 = asio::prefer(ex, execution::blocking.possibly); @endcode
|
||||
*/
|
||||
template <typename Property>
|
||||
any_io_executor prefer(const Property& p,
|
||||
constraint_t<
|
||||
traits::prefer_member<const base_type&, const Property&>::is_valid
|
||||
> = 0) const
|
||||
{
|
||||
return static_cast<const base_type&>(*this).prefer(p);
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::require(
|
||||
const execution::blocking_t::never_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::prefer(
|
||||
const execution::blocking_t::possibly_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::prefer(
|
||||
const execution::outstanding_work_t::tracked_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::prefer(
|
||||
const execution::outstanding_work_t::untracked_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::prefer(
|
||||
const execution::relationship_t::fork_t&, int) const;
|
||||
|
||||
template <>
|
||||
ASIO_DECL any_io_executor any_io_executor::prefer(
|
||||
const execution::relationship_t::continuation_t&, int) const;
|
||||
|
||||
namespace traits {
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
|
||||
template <>
|
||||
struct equality_comparable<any_io_executor>
|
||||
{
|
||||
static const bool is_valid = true;
|
||||
static const bool is_noexcept = true;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
|
||||
|
||||
template <typename F>
|
||||
struct execute_member<any_io_executor, F>
|
||||
{
|
||||
static const bool is_valid = true;
|
||||
static const bool is_noexcept = false;
|
||||
typedef void result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct query_member<any_io_executor, Prop> :
|
||||
query_member<any_io_executor::base_type, Prop>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct require_member<any_io_executor, Prop> :
|
||||
require_member<any_io_executor::base_type, Prop>
|
||||
{
|
||||
typedef any_io_executor result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
|
||||
|
||||
#if !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
|
||||
|
||||
template <typename Prop>
|
||||
struct prefer_member<any_io_executor, Prop> :
|
||||
prefer_member<any_io_executor::base_type, Prop>
|
||||
{
|
||||
typedef any_io_executor result_type;
|
||||
};
|
||||
|
||||
#endif // !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
|
||||
|
||||
} // namespace traits
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#if defined(ASIO_HEADER_ONLY) \
|
||||
&& !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
# include "asio/impl/any_io_executor.ipp"
|
||||
#endif // defined(ASIO_HEADER_ONLY)
|
||||
// && !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
|
||||
|
||||
#endif // ASIO_ANY_IO_EXECUTOR_HPP
|
||||
65
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/append.hpp
vendored
Normal file
65
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/append.hpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// append.hpp
|
||||
// ~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_APPEND_HPP
|
||||
#define ASIO_APPEND_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <tuple>
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Completion token type used to specify that the completion handler
|
||||
/// arguments should be passed additional values after the results of the
|
||||
/// operation.
|
||||
template <typename CompletionToken, typename... Values>
|
||||
class append_t
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
template <typename T, typename... V>
|
||||
constexpr explicit append_t(T&& completion_token, V&&... values)
|
||||
: token_(static_cast<T&&>(completion_token)),
|
||||
values_(static_cast<V&&>(values)...)
|
||||
{
|
||||
}
|
||||
|
||||
//private:
|
||||
CompletionToken token_;
|
||||
std::tuple<Values...> values_;
|
||||
};
|
||||
|
||||
/// Completion token type used to specify that the completion handler
|
||||
/// arguments should be passed additional values after the results of the
|
||||
/// operation.
|
||||
template <typename CompletionToken, typename... Values>
|
||||
ASIO_NODISCARD inline constexpr
|
||||
append_t<decay_t<CompletionToken>, decay_t<Values>...>
|
||||
append(CompletionToken&& completion_token, Values&&... values)
|
||||
{
|
||||
return append_t<decay_t<CompletionToken>, decay_t<Values>...>(
|
||||
static_cast<CompletionToken&&>(completion_token),
|
||||
static_cast<Values&&>(values)...);
|
||||
}
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/impl/append.hpp"
|
||||
|
||||
#endif // ASIO_APPEND_HPP
|
||||
152
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/as_tuple.hpp
vendored
Normal file
152
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/as_tuple.hpp
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// as_tuple.hpp
|
||||
// ~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_AS_TUPLE_HPP
|
||||
#define ASIO_AS_TUPLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// A @ref completion_token adapter used to specify that the completion handler
|
||||
/// arguments should be combined into a single tuple argument.
|
||||
/**
|
||||
* The as_tuple_t class is used to indicate that any arguments to the
|
||||
* completion handler should be combined and passed as a single tuple argument.
|
||||
* The arguments are first moved into a @c std::tuple and that tuple is then
|
||||
* passed to the completion handler.
|
||||
*/
|
||||
template <typename CompletionToken>
|
||||
class as_tuple_t
|
||||
{
|
||||
public:
|
||||
/// Tag type used to prevent the "default" constructor from being used for
|
||||
/// conversions.
|
||||
struct default_constructor_tag {};
|
||||
|
||||
/// Default constructor.
|
||||
/**
|
||||
* This constructor is only valid if the underlying completion token is
|
||||
* default constructible and move constructible. The underlying completion
|
||||
* token is itself defaulted as an argument to allow it to capture a source
|
||||
* location.
|
||||
*/
|
||||
constexpr as_tuple_t(
|
||||
default_constructor_tag = default_constructor_tag(),
|
||||
CompletionToken token = CompletionToken())
|
||||
: token_(static_cast<CompletionToken&&>(token))
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor.
|
||||
template <typename T>
|
||||
constexpr explicit as_tuple_t(
|
||||
T&& completion_token)
|
||||
: token_(static_cast<T&&>(completion_token))
|
||||
{
|
||||
}
|
||||
|
||||
/// Adapts an executor to add the @c as_tuple_t completion token as the
|
||||
/// default.
|
||||
template <typename InnerExecutor>
|
||||
struct executor_with_default : InnerExecutor
|
||||
{
|
||||
/// Specify @c as_tuple_t as the default completion token type.
|
||||
typedef as_tuple_t default_completion_token_type;
|
||||
|
||||
/// Construct the adapted executor from the inner executor type.
|
||||
template <typename InnerExecutor1>
|
||||
executor_with_default(const InnerExecutor1& ex,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<InnerExecutor1, executor_with_default>::value,
|
||||
is_convertible<InnerExecutor1, InnerExecutor>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0) noexcept
|
||||
: InnerExecutor(ex)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// Type alias to adapt an I/O object to use @c as_tuple_t as its
|
||||
/// default completion token type.
|
||||
template <typename T>
|
||||
using as_default_on_t = typename T::template rebind_executor<
|
||||
executor_with_default<typename T::executor_type>>::other;
|
||||
|
||||
/// Function helper to adapt an I/O object to use @c as_tuple_t as its
|
||||
/// default completion token type.
|
||||
template <typename T>
|
||||
static typename decay_t<T>::template rebind_executor<
|
||||
executor_with_default<typename decay_t<T>::executor_type>
|
||||
>::other
|
||||
as_default_on(T&& object)
|
||||
{
|
||||
return typename decay_t<T>::template rebind_executor<
|
||||
executor_with_default<typename decay_t<T>::executor_type>
|
||||
>::other(static_cast<T&&>(object));
|
||||
}
|
||||
|
||||
//private:
|
||||
CompletionToken token_;
|
||||
};
|
||||
|
||||
/// A function object type that adapts a @ref completion_token to specify that
|
||||
/// the completion handler arguments should be combined into a single tuple
|
||||
/// argument.
|
||||
/**
|
||||
* May also be used directly as a completion token, in which case it adapts the
|
||||
* asynchronous operation's default completion token (or asio::deferred
|
||||
* if no default is available).
|
||||
*/
|
||||
struct partial_as_tuple
|
||||
{
|
||||
/// Default constructor.
|
||||
constexpr partial_as_tuple()
|
||||
{
|
||||
}
|
||||
|
||||
/// Adapt a @ref completion_token to specify that the completion handler
|
||||
/// arguments should be combined into a single tuple argument.
|
||||
template <typename CompletionToken>
|
||||
ASIO_NODISCARD inline
|
||||
constexpr as_tuple_t<decay_t<CompletionToken>>
|
||||
operator()(CompletionToken&& completion_token) const
|
||||
{
|
||||
return as_tuple_t<decay_t<CompletionToken>>(
|
||||
static_cast<CompletionToken&&>(completion_token));
|
||||
}
|
||||
};
|
||||
|
||||
/// A function object that adapts a @ref completion_token to specify that the
|
||||
/// completion handler arguments should be combined into a single tuple
|
||||
/// argument.
|
||||
/**
|
||||
* May also be used directly as a completion token, in which case it adapts the
|
||||
* asynchronous operation's default completion token (or asio::deferred
|
||||
* if no default is available).
|
||||
*/
|
||||
constexpr partial_as_tuple as_tuple;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/impl/as_tuple.hpp"
|
||||
|
||||
#endif // ASIO_AS_TUPLE_HPP
|
||||
214
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_allocator.hpp
vendored
Normal file
214
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_allocator.hpp
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// associated_allocator.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASSOCIATED_ALLOCATOR_HPP
|
||||
#define ASIO_ASSOCIATED_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <memory>
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/detail/functional.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
struct associated_allocator;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct has_allocator_type : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct has_allocator_type<T, void_t<typename T::allocator_type>> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename A, typename = void, typename = void>
|
||||
struct associated_allocator_impl
|
||||
{
|
||||
typedef void asio_associated_allocator_is_unspecialised;
|
||||
|
||||
typedef A type;
|
||||
|
||||
static type get(const T&) noexcept
|
||||
{
|
||||
return type();
|
||||
}
|
||||
|
||||
static const type& get(const T&, const A& a) noexcept
|
||||
{
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename A>
|
||||
struct associated_allocator_impl<T, A, void_t<typename T::allocator_type>>
|
||||
{
|
||||
typedef typename T::allocator_type type;
|
||||
|
||||
static auto get(const T& t) noexcept
|
||||
-> decltype(t.get_allocator())
|
||||
{
|
||||
return t.get_allocator();
|
||||
}
|
||||
|
||||
static auto get(const T& t, const A&) noexcept
|
||||
-> decltype(t.get_allocator())
|
||||
{
|
||||
return t.get_allocator();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename A>
|
||||
struct associated_allocator_impl<T, A,
|
||||
enable_if_t<
|
||||
!has_allocator_type<T>::value
|
||||
>,
|
||||
void_t<
|
||||
typename associator<associated_allocator, T, A>::type
|
||||
>> : associator<associated_allocator, T, A>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the allocator associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* Allocator shall be a type meeting the Allocator requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c a is an object of type @c
|
||||
* Allocator.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* Allocator requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,a) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*/
|
||||
template <typename T, typename Allocator = std::allocator<void>>
|
||||
struct associated_allocator
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_allocator_impl<T, Allocator>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// If @c T has a nested type @c allocator_type, <tt>T::allocator_type</tt>.
|
||||
/// Otherwise @c Allocator.
|
||||
typedef see_below type;
|
||||
|
||||
/// If @c T has a nested type @c allocator_type, returns
|
||||
/// <tt>t.get_allocator()</tt>. Otherwise returns @c type().
|
||||
static decltype(auto) get(const T& t) noexcept;
|
||||
|
||||
/// If @c T has a nested type @c allocator_type, returns
|
||||
/// <tt>t.get_allocator()</tt>. Otherwise returns @c a.
|
||||
static decltype(auto) get(const T& t, const Allocator& a) noexcept;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated allocator.
|
||||
/**
|
||||
* @returns <tt>associated_allocator<T>::get(t)</tt>
|
||||
*/
|
||||
template <typename T>
|
||||
ASIO_NODISCARD inline typename associated_allocator<T>::type
|
||||
get_associated_allocator(const T& t) noexcept
|
||||
{
|
||||
return associated_allocator<T>::get(t);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated allocator.
|
||||
/**
|
||||
* @returns <tt>associated_allocator<T, Allocator>::get(t, a)</tt>
|
||||
*/
|
||||
template <typename T, typename Allocator>
|
||||
ASIO_NODISCARD inline auto get_associated_allocator(
|
||||
const T& t, const Allocator& a) noexcept
|
||||
-> decltype(associated_allocator<T, Allocator>::get(t, a))
|
||||
{
|
||||
return associated_allocator<T, Allocator>::get(t, a);
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator = std::allocator<void>>
|
||||
using associated_allocator_t
|
||||
= typename associated_allocator<T, Allocator>::type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename A, typename = void>
|
||||
struct associated_allocator_forwarding_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename A>
|
||||
struct associated_allocator_forwarding_base<T, A,
|
||||
enable_if_t<
|
||||
is_same<
|
||||
typename associated_allocator<T,
|
||||
A>::asio_associated_allocator_is_unspecialised,
|
||||
void
|
||||
>::value
|
||||
>>
|
||||
{
|
||||
typedef void asio_associated_allocator_is_unspecialised;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Specialisation of associated_allocator for @c std::reference_wrapper.
|
||||
template <typename T, typename Allocator>
|
||||
struct associated_allocator<reference_wrapper<T>, Allocator>
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_allocator_forwarding_base<T, Allocator>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
/// Forwards @c type to the associator specialisation for the unwrapped type
|
||||
/// @c T.
|
||||
typedef typename associated_allocator<T, Allocator>::type type;
|
||||
|
||||
/// Forwards the request to get the allocator to the associator specialisation
|
||||
/// for the unwrapped type @c T.
|
||||
static type get(reference_wrapper<T> t) noexcept
|
||||
{
|
||||
return associated_allocator<T, Allocator>::get(t.get());
|
||||
}
|
||||
|
||||
/// Forwards the request to get the allocator to the associator specialisation
|
||||
/// for the unwrapped type @c T.
|
||||
static auto get(reference_wrapper<T> t, const Allocator& a) noexcept
|
||||
-> decltype(associated_allocator<T, Allocator>::get(t.get(), a))
|
||||
{
|
||||
return associated_allocator<T, Allocator>::get(t.get(), a);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ASSOCIATED_ALLOCATOR_HPP
|
||||
221
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_cancellation_slot.hpp
vendored
Normal file
221
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_cancellation_slot.hpp
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// associated_cancellation_slot.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP
|
||||
#define ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/cancellation_signal.hpp"
|
||||
#include "asio/detail/functional.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename T, typename CancellationSlot>
|
||||
struct associated_cancellation_slot;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct has_cancellation_slot_type : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct has_cancellation_slot_type<T, void_t<typename T::cancellation_slot_type>>
|
||||
: true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename S, typename = void, typename = void>
|
||||
struct associated_cancellation_slot_impl
|
||||
{
|
||||
typedef void asio_associated_cancellation_slot_is_unspecialised;
|
||||
|
||||
typedef S type;
|
||||
|
||||
static type get(const T&) noexcept
|
||||
{
|
||||
return type();
|
||||
}
|
||||
|
||||
static const type& get(const T&, const S& s) noexcept
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename S>
|
||||
struct associated_cancellation_slot_impl<T, S,
|
||||
void_t<typename T::cancellation_slot_type>>
|
||||
{
|
||||
typedef typename T::cancellation_slot_type type;
|
||||
|
||||
static auto get(const T& t) noexcept
|
||||
-> decltype(t.get_cancellation_slot())
|
||||
{
|
||||
return t.get_cancellation_slot();
|
||||
}
|
||||
|
||||
static auto get(const T& t, const S&) noexcept
|
||||
-> decltype(t.get_cancellation_slot())
|
||||
{
|
||||
return t.get_cancellation_slot();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename S>
|
||||
struct associated_cancellation_slot_impl<T, S,
|
||||
enable_if_t<
|
||||
!has_cancellation_slot_type<T>::value
|
||||
>,
|
||||
void_t<
|
||||
typename associator<associated_cancellation_slot, T, S>::type
|
||||
>> : associator<associated_cancellation_slot, T, S>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the cancellation_slot associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* CancellationSlot shall be a type meeting the CancellationSlot requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c s is an object of type @c
|
||||
* CancellationSlot.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* CancellationSlot requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,s) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*/
|
||||
template <typename T, typename CancellationSlot = cancellation_slot>
|
||||
struct associated_cancellation_slot
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_cancellation_slot_impl<T, CancellationSlot>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// If @c T has a nested type @c cancellation_slot_type,
|
||||
/// <tt>T::cancellation_slot_type</tt>. Otherwise
|
||||
/// @c CancellationSlot.
|
||||
typedef see_below type;
|
||||
|
||||
/// If @c T has a nested type @c cancellation_slot_type, returns
|
||||
/// <tt>t.get_cancellation_slot()</tt>. Otherwise returns @c type().
|
||||
static decltype(auto) get(const T& t) noexcept;
|
||||
|
||||
/// If @c T has a nested type @c cancellation_slot_type, returns
|
||||
/// <tt>t.get_cancellation_slot()</tt>. Otherwise returns @c s.
|
||||
static decltype(auto) get(const T& t,
|
||||
const CancellationSlot& s) noexcept;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated cancellation_slot.
|
||||
/**
|
||||
* @returns <tt>associated_cancellation_slot<T>::get(t)</tt>
|
||||
*/
|
||||
template <typename T>
|
||||
ASIO_NODISCARD inline typename associated_cancellation_slot<T>::type
|
||||
get_associated_cancellation_slot(const T& t) noexcept
|
||||
{
|
||||
return associated_cancellation_slot<T>::get(t);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated cancellation_slot.
|
||||
/**
|
||||
* @returns <tt>associated_cancellation_slot<T,
|
||||
* CancellationSlot>::get(t, st)</tt>
|
||||
*/
|
||||
template <typename T, typename CancellationSlot>
|
||||
ASIO_NODISCARD inline auto get_associated_cancellation_slot(
|
||||
const T& t, const CancellationSlot& st) noexcept
|
||||
-> decltype(associated_cancellation_slot<T, CancellationSlot>::get(t, st))
|
||||
{
|
||||
return associated_cancellation_slot<T, CancellationSlot>::get(t, st);
|
||||
}
|
||||
|
||||
template <typename T, typename CancellationSlot = cancellation_slot>
|
||||
using associated_cancellation_slot_t =
|
||||
typename associated_cancellation_slot<T, CancellationSlot>::type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename S, typename = void>
|
||||
struct associated_cancellation_slot_forwarding_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename S>
|
||||
struct associated_cancellation_slot_forwarding_base<T, S,
|
||||
enable_if_t<
|
||||
is_same<
|
||||
typename associated_cancellation_slot<T,
|
||||
S>::asio_associated_cancellation_slot_is_unspecialised,
|
||||
void
|
||||
>::value
|
||||
>>
|
||||
{
|
||||
typedef void asio_associated_cancellation_slot_is_unspecialised;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Specialisation of associated_cancellation_slot for @c
|
||||
/// std::reference_wrapper.
|
||||
template <typename T, typename CancellationSlot>
|
||||
struct associated_cancellation_slot<reference_wrapper<T>, CancellationSlot>
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_cancellation_slot_forwarding_base<T, CancellationSlot>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
/// Forwards @c type to the associator specialisation for the unwrapped type
|
||||
/// @c T.
|
||||
typedef typename associated_cancellation_slot<T, CancellationSlot>::type type;
|
||||
|
||||
/// Forwards the request to get the cancellation slot to the associator
|
||||
/// specialisation for the unwrapped type @c T.
|
||||
static type get(reference_wrapper<T> t) noexcept
|
||||
{
|
||||
return associated_cancellation_slot<T, CancellationSlot>::get(t.get());
|
||||
}
|
||||
|
||||
/// Forwards the request to get the cancellation slot to the associator
|
||||
/// specialisation for the unwrapped type @c T.
|
||||
static auto get(reference_wrapper<T> t, const CancellationSlot& s) noexcept
|
||||
-> decltype(
|
||||
associated_cancellation_slot<T, CancellationSlot>::get(t.get(), s))
|
||||
{
|
||||
return associated_cancellation_slot<T, CancellationSlot>::get(t.get(), s);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP
|
||||
235
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_executor.hpp
vendored
Normal file
235
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_executor.hpp
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
//
|
||||
// associated_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASSOCIATED_EXECUTOR_HPP
|
||||
#define ASIO_ASSOCIATED_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/detail/functional.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/is_executor.hpp"
|
||||
#include "asio/system_executor.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename T, typename Executor>
|
||||
struct associated_executor;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct has_executor_type : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct has_executor_type<T, void_t<typename T::executor_type>>
|
||||
: true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename E, typename = void, typename = void>
|
||||
struct associated_executor_impl
|
||||
{
|
||||
typedef void asio_associated_executor_is_unspecialised;
|
||||
|
||||
typedef E type;
|
||||
|
||||
static type get(const T&) noexcept
|
||||
{
|
||||
return type();
|
||||
}
|
||||
|
||||
static const type& get(const T&, const E& e) noexcept
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_executor_impl<T, E, void_t<typename T::executor_type>>
|
||||
{
|
||||
typedef typename T::executor_type type;
|
||||
|
||||
static auto get(const T& t) noexcept
|
||||
-> decltype(t.get_executor())
|
||||
{
|
||||
return t.get_executor();
|
||||
}
|
||||
|
||||
static auto get(const T& t, const E&) noexcept
|
||||
-> decltype(t.get_executor())
|
||||
{
|
||||
return t.get_executor();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_executor_impl<T, E,
|
||||
enable_if_t<
|
||||
!has_executor_type<T>::value
|
||||
>,
|
||||
void_t<
|
||||
typename associator<associated_executor, T, E>::type
|
||||
>> : associator<associated_executor, T, E>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the executor associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* Executor shall be a type meeting the Executor requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c e is an object of type @c
|
||||
* Executor.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* Executor requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,e) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*/
|
||||
template <typename T, typename Executor = system_executor>
|
||||
struct associated_executor
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_executor_impl<T, Executor>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// If @c T has a nested type @c executor_type, <tt>T::executor_type</tt>.
|
||||
/// Otherwise @c Executor.
|
||||
typedef see_below type;
|
||||
|
||||
/// If @c T has a nested type @c executor_type, returns
|
||||
/// <tt>t.get_executor()</tt>. Otherwise returns @c type().
|
||||
static decltype(auto) get(const T& t) noexcept;
|
||||
|
||||
/// If @c T has a nested type @c executor_type, returns
|
||||
/// <tt>t.get_executor()</tt>. Otherwise returns @c ex.
|
||||
static decltype(auto) get(const T& t, const Executor& ex) noexcept;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T>::get(t)</tt>
|
||||
*/
|
||||
template <typename T>
|
||||
ASIO_NODISCARD inline typename associated_executor<T>::type
|
||||
get_associated_executor(const T& t) noexcept
|
||||
{
|
||||
return associated_executor<T>::get(t);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T, Executor>::get(t, ex)</tt>
|
||||
*/
|
||||
template <typename T, typename Executor>
|
||||
ASIO_NODISCARD inline auto get_associated_executor(
|
||||
const T& t, const Executor& ex,
|
||||
constraint_t<
|
||||
is_executor<Executor>::value || execution::is_executor<Executor>::value
|
||||
> = 0) noexcept
|
||||
-> decltype(associated_executor<T, Executor>::get(t, ex))
|
||||
{
|
||||
return associated_executor<T, Executor>::get(t, ex);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T, typename
|
||||
* ExecutionContext::executor_type>::get(t, ctx.get_executor())</tt>
|
||||
*/
|
||||
template <typename T, typename ExecutionContext>
|
||||
ASIO_NODISCARD inline typename associated_executor<T,
|
||||
typename ExecutionContext::executor_type>::type
|
||||
get_associated_executor(const T& t, ExecutionContext& ctx,
|
||||
constraint_t<is_convertible<ExecutionContext&,
|
||||
execution_context&>::value> = 0) noexcept
|
||||
{
|
||||
return associated_executor<T,
|
||||
typename ExecutionContext::executor_type>::get(t, ctx.get_executor());
|
||||
}
|
||||
|
||||
template <typename T, typename Executor = system_executor>
|
||||
using associated_executor_t = typename associated_executor<T, Executor>::type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename E, typename = void>
|
||||
struct associated_executor_forwarding_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_executor_forwarding_base<T, E,
|
||||
enable_if_t<
|
||||
is_same<
|
||||
typename associated_executor<T,
|
||||
E>::asio_associated_executor_is_unspecialised,
|
||||
void
|
||||
>::value
|
||||
>>
|
||||
{
|
||||
typedef void asio_associated_executor_is_unspecialised;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Specialisation of associated_executor for @c std::reference_wrapper.
|
||||
template <typename T, typename Executor>
|
||||
struct associated_executor<reference_wrapper<T>, Executor>
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_executor_forwarding_base<T, Executor>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
/// Forwards @c type to the associator specialisation for the unwrapped type
|
||||
/// @c T.
|
||||
typedef typename associated_executor<T, Executor>::type type;
|
||||
|
||||
/// Forwards the request to get the executor to the associator specialisation
|
||||
/// for the unwrapped type @c T.
|
||||
static type get(reference_wrapper<T> t) noexcept
|
||||
{
|
||||
return associated_executor<T, Executor>::get(t.get());
|
||||
}
|
||||
|
||||
/// Forwards the request to get the executor to the associator specialisation
|
||||
/// for the unwrapped type @c T.
|
||||
static auto get(reference_wrapper<T> t, const Executor& ex) noexcept
|
||||
-> decltype(associated_executor<T, Executor>::get(t.get(), ex))
|
||||
{
|
||||
return associated_executor<T, Executor>::get(t.get(), ex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ASSOCIATED_EXECUTOR_HPP
|
||||
281
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_immediate_executor.hpp
vendored
Normal file
281
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associated_immediate_executor.hpp
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
//
|
||||
// associated_immediate_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP
|
||||
#define ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/detail/functional.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/execution/blocking.hpp"
|
||||
#include "asio/execution/executor.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#include "asio/is_executor.hpp"
|
||||
#include "asio/require.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename T, typename Executor>
|
||||
struct associated_immediate_executor;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct has_immediate_executor_type : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct has_immediate_executor_type<T,
|
||||
void_t<typename T::immediate_executor_type>>
|
||||
: true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename E, typename = void, typename = void>
|
||||
struct default_immediate_executor
|
||||
{
|
||||
typedef decay_t<require_result_t<E, execution::blocking_t::never_t>> type;
|
||||
|
||||
static auto get(const E& e) noexcept
|
||||
-> decltype(asio::require(e, execution::blocking.never))
|
||||
{
|
||||
return asio::require(e, execution::blocking.never);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename E>
|
||||
struct default_immediate_executor<E,
|
||||
enable_if_t<
|
||||
!execution::is_executor<E>::value
|
||||
>,
|
||||
enable_if_t<
|
||||
is_executor<E>::value
|
||||
>>
|
||||
{
|
||||
class type : public E
|
||||
{
|
||||
public:
|
||||
template <typename Executor1>
|
||||
explicit type(const Executor1& e,
|
||||
constraint_t<
|
||||
conditional_t<
|
||||
!is_same<Executor1, type>::value,
|
||||
is_convertible<Executor1, E>,
|
||||
false_type
|
||||
>::value
|
||||
> = 0) noexcept
|
||||
: E(e)
|
||||
{
|
||||
}
|
||||
|
||||
type(const type& other) noexcept
|
||||
: E(static_cast<const E&>(other))
|
||||
{
|
||||
}
|
||||
|
||||
type(type&& other) noexcept
|
||||
: E(static_cast<E&&>(other))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Function, typename Allocator>
|
||||
void dispatch(Function&& f, const Allocator& a) const
|
||||
{
|
||||
this->post(static_cast<Function&&>(f), a);
|
||||
}
|
||||
|
||||
friend bool operator==(const type& a, const type& b) noexcept
|
||||
{
|
||||
return static_cast<const E&>(a) == static_cast<const E&>(b);
|
||||
}
|
||||
|
||||
friend bool operator!=(const type& a, const type& b) noexcept
|
||||
{
|
||||
return static_cast<const E&>(a) != static_cast<const E&>(b);
|
||||
}
|
||||
};
|
||||
|
||||
static type get(const E& e) noexcept
|
||||
{
|
||||
return type(e);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E, typename = void, typename = void>
|
||||
struct associated_immediate_executor_impl
|
||||
{
|
||||
typedef void asio_associated_immediate_executor_is_unspecialised;
|
||||
|
||||
typedef typename default_immediate_executor<E>::type type;
|
||||
|
||||
static auto get(const T&, const E& e) noexcept
|
||||
-> decltype(default_immediate_executor<E>::get(e))
|
||||
{
|
||||
return default_immediate_executor<E>::get(e);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_immediate_executor_impl<T, E,
|
||||
void_t<typename T::immediate_executor_type>>
|
||||
{
|
||||
typedef typename T::immediate_executor_type type;
|
||||
|
||||
static auto get(const T& t, const E&) noexcept
|
||||
-> decltype(t.get_immediate_executor())
|
||||
{
|
||||
return t.get_immediate_executor();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_immediate_executor_impl<T, E,
|
||||
enable_if_t<
|
||||
!has_immediate_executor_type<T>::value
|
||||
>,
|
||||
void_t<
|
||||
typename associator<associated_immediate_executor, T, E>::type
|
||||
>> : associator<associated_immediate_executor, T, E>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the immediate executor associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* Executor shall be a type meeting the Executor requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c e is an object of type @c
|
||||
* Executor.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* Executor requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,e) and with return type @c type or a (possibly const) reference to @c
|
||||
* type.
|
||||
*/
|
||||
template <typename T, typename Executor>
|
||||
struct associated_immediate_executor
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_immediate_executor_impl<T, Executor>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// If @c T has a nested type @c immediate_executor_type,
|
||||
// <tt>T::immediate_executor_type</tt>. Otherwise @c Executor.
|
||||
typedef see_below type;
|
||||
|
||||
/// If @c T has a nested type @c immediate_executor_type, returns
|
||||
/// <tt>t.get_immediate_executor()</tt>. Otherwise returns
|
||||
/// <tt>asio::require(ex, asio::execution::blocking.never)</tt>.
|
||||
static decltype(auto) get(const T& t, const Executor& ex) noexcept;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_immediate_executor<T, Executor>::get(t, ex)</tt>
|
||||
*/
|
||||
template <typename T, typename Executor>
|
||||
ASIO_NODISCARD inline auto get_associated_immediate_executor(
|
||||
const T& t, const Executor& ex,
|
||||
constraint_t<
|
||||
is_executor<Executor>::value || execution::is_executor<Executor>::value
|
||||
> = 0) noexcept
|
||||
-> decltype(associated_immediate_executor<T, Executor>::get(t, ex))
|
||||
{
|
||||
return associated_immediate_executor<T, Executor>::get(t, ex);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_immediate_executor<T, typename
|
||||
* ExecutionContext::executor_type>::get(t, ctx.get_executor())</tt>
|
||||
*/
|
||||
template <typename T, typename ExecutionContext>
|
||||
ASIO_NODISCARD inline typename associated_immediate_executor<T,
|
||||
typename ExecutionContext::executor_type>::type
|
||||
get_associated_immediate_executor(const T& t, ExecutionContext& ctx,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0) noexcept
|
||||
{
|
||||
return associated_immediate_executor<T,
|
||||
typename ExecutionContext::executor_type>::get(t, ctx.get_executor());
|
||||
}
|
||||
|
||||
template <typename T, typename Executor>
|
||||
using associated_immediate_executor_t =
|
||||
typename associated_immediate_executor<T, Executor>::type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename E, typename = void>
|
||||
struct associated_immediate_executor_forwarding_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_immediate_executor_forwarding_base<T, E,
|
||||
enable_if_t<
|
||||
is_same<
|
||||
typename associated_immediate_executor<T,
|
||||
E>::asio_associated_immediate_executor_is_unspecialised,
|
||||
void
|
||||
>::value
|
||||
>>
|
||||
{
|
||||
typedef void asio_associated_immediate_executor_is_unspecialised;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Specialisation of associated_immediate_executor for
|
||||
/// @c std::reference_wrapper.
|
||||
template <typename T, typename Executor>
|
||||
struct associated_immediate_executor<reference_wrapper<T>, Executor>
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: detail::associated_immediate_executor_forwarding_base<T, Executor>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
/// Forwards @c type to the associator specialisation for the unwrapped type
|
||||
/// @c T.
|
||||
typedef typename associated_immediate_executor<T, Executor>::type type;
|
||||
|
||||
/// Forwards the request to get the executor to the associator specialisation
|
||||
/// for the unwrapped type @c T.
|
||||
static auto get(reference_wrapper<T> t, const Executor& ex) noexcept
|
||||
-> decltype(associated_immediate_executor<T, Executor>::get(t.get(), ex))
|
||||
{
|
||||
return associated_immediate_executor<T, Executor>::get(t.get(), ex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP
|
||||
35
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associator.hpp
vendored
Normal file
35
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/associator.hpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// associator.hpp
|
||||
// ~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASSOCIATOR_HPP
|
||||
#define ASIO_ASSOCIATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Used to generically specialise associators for a type.
|
||||
template <template <typename, typename> class Associator,
|
||||
typename T, typename DefaultCandidate, typename _ = void>
|
||||
struct associator
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_ASSOCIATOR_HPP
|
||||
948
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/async_result.hpp
vendored
Normal file
948
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/async_result.hpp
vendored
Normal file
@@ -0,0 +1,948 @@
|
||||
//
|
||||
// async_result.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_ASYNC_RESULT_HPP
|
||||
#define ASIO_ASYNC_RESULT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct is_completion_signature : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...)> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...) &> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...) &&> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...) noexcept> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...) & noexcept> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_completion_signature<R(Args...) && noexcept> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename... T>
|
||||
struct are_completion_signatures : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct are_completion_signatures<>
|
||||
: true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T0>
|
||||
struct are_completion_signatures<T0>
|
||||
: is_completion_signature<T0>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T0, typename... TN>
|
||||
struct are_completion_signatures<T0, TN...>
|
||||
: integral_constant<bool, (
|
||||
is_completion_signature<T0>::value
|
||||
&& are_completion_signatures<TN...>::value)>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename... Args>
|
||||
ASIO_CONCEPT callable_with = requires(T&& t, Args&&... args)
|
||||
{
|
||||
static_cast<T&&>(t)(static_cast<Args&&>(args)...);
|
||||
};
|
||||
|
||||
template <typename T, typename... Signatures>
|
||||
struct is_completion_handler_for : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...)>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...) &>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>&, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...) &&>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>&&, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...) noexcept>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...) & noexcept>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>&, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename R, typename... Args>
|
||||
struct is_completion_handler_for<T, R(Args...) && noexcept>
|
||||
: integral_constant<bool, (callable_with<decay_t<T>&&, Args...>)>
|
||||
{
|
||||
};
|
||||
|
||||
# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename T, typename Signature0, typename... SignatureN>
|
||||
struct is_completion_handler_for<T, Signature0, SignatureN...>
|
||||
: integral_constant<bool, (
|
||||
is_completion_handler_for<T, Signature0>::value
|
||||
&& is_completion_handler_for<T, SignatureN...>::value)>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
ASIO_CONCEPT completion_signature =
|
||||
detail::is_completion_signature<T>::value;
|
||||
|
||||
#define ASIO_COMPLETION_SIGNATURE \
|
||||
::asio::completion_signature
|
||||
|
||||
template <typename T, typename... Signatures>
|
||||
ASIO_CONCEPT completion_handler_for =
|
||||
detail::are_completion_signatures<Signatures...>::value
|
||||
&& detail::is_completion_handler_for<T, Signatures...>::value;
|
||||
|
||||
#define ASIO_COMPLETION_HANDLER_FOR(sig) \
|
||||
::asio::completion_handler_for<sig>
|
||||
#define ASIO_COMPLETION_HANDLER_FOR2(sig0, sig1) \
|
||||
::asio::completion_handler_for<sig0, sig1>
|
||||
#define ASIO_COMPLETION_HANDLER_FOR3(sig0, sig1, sig2) \
|
||||
::asio::completion_handler_for<sig0, sig1, sig2>
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_COMPLETION_SIGNATURE typename
|
||||
#define ASIO_COMPLETION_HANDLER_FOR(sig) typename
|
||||
#define ASIO_COMPLETION_HANDLER_FOR2(sig0, sig1) typename
|
||||
#define ASIO_COMPLETION_HANDLER_FOR3(sig0, sig1, sig2) typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct is_lvalue_completion_signature : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_lvalue_completion_signature<R(Args...) &> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_lvalue_completion_signature<R(Args...) & noexcept> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename... Signatures>
|
||||
struct are_any_lvalue_completion_signatures : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Sig0>
|
||||
struct are_any_lvalue_completion_signatures<Sig0>
|
||||
: is_lvalue_completion_signature<Sig0>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Sig0, typename... SigN>
|
||||
struct are_any_lvalue_completion_signatures<Sig0, SigN...>
|
||||
: integral_constant<bool, (
|
||||
is_lvalue_completion_signature<Sig0>::value
|
||||
|| are_any_lvalue_completion_signatures<SigN...>::value)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_rvalue_completion_signature : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_rvalue_completion_signature<R(Args...) &&> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct is_rvalue_completion_signature<R(Args...) && noexcept> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename... Signatures>
|
||||
struct are_any_rvalue_completion_signatures : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Sig0>
|
||||
struct are_any_rvalue_completion_signatures<Sig0>
|
||||
: is_rvalue_completion_signature<Sig0>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Sig0, typename... SigN>
|
||||
struct are_any_rvalue_completion_signatures<Sig0, SigN...>
|
||||
: integral_constant<bool, (
|
||||
is_rvalue_completion_signature<Sig0>::value
|
||||
|| are_any_rvalue_completion_signatures<SigN...>::value)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct simple_completion_signature;
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...)>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...) &>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...) &&>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...) noexcept>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...) & noexcept>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct simple_completion_signature<R(Args...) && noexcept>
|
||||
{
|
||||
typedef R type(Args...);
|
||||
};
|
||||
|
||||
# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
|
||||
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
class completion_handler_async_result
|
||||
{
|
||||
public:
|
||||
typedef CompletionToken completion_handler_type;
|
||||
typedef void return_type;
|
||||
|
||||
explicit completion_handler_async_result(completion_handler_type&)
|
||||
{
|
||||
}
|
||||
|
||||
return_type get()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Initiation,
|
||||
ASIO_COMPLETION_HANDLER_FOR(Signatures...) RawCompletionToken,
|
||||
typename... Args>
|
||||
static return_type initiate(Initiation&& initiation,
|
||||
RawCompletionToken&& token, Args&&... args)
|
||||
{
|
||||
static_cast<Initiation&&>(initiation)(
|
||||
static_cast<RawCompletionToken&&>(token),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
completion_handler_async_result(
|
||||
const completion_handler_async_result&) = delete;
|
||||
completion_handler_async_result& operator=(
|
||||
const completion_handler_async_result&) = delete;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// An interface for customising the behaviour of an initiating function.
|
||||
/**
|
||||
* The async_result traits class is used for determining:
|
||||
*
|
||||
* @li the concrete completion handler type to be called at the end of the
|
||||
* asynchronous operation;
|
||||
*
|
||||
* @li the initiating function return type; and
|
||||
*
|
||||
* @li how the return value of the initiating function is obtained.
|
||||
*
|
||||
* The trait allows the handler and return types to be determined at the point
|
||||
* where the specific completion handler signature is known.
|
||||
*
|
||||
* This template may be specialised for user-defined completion token types.
|
||||
* The primary template assumes that the CompletionToken is the completion
|
||||
* handler.
|
||||
*/
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
class async_result
|
||||
{
|
||||
public:
|
||||
/// The concrete completion handler type for the specific signature.
|
||||
typedef CompletionToken completion_handler_type;
|
||||
|
||||
/// The return type of the initiating function.
|
||||
typedef void return_type;
|
||||
|
||||
/// Construct an async result from a given handler.
|
||||
/**
|
||||
* When using a specalised async_result, the constructor has an opportunity
|
||||
* to initialise some state associated with the completion handler, which is
|
||||
* then returned from the initiating function.
|
||||
*/
|
||||
explicit async_result(completion_handler_type& h);
|
||||
|
||||
/// Obtain the value to be returned from the initiating function.
|
||||
return_type get();
|
||||
|
||||
/// Initiate the asynchronous operation that will produce the result, and
|
||||
/// obtain the value to be returned from the initiating function.
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static return_type initiate(
|
||||
Initiation&& initiation,
|
||||
RawCompletionToken&& token,
|
||||
Args&&... args);
|
||||
|
||||
private:
|
||||
async_result(const async_result&) = delete;
|
||||
async_result& operator=(const async_result&) = delete;
|
||||
};
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
class async_result :
|
||||
public conditional_t<
|
||||
detail::are_any_lvalue_completion_signatures<Signatures...>::value
|
||||
|| !detail::are_any_rvalue_completion_signatures<Signatures...>::value,
|
||||
detail::completion_handler_async_result<CompletionToken, Signatures...>,
|
||||
async_result<CompletionToken,
|
||||
typename detail::simple_completion_signature<Signatures>::type...>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef conditional_t<
|
||||
detail::are_any_lvalue_completion_signatures<Signatures...>::value
|
||||
|| !detail::are_any_rvalue_completion_signatures<Signatures...>::value,
|
||||
detail::completion_handler_async_result<CompletionToken, Signatures...>,
|
||||
async_result<CompletionToken,
|
||||
typename detail::simple_completion_signature<Signatures>::type...>
|
||||
> base_type;
|
||||
|
||||
using base_type::base_type;
|
||||
|
||||
private:
|
||||
async_result(const async_result&) = delete;
|
||||
async_result& operator=(const async_result&) = delete;
|
||||
};
|
||||
|
||||
template <ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
class async_result<void, Signatures...>
|
||||
{
|
||||
// Empty.
|
||||
};
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Helper template to deduce the handler type from a CompletionToken, capture
|
||||
/// a local copy of the handler, and then create an async_result for the
|
||||
/// handler.
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
struct async_completion
|
||||
{
|
||||
/// The real handler type to be used for the asynchronous operation.
|
||||
typedef typename asio::async_result<
|
||||
decay_t<CompletionToken>, Signatures...>::completion_handler_type
|
||||
completion_handler_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* The constructor creates the concrete completion handler and makes the link
|
||||
* between the handler and the asynchronous result.
|
||||
*/
|
||||
explicit async_completion(CompletionToken& token)
|
||||
: completion_handler(static_cast<conditional_t<
|
||||
is_same<CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&, CompletionToken&&>>(token)),
|
||||
result(completion_handler)
|
||||
{
|
||||
}
|
||||
|
||||
/// A copy of, or reference to, a real handler object.
|
||||
conditional_t<
|
||||
is_same<CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&, completion_handler_type> completion_handler;
|
||||
|
||||
/// The result of the asynchronous operation's initiating function.
|
||||
async_result<decay_t<CompletionToken>, Signatures...> result;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct async_result_memfns_base
|
||||
{
|
||||
void initiate();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct async_result_memfns_derived
|
||||
: T, async_result_memfns_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, T>
|
||||
struct async_result_memfns_check
|
||||
{
|
||||
};
|
||||
|
||||
template <typename>
|
||||
char (&async_result_initiate_memfn_helper(...))[2];
|
||||
|
||||
template <typename T>
|
||||
char async_result_initiate_memfn_helper(
|
||||
async_result_memfns_check<
|
||||
void (async_result_memfns_base::*)(),
|
||||
&async_result_memfns_derived<T>::initiate>*);
|
||||
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures>
|
||||
struct async_result_has_initiate_memfn
|
||||
: integral_constant<bool, sizeof(async_result_initiate_memfn_helper<
|
||||
async_result<decay_t<CompletionToken>, Signatures...>
|
||||
>(0)) != 1>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define ASIO_INITFN_RESULT_TYPE(ct, sig) \
|
||||
void_or_deduced
|
||||
# define ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) \
|
||||
void_or_deduced
|
||||
# define ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \
|
||||
void_or_deduced
|
||||
#else
|
||||
# define ASIO_INITFN_RESULT_TYPE(ct, sig) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, sig>::return_type
|
||||
# define ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, sig0, sig1>::return_type
|
||||
# define ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, sig0, sig1, sig2>::return_type
|
||||
#define ASIO_HANDLER_TYPE(ct, sig) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, sig>::completion_handler_type
|
||||
#define ASIO_HANDLER_TYPE2(ct, sig0, sig1) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, \
|
||||
sig0, sig1>::completion_handler_type
|
||||
#define ASIO_HANDLER_TYPE3(ct, sig0, sig1, sig2) \
|
||||
typename ::asio::async_result< \
|
||||
typename ::asio::decay<ct>::type, \
|
||||
sig0, sig1, sig2>::completion_handler_type
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE(ct, sig) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE2(ct, sig0, sig1) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE3(ct, sig0, sig1, sig2) \
|
||||
auto
|
||||
#elif defined(ASIO_HAS_RETURN_TYPE_DEDUCTION)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE(ct, sig) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE2(ct, sig0, sig1) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE3(ct, sig0, sig1, sig2) \
|
||||
auto
|
||||
#else
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE(ct, sig) \
|
||||
ASIO_INITFN_RESULT_TYPE(ct, sig)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE2(ct, sig0, sig1) \
|
||||
ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE3(ct, sig0, sig1, sig2) \
|
||||
ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2)
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr)
|
||||
#elif defined(ASIO_HAS_RETURN_TYPE_DEDUCTION)
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr)
|
||||
#else
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \
|
||||
auto
|
||||
# define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) -> decltype expr
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \
|
||||
void_or_deduced
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \
|
||||
void_or_deduced
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \
|
||||
void_or_deduced
|
||||
#else
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \
|
||||
decltype expr
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \
|
||||
decltype expr
|
||||
# define ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \
|
||||
decltype expr
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken,
|
||||
completion_signature... Signatures,
|
||||
typename Initiation, typename... Args>
|
||||
void_or_deduced async_initiate(
|
||||
Initiation&& initiation,
|
||||
type_identity_t<CompletionToken>& token,
|
||||
Args&&... args);
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures,
|
||||
typename Initiation, typename... Args>
|
||||
inline auto async_initiate(Initiation&& initiation,
|
||||
type_identity_t<CompletionToken>& token, Args&&... args)
|
||||
-> decltype(enable_if_t<
|
||||
enable_if_t<
|
||||
detail::are_completion_signatures<Signatures...>::value,
|
||||
detail::async_result_has_initiate_memfn<
|
||||
CompletionToken, Signatures...>>::value,
|
||||
async_result<decay_t<CompletionToken>, Signatures...>>::initiate(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
static_cast<CompletionToken&&>(token),
|
||||
static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_result<decay_t<CompletionToken>, Signatures...>::initiate(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
static_cast<CompletionToken&&>(token),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures,
|
||||
typename CompletionToken, typename Initiation, typename... Args>
|
||||
inline auto async_initiate(Initiation&& initiation,
|
||||
CompletionToken&& token, Args&&... args)
|
||||
-> decltype(enable_if_t<
|
||||
enable_if_t<
|
||||
detail::are_completion_signatures<Signatures...>::value,
|
||||
detail::async_result_has_initiate_memfn<
|
||||
CompletionToken, Signatures...>>::value,
|
||||
async_result<decay_t<CompletionToken>, Signatures...>>::initiate(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
static_cast<CompletionToken&&>(token),
|
||||
static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_result<decay_t<CompletionToken>, Signatures...>::initiate(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
static_cast<CompletionToken&&>(token),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename CompletionToken,
|
||||
ASIO_COMPLETION_SIGNATURE... Signatures,
|
||||
typename Initiation, typename... Args>
|
||||
inline typename enable_if_t<
|
||||
!enable_if_t<
|
||||
detail::are_completion_signatures<Signatures...>::value,
|
||||
detail::async_result_has_initiate_memfn<
|
||||
CompletionToken, Signatures...>>::value,
|
||||
async_result<decay_t<CompletionToken>, Signatures...>
|
||||
>::return_type
|
||||
async_initiate(Initiation&& initiation,
|
||||
type_identity_t<CompletionToken>& token, Args&&... args)
|
||||
{
|
||||
async_completion<CompletionToken, Signatures...> completion(token);
|
||||
|
||||
static_cast<Initiation&&>(initiation)(
|
||||
static_cast<
|
||||
typename async_result<decay_t<CompletionToken>,
|
||||
Signatures...>::completion_handler_type&&>(
|
||||
completion.completion_handler),
|
||||
static_cast<Args&&>(args)...);
|
||||
|
||||
return completion.result.get();
|
||||
}
|
||||
|
||||
template <ASIO_COMPLETION_SIGNATURE... Signatures,
|
||||
typename CompletionToken, typename Initiation, typename... Args>
|
||||
inline typename enable_if_t<
|
||||
!enable_if_t<
|
||||
detail::are_completion_signatures<Signatures...>::value,
|
||||
detail::async_result_has_initiate_memfn<
|
||||
CompletionToken, Signatures...>>::value,
|
||||
async_result<decay_t<CompletionToken>, Signatures...>
|
||||
>::return_type
|
||||
async_initiate(Initiation&& initiation, CompletionToken&& token, Args&&... args)
|
||||
{
|
||||
async_completion<CompletionToken, Signatures...> completion(token);
|
||||
|
||||
static_cast<Initiation&&>(initiation)(
|
||||
static_cast<
|
||||
typename async_result<decay_t<CompletionToken>,
|
||||
Signatures...>::completion_handler_type&&>(
|
||||
completion.completion_handler),
|
||||
static_cast<Args&&>(args)...);
|
||||
|
||||
return completion.result.get();
|
||||
}
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename... Signatures>
|
||||
struct initiation_archetype
|
||||
{
|
||||
template <completion_handler_for<Signatures...> CompletionHandler>
|
||||
void operator()(CompletionHandler&&) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T, typename... Signatures>
|
||||
ASIO_CONCEPT completion_token_for =
|
||||
detail::are_completion_signatures<Signatures...>::value
|
||||
&&
|
||||
requires(T&& t)
|
||||
{
|
||||
async_initiate<T, Signatures...>(
|
||||
detail::initiation_archetype<Signatures...>{}, t);
|
||||
};
|
||||
|
||||
#define ASIO_COMPLETION_TOKEN_FOR(sig) \
|
||||
::asio::completion_token_for<sig>
|
||||
#define ASIO_COMPLETION_TOKEN_FOR2(sig0, sig1) \
|
||||
::asio::completion_token_for<sig0, sig1>
|
||||
#define ASIO_COMPLETION_TOKEN_FOR3(sig0, sig1, sig2) \
|
||||
::asio::completion_token_for<sig0, sig1, sig2>
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_COMPLETION_TOKEN_FOR(sig) typename
|
||||
#define ASIO_COMPLETION_TOKEN_FOR2(sig0, sig1) typename
|
||||
#define ASIO_COMPLETION_TOKEN_FOR3(sig0, sig1, sig2) typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct async_operation_probe {};
|
||||
struct async_operation_probe_result {};
|
||||
|
||||
template <typename Call, typename = void>
|
||||
struct is_async_operation_call : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Call>
|
||||
struct is_async_operation_call<Call,
|
||||
void_t<
|
||||
enable_if_t<
|
||||
is_same<
|
||||
result_of_t<Call>,
|
||||
async_operation_probe_result
|
||||
>::value
|
||||
>
|
||||
>
|
||||
> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename... Signatures>
|
||||
class async_result<detail::async_operation_probe, Signatures...>
|
||||
{
|
||||
public:
|
||||
typedef detail::async_operation_probe_result return_type;
|
||||
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static return_type initiate(Initiation&&,
|
||||
detail::async_operation_probe, InitArgs&&...)
|
||||
{
|
||||
return return_type();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The is_async_operation trait detects whether a type @c T and arguments
|
||||
/// @c Args... may be used to initiate an asynchronous operation.
|
||||
/**
|
||||
* Class template @c is_async_operation is a trait is derived from @c true_type
|
||||
* if the expression <tt>T(Args..., token)</tt> initiates an asynchronous
|
||||
* operation, where @c token is an unspecified completion token type. Otherwise,
|
||||
* @c is_async_operation is derived from @c false_type.
|
||||
*/
|
||||
template <typename T, typename... Args>
|
||||
struct is_async_operation : integral_constant<bool, automatically_determined>
|
||||
{
|
||||
};
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename T, typename... Args>
|
||||
struct is_async_operation :
|
||||
detail::is_async_operation_call<
|
||||
T(Args..., detail::async_operation_probe)>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
template <typename T, typename... Args>
|
||||
ASIO_CONCEPT async_operation = is_async_operation<T, Args...>::value;
|
||||
|
||||
#define ASIO_ASYNC_OPERATION(t) \
|
||||
::asio::async_operation<t>
|
||||
#define ASIO_ASYNC_OPERATION1(t, a0) \
|
||||
::asio::async_operation<t, a0>
|
||||
#define ASIO_ASYNC_OPERATION2(t, a0, a1) \
|
||||
::asio::async_operation<t, a0, a1>
|
||||
#define ASIO_ASYNC_OPERATION3(t, a0, a1, a2) \
|
||||
::asio::async_operation<t, a0, a1, a2>
|
||||
|
||||
#else // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
#define ASIO_ASYNC_OPERATION(t) typename
|
||||
#define ASIO_ASYNC_OPERATION1(t, a0) typename
|
||||
#define ASIO_ASYNC_OPERATION2(t, a0, a1) typename
|
||||
#define ASIO_ASYNC_OPERATION3(t, a0, a1, a2) typename
|
||||
|
||||
#endif // defined(ASIO_HAS_CONCEPTS)
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct completion_signature_probe {};
|
||||
|
||||
template <typename... T>
|
||||
struct completion_signature_probe_result
|
||||
{
|
||||
template <template <typename...> class Op>
|
||||
struct apply
|
||||
{
|
||||
typedef Op<T...> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct completion_signature_probe_result<T>
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
template <template <typename...> class Op>
|
||||
struct apply
|
||||
{
|
||||
typedef Op<T> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct completion_signature_probe_result<void>
|
||||
{
|
||||
template <template <typename...> class Op>
|
||||
struct apply
|
||||
{
|
||||
typedef Op<> type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename... Signatures>
|
||||
class async_result<detail::completion_signature_probe, Signatures...>
|
||||
{
|
||||
public:
|
||||
typedef detail::completion_signature_probe_result<Signatures...> return_type;
|
||||
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static return_type initiate(Initiation&&,
|
||||
detail::completion_signature_probe, InitArgs&&...)
|
||||
{
|
||||
return return_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Signature>
|
||||
class async_result<detail::completion_signature_probe, Signature>
|
||||
{
|
||||
public:
|
||||
typedef detail::completion_signature_probe_result<Signature> return_type;
|
||||
|
||||
template <typename Initiation, typename... InitArgs>
|
||||
static return_type initiate(Initiation&&,
|
||||
detail::completion_signature_probe, InitArgs&&...)
|
||||
{
|
||||
return return_type();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The completion_signature_of trait determines the completion signature
|
||||
/// of an asynchronous operation.
|
||||
/**
|
||||
* Class template @c completion_signature_of is a trait with a member type
|
||||
* alias @c type that denotes the completion signature of the asynchronous
|
||||
* operation initiated by the expression <tt>T(Args..., token)</tt> operation,
|
||||
* where @c token is an unspecified completion token type. If the asynchronous
|
||||
* operation does not have exactly one completion signature, the instantion of
|
||||
* the trait is well-formed but the member type alias @c type is omitted. If
|
||||
* the expression <tt>T(Args..., token)</tt> is not an asynchronous operation
|
||||
* then use of the trait is ill-formed.
|
||||
*/
|
||||
template <typename T, typename... Args>
|
||||
struct completion_signature_of
|
||||
{
|
||||
typedef automatically_determined type;
|
||||
};
|
||||
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename T, typename... Args>
|
||||
struct completion_signature_of :
|
||||
result_of_t<T(Args..., detail::completion_signature_probe)>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename T, typename... Args>
|
||||
using completion_signature_of_t =
|
||||
typename completion_signature_of<T, Args...>::type;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/default_completion_token.hpp"
|
||||
|
||||
#endif // ASIO_ASYNC_RESULT_HPP
|
||||
142
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/awaitable.hpp
vendored
Normal file
142
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/awaitable.hpp
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// awaitable.hpp
|
||||
// ~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_AWAITABLE_HPP
|
||||
#define ASIO_AWAITABLE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_CO_AWAIT) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(ASIO_HAS_STD_COROUTINE)
|
||||
# include <coroutine>
|
||||
#else // defined(ASIO_HAS_STD_COROUTINE)
|
||||
# include <experimental/coroutine>
|
||||
#endif // defined(ASIO_HAS_STD_COROUTINE)
|
||||
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if defined(ASIO_HAS_STD_COROUTINE)
|
||||
using std::coroutine_handle;
|
||||
using std::suspend_always;
|
||||
#else // defined(ASIO_HAS_STD_COROUTINE)
|
||||
using std::experimental::coroutine_handle;
|
||||
using std::experimental::suspend_always;
|
||||
#endif // defined(ASIO_HAS_STD_COROUTINE)
|
||||
|
||||
template <typename> class awaitable_thread;
|
||||
template <typename, typename> class awaitable_frame;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The return type of a coroutine or asynchronous operation.
|
||||
template <typename T, typename Executor = any_io_executor>
|
||||
class ASIO_NODISCARD awaitable
|
||||
{
|
||||
public:
|
||||
/// The type of the awaited value.
|
||||
typedef T value_type;
|
||||
|
||||
/// The executor type that will be used for the coroutine.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Default constructor.
|
||||
constexpr awaitable() noexcept
|
||||
: frame_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/// Move constructor.
|
||||
awaitable(awaitable&& other) noexcept
|
||||
: frame_(std::exchange(other.frame_, nullptr))
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~awaitable()
|
||||
{
|
||||
if (frame_)
|
||||
frame_->destroy();
|
||||
}
|
||||
|
||||
/// Move assignment.
|
||||
awaitable& operator=(awaitable&& other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
frame_ = std::exchange(other.frame_, nullptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Checks if the awaitable refers to a future result.
|
||||
bool valid() const noexcept
|
||||
{
|
||||
return !!frame_;
|
||||
}
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
// Support for co_await keyword.
|
||||
bool await_ready() const noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Support for co_await keyword.
|
||||
template <class U>
|
||||
void await_suspend(
|
||||
detail::coroutine_handle<detail::awaitable_frame<U, Executor>> h)
|
||||
{
|
||||
frame_->push_frame(&h.promise());
|
||||
}
|
||||
|
||||
// Support for co_await keyword.
|
||||
T await_resume()
|
||||
{
|
||||
return awaitable(static_cast<awaitable&&>(*this)).frame_->get();
|
||||
}
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
private:
|
||||
template <typename> friend class detail::awaitable_thread;
|
||||
template <typename, typename> friend class detail::awaitable_frame;
|
||||
|
||||
// Not copy constructible or copy assignable.
|
||||
awaitable(const awaitable&) = delete;
|
||||
awaitable& operator=(const awaitable&) = delete;
|
||||
|
||||
// Construct the awaitable from a coroutine's frame object.
|
||||
explicit awaitable(detail::awaitable_frame<T, Executor>* a)
|
||||
: frame_(a)
|
||||
{
|
||||
}
|
||||
|
||||
detail::awaitable_frame<T, Executor>* frame_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/impl/awaitable.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_CO_AWAIT) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_AWAITABLE_HPP
|
||||
1362
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_datagram_socket.hpp
vendored
Normal file
1362
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_datagram_socket.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
710
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_deadline_timer.hpp
vendored
Normal file
710
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_deadline_timer.hpp
vendored
Normal file
@@ -0,0 +1,710 @@
|
||||
//
|
||||
// basic_deadline_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
#define ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/detail/deadline_timer_service.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#include "asio/time_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Provides waitable timer functionality.
|
||||
/**
|
||||
* The basic_deadline_timer class template provides the ability to perform a
|
||||
* blocking or asynchronous wait for a timer to expire.
|
||||
*
|
||||
* A deadline timer is always in one of two states: "expired" or "not expired".
|
||||
* If the wait() or async_wait() function is called on an expired timer, the
|
||||
* wait operation will complete immediately.
|
||||
*
|
||||
* Most applications will use the asio::deadline_timer typedef.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Examples
|
||||
* Performing a blocking wait:
|
||||
* @code
|
||||
* // Construct a timer without setting an expiry time.
|
||||
* asio::deadline_timer timer(my_context);
|
||||
*
|
||||
* // Set an expiry time relative to now.
|
||||
* timer.expires_from_now(boost::posix_time::seconds(5));
|
||||
*
|
||||
* // Wait for the timer to expire.
|
||||
* timer.wait();
|
||||
* @endcode
|
||||
*
|
||||
* @par
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(const asio::error_code& error)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // Timer expired.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a timer with an absolute expiry time.
|
||||
* asio::deadline_timer timer(my_context,
|
||||
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
|
||||
*
|
||||
* // Start an asynchronous wait.
|
||||
* timer.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Changing an active deadline_timer's expiry time
|
||||
*
|
||||
* Changing the expiry time of a timer while there are pending asynchronous
|
||||
* waits causes those wait operations to be cancelled. To ensure that the action
|
||||
* associated with the timer is performed only once, use something like this:
|
||||
* used:
|
||||
*
|
||||
* @code
|
||||
* void on_some_event()
|
||||
* {
|
||||
* if (my_timer.expires_from_now(seconds(5)) > 0)
|
||||
* {
|
||||
* // We managed to cancel the timer. Start new asynchronous wait.
|
||||
* my_timer.async_wait(on_timeout);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Too late, timer has already expired!
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void on_timeout(const asio::error_code& e)
|
||||
* {
|
||||
* if (e != asio::error::operation_aborted)
|
||||
* {
|
||||
* // Timer was not cancelled, take necessary action.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @li The asio::basic_deadline_timer::expires_from_now() function
|
||||
* cancels any pending asynchronous waits, and returns the number of
|
||||
* asynchronous waits that were cancelled. If it returns 0 then you were too
|
||||
* late and the wait handler has already been executed, or will soon be
|
||||
* executed. If it returns 1 then the wait handler was successfully cancelled.
|
||||
*
|
||||
* @li If a wait handler is cancelled, the asio::error_code passed to
|
||||
* it contains the value asio::error::operation_aborted.
|
||||
*/
|
||||
template <typename Time,
|
||||
typename TimeTraits = asio::time_traits<Time>,
|
||||
typename Executor = any_io_executor>
|
||||
class basic_deadline_timer
|
||||
{
|
||||
private:
|
||||
class initiate_async_wait;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the timer type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The timer type when rebound to the specified executor.
|
||||
typedef basic_deadline_timer<Time, TimeTraits, Executor1> other;
|
||||
};
|
||||
|
||||
/// The time traits type.
|
||||
typedef TimeTraits traits_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename traits_type::time_type time_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename traits_type::duration_type duration_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_from_now() functions must be called to set an
|
||||
* expiry time before the timer can be waited on.
|
||||
*
|
||||
* @param ex The I/O executor that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*/
|
||||
explicit basic_deadline_timer(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_from_now() functions must be called to set an
|
||||
* expiry time before the timer can be waited on.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_deadline_timer(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param ex The I/O executor that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
basic_deadline_timer(const executor_type& ex, const time_type& expiry_time)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_deadline_timer(ExecutionContext& context, const time_type& expiry_time,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param ex The I/O executor that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
basic_deadline_timer(const executor_type& ex,
|
||||
const duration_type& expiry_time)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_from_now");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_deadline_timer(ExecutionContext& context,
|
||||
const duration_type& expiry_time,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_from_now");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_deadline_timer from another.
|
||||
/**
|
||||
* This constructor moves a timer from one object to another.
|
||||
*
|
||||
* @param other The other basic_deadline_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_deadline_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_deadline_timer(basic_deadline_timer&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_deadline_timer from another.
|
||||
/**
|
||||
* This assignment operator moves a timer from one object to another. Cancels
|
||||
* any outstanding asynchronous operations associated with the target object.
|
||||
*
|
||||
* @param other The other basic_deadline_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_deadline_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_deadline_timer& operator=(basic_deadline_timer&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the timer.
|
||||
/**
|
||||
* This function destroys the timer, cancelling any outstanding asynchronous
|
||||
* wait operations associated with the timer as if by calling @c cancel.
|
||||
*/
|
||||
~basic_deadline_timer()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one()
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().cancel_one(
|
||||
impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel_one");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().cancel_one(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_type expires_at() const
|
||||
{
|
||||
return impl_.get_service().expires_at(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().expires_at(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().expires_at(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
duration_type expires_from_now() const
|
||||
{
|
||||
return impl_.get_service().expires_from_now(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_from_now");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "wait");
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
void wait(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the timer.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* timer. It is an initiating function for an @ref asynchronous_operation,
|
||||
* and always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the completion handler will be called
|
||||
* exactly once. The completion handler will be called when:
|
||||
*
|
||||
* @li The timer has expired.
|
||||
*
|
||||
* @li The timer was cancelled, in which case the handler is passed the error
|
||||
* code asio::error::operation_aborted.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the timer expires. Potential
|
||||
* completion tokens include @ref use_future, @ref use_awaitable, @ref
|
||||
* yield_context, or a function object with the correct completion signature.
|
||||
* The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code) @endcode
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code))
|
||||
WaitToken = default_completion_token_t<executor_type>>
|
||||
auto async_wait(
|
||||
WaitToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WaitToken, void (asio::error_code)>(
|
||||
declval<initiate_async_wait>(), token))
|
||||
{
|
||||
return async_initiate<WaitToken, void (asio::error_code)>(
|
||||
initiate_async_wait(this), token);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_deadline_timer(const basic_deadline_timer&) = delete;
|
||||
basic_deadline_timer& operator=(
|
||||
const basic_deadline_timer&) = delete;
|
||||
|
||||
class initiate_async_wait
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_wait(basic_deadline_timer* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WaitHandler>
|
||||
void operator()(WaitHandler&& handler) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WaitHandler.
|
||||
ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WaitHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_wait(
|
||||
self_->impl_.get_implementation(),
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_deadline_timer* self_;
|
||||
};
|
||||
|
||||
detail::io_object_impl<
|
||||
detail::deadline_timer_service<TimeTraits>, Executor> impl_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
824
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_file.hpp
vendored
Normal file
824
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_file.hpp
vendored
Normal file
@@ -0,0 +1,824 @@
|
||||
//
|
||||
// basic_file.hpp
|
||||
// ~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_FILE_HPP
|
||||
#define ASIO_BASIC_FILE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_FILE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/cstdint.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/file_base.hpp"
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
# include "asio/detail/win_iocp_file_service.hpp"
|
||||
#elif defined(ASIO_HAS_IO_URING)
|
||||
# include "asio/detail/io_uring_file_service.hpp"
|
||||
#endif
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if !defined(ASIO_BASIC_FILE_FWD_DECL)
|
||||
#define ASIO_BASIC_FILE_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_file;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_FILE_FWD_DECL)
|
||||
|
||||
/// Provides file functionality.
|
||||
/**
|
||||
* The basic_file class template provides functionality that is common to both
|
||||
* stream-oriented and random-access files.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor>
|
||||
class basic_file
|
||||
: public file_base
|
||||
{
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the file type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The file type when rebound to the specified executor.
|
||||
typedef basic_file<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a file.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#elif defined(ASIO_HAS_IOCP)
|
||||
typedef detail::win_iocp_file_service::native_handle_type native_handle_type;
|
||||
#elif defined(ASIO_HAS_IO_URING)
|
||||
typedef detail::io_uring_file_service::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*/
|
||||
explicit basic_file(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_file(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_file.
|
||||
/**
|
||||
* This constructor initialises a file and opens it.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*/
|
||||
explicit basic_file(const executor_type& ex,
|
||||
const char* path, file_base::flags open_flags)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), path, open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file and opens it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_file(ExecutionContext& context,
|
||||
const char* path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), path, open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_file.
|
||||
/**
|
||||
* This constructor initialises a file and opens it.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*/
|
||||
explicit basic_file(const executor_type& ex,
|
||||
const std::string& path, file_base::flags open_flags)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file and opens it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_file(ExecutionContext& context,
|
||||
const std::string& path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_file on an existing native file handle.
|
||||
/**
|
||||
* This constructor initialises a file object to hold an existing native file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param native_file A native file handle.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_file(const executor_type& ex, const native_handle_type& native_file)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(
|
||||
impl_.get_implementation(), native_file, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct a basic_file on an existing native file.
|
||||
/**
|
||||
* This constructor initialises a file object to hold an existing native file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param native_file A native file.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_file(ExecutionContext& context, const native_handle_type& native_file,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(
|
||||
impl_.get_implementation(), native_file, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_file from another.
|
||||
/**
|
||||
* This constructor moves a file from one object to another.
|
||||
*
|
||||
* @param other The other basic_file object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_file(const executor_type&) constructor.
|
||||
*/
|
||||
basic_file(basic_file&& other) noexcept
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_file from another.
|
||||
/**
|
||||
* This assignment operator moves a file from one object to another.
|
||||
*
|
||||
* @param other The other basic_file object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_file(const executor_type&) constructor.
|
||||
*/
|
||||
basic_file& operator=(basic_file&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All files have access to each other's implementations.
|
||||
template <typename Executor1>
|
||||
friend class basic_file;
|
||||
|
||||
/// Move-construct a basic_file from a file of another executor type.
|
||||
/**
|
||||
* This constructor moves a file from one object to another.
|
||||
*
|
||||
* @param other The other basic_file object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_file(const executor_type&) constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_file(basic_file<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_file from a file of another executor type.
|
||||
/**
|
||||
* This assignment operator moves a file from one object to another.
|
||||
*
|
||||
* @param other The other basic_file object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_file(const executor_type&) constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_file&
|
||||
> operator=(basic_file<Executor1>&& other)
|
||||
{
|
||||
basic_file tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Open the file using the specified path.
|
||||
/**
|
||||
* This function opens the file so that it will use the specified path.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* asio::stream_file file(my_context);
|
||||
* file.open("/path/to/my/file", asio::stream_file::read_only);
|
||||
* @endcode
|
||||
*/
|
||||
void open(const char* path, file_base::flags open_flags)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), path, open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the file using the specified path.
|
||||
/**
|
||||
* This function opens the file so that it will use the specified path.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* asio::stream_file file(my_context);
|
||||
* asio::error_code ec;
|
||||
* file.open("/path/to/my/file", asio::stream_file::read_only, ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID open(const char* path,
|
||||
file_base::flags open_flags, asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().open(impl_.get_implementation(), path, open_flags, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Open the file using the specified path.
|
||||
/**
|
||||
* This function opens the file so that it will use the specified path.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* asio::stream_file file(my_context);
|
||||
* file.open("/path/to/my/file", asio::stream_file::read_only);
|
||||
* @endcode
|
||||
*/
|
||||
void open(const std::string& path, file_base::flags open_flags)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the file using the specified path.
|
||||
/**
|
||||
* This function opens the file so that it will use the specified path.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* asio::stream_file file(my_context);
|
||||
* asio::error_code ec;
|
||||
* file.open("/path/to/my/file", asio::stream_file::read_only, ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID open(const std::string& path,
|
||||
file_base::flags open_flags, asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().open(impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Assign an existing native file to the file.
|
||||
/*
|
||||
* This function opens the file to hold an existing native file.
|
||||
*
|
||||
* @param native_file A native file.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& native_file)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(
|
||||
impl_.get_implementation(), native_file, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native file to the file.
|
||||
/*
|
||||
* This function opens the file to hold an existing native file.
|
||||
*
|
||||
* @param native_file A native file.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID assign(const native_handle_type& native_file,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(
|
||||
impl_.get_implementation(), native_file, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the file is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the file.
|
||||
/**
|
||||
* This function is used to close the file. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. Note that, even if
|
||||
* the function indicates an error, the underlying descriptor is closed.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the file.
|
||||
/**
|
||||
* This function is used to close the file. Any asynchronous read or write
|
||||
* operations will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. Note that, even if
|
||||
* the function indicates an error, the underlying descriptor is closed.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* asio::stream_file file(my_context);
|
||||
* ...
|
||||
* asio::error_code ec;
|
||||
* file.close(ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID close(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native file.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read and write
|
||||
* operations to finish immediately, and the handlers for cancelled
|
||||
* operations will be passed the asio::error::operation_aborted error.
|
||||
* Ownership of the native file is then transferred to the caller.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release()
|
||||
{
|
||||
asio::error_code ec;
|
||||
native_handle_type s = impl_.get_service().release(
|
||||
impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "release");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native file.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read and write
|
||||
* operations to finish immediately, and the handlers for cancelled
|
||||
* operations will be passed the asio::error::operation_aborted error.
|
||||
* Ownership of the native file is then transferred to the caller.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().release(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Get the native file representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* file. This is intended to allow access to native file functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the file.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read and write
|
||||
* operations to finish immediately, and the handlers for cancelled
|
||||
* operations will be passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note Calls to cancel() will always fail with
|
||||
* asio::error::operation_not_supported when run on Windows XP, Windows
|
||||
* Server 2003, and earlier versions of Windows, unless
|
||||
* ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has
|
||||
* two issues that should be considered before enabling its use:
|
||||
*
|
||||
* @li It will only cancel asynchronous operations that were initiated in the
|
||||
* current thread.
|
||||
*
|
||||
* @li It can appear to complete without error, but the request to cancel the
|
||||
* unfinished operations may be silently ignored by the operating system.
|
||||
* Whether it works or not seems to depend on the drivers that are installed.
|
||||
*
|
||||
* For portable cancellation, consider using the close() function to
|
||||
* simultaneously cancel the outstanding operations and close the file.
|
||||
*
|
||||
* When running on Windows Vista, Windows Server 2008, and later, the
|
||||
* CancelIoEx function is always used. This function does not have the
|
||||
* problems described above.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \
|
||||
&& !defined(ASIO_ENABLE_CANCELIO)
|
||||
__declspec(deprecated("By default, this function always fails with "
|
||||
"operation_not_supported when used on Windows XP, Windows Server 2003, "
|
||||
"or earlier. Consult documentation for details."))
|
||||
#endif
|
||||
void cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the file.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read and write
|
||||
* operations to finish immediately, and the handlers for cancelled
|
||||
* operations will be passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note Calls to cancel() will always fail with
|
||||
* asio::error::operation_not_supported when run on Windows XP, Windows
|
||||
* Server 2003, and earlier versions of Windows, unless
|
||||
* ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has
|
||||
* two issues that should be considered before enabling its use:
|
||||
*
|
||||
* @li It will only cancel asynchronous operations that were initiated in the
|
||||
* current thread.
|
||||
*
|
||||
* @li It can appear to complete without error, but the request to cancel the
|
||||
* unfinished operations may be silently ignored by the operating system.
|
||||
* Whether it works or not seems to depend on the drivers that are installed.
|
||||
*
|
||||
* For portable cancellation, consider using the close() function to
|
||||
* simultaneously cancel the outstanding operations and close the file.
|
||||
*
|
||||
* When running on Windows Vista, Windows Server 2008, and later, the
|
||||
* CancelIoEx function is always used. This function does not have the
|
||||
* problems described above.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \
|
||||
&& !defined(ASIO_ENABLE_CANCELIO)
|
||||
__declspec(deprecated("By default, this function always fails with "
|
||||
"operation_not_supported when used on Windows XP, Windows Server 2003, "
|
||||
"or earlier. Consult documentation for details."))
|
||||
#endif
|
||||
ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Get the size of the file.
|
||||
/**
|
||||
* This function determines the size of the file, in bytes.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
uint64_t size() const
|
||||
{
|
||||
asio::error_code ec;
|
||||
uint64_t s = impl_.get_service().size(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "size");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Get the size of the file.
|
||||
/**
|
||||
* This function determines the size of the file, in bytes.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
uint64_t size(asio::error_code& ec) const
|
||||
{
|
||||
return impl_.get_service().size(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Alter the size of the file.
|
||||
/**
|
||||
* This function resizes the file to the specified size, in bytes. If the
|
||||
* current file size exceeds @c n then any extra data is discarded. If the
|
||||
* current size is less than @c n then the file is extended and filled with
|
||||
* zeroes.
|
||||
*
|
||||
* @param n The new size for the file.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void resize(uint64_t n)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().resize(impl_.get_implementation(), n, ec);
|
||||
asio::detail::throw_error(ec, "resize");
|
||||
}
|
||||
|
||||
/// Alter the size of the file.
|
||||
/**
|
||||
* This function resizes the file to the specified size, in bytes. If the
|
||||
* current file size exceeds @c n then any extra data is discarded. If the
|
||||
* current size is less than @c n then the file is extended and filled with
|
||||
* zeroes.
|
||||
*
|
||||
* @param n The new size for the file.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID resize(uint64_t n, asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().resize(impl_.get_implementation(), n, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Synchronise the file to disk.
|
||||
/**
|
||||
* This function synchronises the file data and metadata to disk. Note that
|
||||
* the semantics of this synchronisation vary between operation systems.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void sync_all()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().sync_all(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "sync_all");
|
||||
}
|
||||
|
||||
/// Synchronise the file to disk.
|
||||
/**
|
||||
* This function synchronises the file data and metadata to disk. Note that
|
||||
* the semantics of this synchronisation vary between operation systems.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID sync_all(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().sync_all(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Synchronise the file data to disk.
|
||||
/**
|
||||
* This function synchronises the file data to disk. Note that the semantics
|
||||
* of this synchronisation vary between operation systems.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void sync_data()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().sync_data(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "sync_data");
|
||||
}
|
||||
|
||||
/// Synchronise the file data to disk.
|
||||
/**
|
||||
* This function synchronises the file data to disk. Note that the semantics
|
||||
* of this synchronisation vary between operation systems.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID sync_data(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().sync_data(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
/**
|
||||
* This function destroys the file, cancelling any outstanding asynchronous
|
||||
* operations associated with the file as if by calling @c cancel.
|
||||
*/
|
||||
~basic_file()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
detail::io_object_impl<detail::win_iocp_file_service, Executor> impl_;
|
||||
#elif defined(ASIO_HAS_IO_URING)
|
||||
detail::io_object_impl<detail::io_uring_file_service, Executor> impl_;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_file(const basic_file&) = delete;
|
||||
basic_file& operator=(const basic_file&) = delete;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_FILE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_FILE_HPP
|
||||
286
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_io_object.hpp
vendored
Normal file
286
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_io_object.hpp
vendored
Normal file
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// basic_io_object.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_IO_OBJECT_HPP
|
||||
#define ASIO_BASIC_IO_OBJECT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/io_context.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Type trait used to determine whether a service supports move.
|
||||
template <typename IoObjectService>
|
||||
class service_has_move
|
||||
{
|
||||
private:
|
||||
typedef IoObjectService service_type;
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
template <typename T, typename U>
|
||||
static auto asio_service_has_move_eval(T* t, U* u)
|
||||
-> decltype(t->move_construct(*u, *u), char());
|
||||
static char (&asio_service_has_move_eval(...))[2];
|
||||
|
||||
public:
|
||||
static const bool value =
|
||||
sizeof(asio_service_has_move_eval(
|
||||
static_cast<service_type*>(0),
|
||||
static_cast<implementation_type*>(0))) == 1;
|
||||
};
|
||||
}
|
||||
|
||||
/// Base class for all I/O objects.
|
||||
/**
|
||||
* @note All I/O objects are non-copyable. However, when using C++0x, certain
|
||||
* I/O objects do support move construction and move assignment.
|
||||
*/
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <typename IoObjectService>
|
||||
#else
|
||||
template <typename IoObjectService,
|
||||
bool Movable = detail::service_has_move<IoObjectService>::value>
|
||||
#endif
|
||||
class basic_io_object
|
||||
{
|
||||
public:
|
||||
/// The type of the service that will be used to provide I/O operations.
|
||||
typedef IoObjectService service_type;
|
||||
|
||||
/// The underlying implementation type of I/O object.
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use get_executor().) Get the io_context associated with the
|
||||
/// object.
|
||||
/**
|
||||
* This function may be used to obtain the io_context object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_context object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
asio::io_context& get_io_context()
|
||||
{
|
||||
return service_.get_io_context();
|
||||
}
|
||||
|
||||
/// (Deprecated: Use get_executor().) Get the io_context associated with the
|
||||
/// object.
|
||||
/**
|
||||
* This function may be used to obtain the io_context object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_context object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
asio::io_context& get_io_service()
|
||||
{
|
||||
return service_.get_io_context();
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// The type of the executor associated with the object.
|
||||
typedef asio::io_context::executor_type executor_type;
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
executor_type get_executor() noexcept
|
||||
{
|
||||
return service_.get_io_context().get_executor();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Construct a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().construct(get_implementation()); @endcode
|
||||
*/
|
||||
explicit basic_io_object(asio::io_context& io_context)
|
||||
: service_(asio::use_service<IoObjectService>(io_context))
|
||||
{
|
||||
service_.construct(implementation_);
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().move_construct(
|
||||
* get_implementation(), other.get_implementation()); @endcode
|
||||
*
|
||||
* @note Available only for services that support movability,
|
||||
*/
|
||||
basic_io_object(basic_io_object&& other);
|
||||
|
||||
/// Move-assign a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().move_assign(get_implementation(),
|
||||
* other.get_service(), other.get_implementation()); @endcode
|
||||
*
|
||||
* @note Available only for services that support movability,
|
||||
*/
|
||||
basic_io_object& operator=(basic_io_object&& other);
|
||||
|
||||
/// Perform a converting move-construction of a basic_io_object.
|
||||
template <typename IoObjectService1>
|
||||
basic_io_object(IoObjectService1& other_service,
|
||||
typename IoObjectService1::implementation_type& other_implementation);
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().destroy(get_implementation()); @endcode
|
||||
*/
|
||||
~basic_io_object()
|
||||
{
|
||||
service_.destroy(implementation_);
|
||||
}
|
||||
|
||||
/// Get the service associated with the I/O object.
|
||||
service_type& get_service()
|
||||
{
|
||||
return service_;
|
||||
}
|
||||
|
||||
/// Get the service associated with the I/O object.
|
||||
const service_type& get_service() const
|
||||
{
|
||||
return service_;
|
||||
}
|
||||
|
||||
/// Get the underlying implementation of the I/O object.
|
||||
implementation_type& get_implementation()
|
||||
{
|
||||
return implementation_;
|
||||
}
|
||||
|
||||
/// Get the underlying implementation of the I/O object.
|
||||
const implementation_type& get_implementation() const
|
||||
{
|
||||
return implementation_;
|
||||
}
|
||||
|
||||
private:
|
||||
basic_io_object(const basic_io_object&);
|
||||
basic_io_object& operator=(const basic_io_object&);
|
||||
|
||||
// The service associated with the I/O object.
|
||||
service_type& service_;
|
||||
|
||||
/// The underlying implementation of the I/O object.
|
||||
implementation_type implementation_;
|
||||
};
|
||||
|
||||
// Specialisation for movable objects.
|
||||
template <typename IoObjectService>
|
||||
class basic_io_object<IoObjectService, true>
|
||||
{
|
||||
public:
|
||||
typedef IoObjectService service_type;
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
asio::io_context& get_io_context()
|
||||
{
|
||||
return service_->get_io_context();
|
||||
}
|
||||
|
||||
asio::io_context& get_io_service()
|
||||
{
|
||||
return service_->get_io_context();
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
typedef asio::io_context::executor_type executor_type;
|
||||
|
||||
executor_type get_executor() noexcept
|
||||
{
|
||||
return service_->get_io_context().get_executor();
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit basic_io_object(asio::io_context& io_context)
|
||||
: service_(&asio::use_service<IoObjectService>(io_context))
|
||||
{
|
||||
service_->construct(implementation_);
|
||||
}
|
||||
|
||||
basic_io_object(basic_io_object&& other)
|
||||
: service_(&other.get_service())
|
||||
{
|
||||
service_->move_construct(implementation_, other.implementation_);
|
||||
}
|
||||
|
||||
template <typename IoObjectService1>
|
||||
basic_io_object(IoObjectService1& other_service,
|
||||
typename IoObjectService1::implementation_type& other_implementation)
|
||||
: service_(&asio::use_service<IoObjectService>(
|
||||
other_service.get_io_context()))
|
||||
{
|
||||
service_->converting_move_construct(implementation_,
|
||||
other_service, other_implementation);
|
||||
}
|
||||
|
||||
~basic_io_object()
|
||||
{
|
||||
service_->destroy(implementation_);
|
||||
}
|
||||
|
||||
basic_io_object& operator=(basic_io_object&& other)
|
||||
{
|
||||
service_->move_assign(implementation_,
|
||||
*other.service_, other.implementation_);
|
||||
service_ = other.service_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
service_type& get_service()
|
||||
{
|
||||
return *service_;
|
||||
}
|
||||
|
||||
const service_type& get_service() const
|
||||
{
|
||||
return *service_;
|
||||
}
|
||||
|
||||
implementation_type& get_implementation()
|
||||
{
|
||||
return implementation_;
|
||||
}
|
||||
|
||||
const implementation_type& get_implementation() const
|
||||
{
|
||||
return implementation_;
|
||||
}
|
||||
|
||||
private:
|
||||
basic_io_object(const basic_io_object&);
|
||||
void operator=(const basic_io_object&);
|
||||
|
||||
IoObjectService* service_;
|
||||
implementation_type implementation_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BASIC_IO_OBJECT_HPP
|
||||
689
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_random_access_file.hpp
vendored
Normal file
689
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_random_access_file.hpp
vendored
Normal file
@@ -0,0 +1,689 @@
|
||||
//
|
||||
// basic_random_access_file.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_RANDOM_ACCESS_FILE_HPP
|
||||
#define ASIO_BASIC_RANDOM_ACCESS_FILE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_FILE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/basic_file.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/error.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if !defined(ASIO_BASIC_RANDOM_ACCESS_FILE_FWD_DECL)
|
||||
#define ASIO_BASIC_RANDOM_ACCESS_FILE_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_random_access_file;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_RANDOM_ACCESS_FILE_FWD_DECL)
|
||||
|
||||
/// Provides random-access file functionality.
|
||||
/**
|
||||
* The basic_random_access_file class template provides asynchronous and
|
||||
* blocking random-access file functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* Synchronous @c read_some_at and @c write_some_at operations are thread safe
|
||||
* with respect to each other, if the underlying operating system calls are
|
||||
* also thread safe. This means that it is permitted to perform concurrent
|
||||
* calls to these synchronous operations on a single file object. Other
|
||||
* synchronous operations, such as @c open or @c close, are not thread safe.
|
||||
*/
|
||||
template <typename Executor>
|
||||
class basic_random_access_file
|
||||
: public basic_file<Executor>
|
||||
{
|
||||
private:
|
||||
class initiate_async_write_some_at;
|
||||
class initiate_async_read_some_at;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the file type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The file type when rebound to the specified executor.
|
||||
typedef basic_random_access_file<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a file.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef typename basic_file<Executor>::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_random_access_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it. The file needs to
|
||||
* be opened before data can be read from or or written to it.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*/
|
||||
explicit basic_random_access_file(const executor_type& ex)
|
||||
: basic_file<Executor>(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_random_access_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it. The file needs to
|
||||
* be opened before data can be read from or or written to it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_random_access_file(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_random_access_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_random_access_file(const executor_type& ex,
|
||||
const char* path, file_base::flags open_flags)
|
||||
: basic_file<Executor>(ex, path, open_flags)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_random_access_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_random_access_file(ExecutionContext& context,
|
||||
const char* path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context, path, open_flags)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_random_access_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_random_access_file(const executor_type& ex,
|
||||
const std::string& path, file_base::flags open_flags)
|
||||
: basic_file<Executor>(ex, path, open_flags)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_random_access_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_random_access_file(ExecutionContext& context,
|
||||
const std::string& path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context, path, open_flags)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_random_access_file on an existing native file.
|
||||
/**
|
||||
* This constructor initialises a random-access file object to hold an
|
||||
* existing native file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param native_file The new underlying file implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_random_access_file(const executor_type& ex,
|
||||
const native_handle_type& native_file)
|
||||
: basic_file<Executor>(ex, native_file)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_random_access_file on an existing native file.
|
||||
/**
|
||||
* This constructor initialises a random-access file object to hold an
|
||||
* existing native file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param native_file The new underlying file implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_random_access_file(ExecutionContext& context,
|
||||
const native_handle_type& native_file,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context, native_file)
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-construct a basic_random_access_file from another.
|
||||
/**
|
||||
* This constructor moves a random-access file from one object to another.
|
||||
*
|
||||
* @param other The other basic_random_access_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_random_access_file(basic_random_access_file&& other) noexcept
|
||||
: basic_file<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_random_access_file from another.
|
||||
/**
|
||||
* This assignment operator moves a random-access file from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_random_access_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_random_access_file& operator=(basic_random_access_file&& other)
|
||||
{
|
||||
basic_file<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move-construct a basic_random_access_file from a file of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This constructor moves a random-access file from one object to another.
|
||||
*
|
||||
* @param other The other basic_random_access_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_random_access_file(basic_random_access_file<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_random_access_file from a file of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This assignment operator moves a random-access file from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_random_access_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_random_access_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_random_access_file&
|
||||
> operator=(basic_random_access_file<Executor1>&& other)
|
||||
{
|
||||
basic_file<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the file.
|
||||
/**
|
||||
* This function destroys the file, cancelling any outstanding asynchronous
|
||||
* operations associated with the file as if by calling @c cancel.
|
||||
*/
|
||||
~basic_random_access_file()
|
||||
{
|
||||
}
|
||||
|
||||
/// Write some data to the handle at the specified offset.
|
||||
/**
|
||||
* This function is used to write data to the random-access handle. The
|
||||
* function call will block until one or more bytes of the data has been
|
||||
* written successfully, or until an error occurs.
|
||||
*
|
||||
* @param offset The offset at which the data will be written.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the handle.
|
||||
*
|
||||
* @returns The number of bytes written.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the end of the file was reached.
|
||||
*
|
||||
* @note The write_some_at operation may not write all of the data. Consider
|
||||
* using the @ref write_at function if you need to ensure that all data is
|
||||
* written before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* handle.write_some_at(42, asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some_at(uint64_t offset,
|
||||
const ConstBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().write_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
asio::detail::throw_error(ec, "write_some_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Write some data to the handle at the specified offset.
|
||||
/**
|
||||
* This function is used to write data to the random-access handle. The
|
||||
* function call will block until one or more bytes of the data has been
|
||||
* written successfully, or until an error occurs.
|
||||
*
|
||||
* @param offset The offset at which the data will be written.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the handle.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes written. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The write_some operation may not write all of the data to the
|
||||
* file. Consider using the @ref write_at function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some_at(uint64_t offset,
|
||||
const ConstBufferSequence& buffers, asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().write_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write at the specified offset.
|
||||
/**
|
||||
* This function is used to asynchronously write data to the random-access
|
||||
* handle. It is an initiating function for an @ref asynchronous_operation,
|
||||
* and always returns immediately.
|
||||
*
|
||||
* @param offset The offset at which the data will be written.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the handle.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the write completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The write operation may not write all of the data to the file.
|
||||
* Consider using the @ref async_write_at function if you need to ensure that
|
||||
* all data is written before the asynchronous operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* handle.async_write_some_at(42, asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename ConstBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) WriteToken = default_completion_token_t<executor_type>>
|
||||
auto async_write_some_at(uint64_t offset, const ConstBufferSequence& buffers,
|
||||
WriteToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_write_some_at>(), token, offset, buffers))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_write_some_at(this), token, offset, buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the handle at the specified offset.
|
||||
/**
|
||||
* This function is used to read data from the random-access handle. The
|
||||
* function call will block until one or more bytes of data has been read
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param offset The offset at which the data will be read.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @returns The number of bytes read.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the end of the file was reached.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read_at function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* handle.read_some_at(42, asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some_at(uint64_t offset,
|
||||
const MutableBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().read_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
asio::detail::throw_error(ec, "read_some_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Read some data from the handle at the specified offset.
|
||||
/**
|
||||
* This function is used to read data from the random-access handle. The
|
||||
* function call will block until one or more bytes of data has been read
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param offset The offset at which the data will be read.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes read. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read_at function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some_at(uint64_t offset,
|
||||
const MutableBufferSequence& buffers, asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().read_some_at(
|
||||
this->impl_.get_implementation(), offset, buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read at the specified offset.
|
||||
/**
|
||||
* This function is used to asynchronously read data from the random-access
|
||||
* handle. It is an initiating function for an @ref asynchronous_operation,
|
||||
* and always returns immediately.
|
||||
*
|
||||
* @param offset The offset at which the data will be read.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the read completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read_at function if you need to ensure that
|
||||
* the requested amount of data is read before the asynchronous operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* handle.async_read_some_at(42, asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_read_some_at(uint64_t offset, const MutableBufferSequence& buffers,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_read_some_at>(), token, offset, buffers))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_read_some_at(this), token, offset, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_random_access_file(const basic_random_access_file&) = delete;
|
||||
basic_random_access_file& operator=(
|
||||
const basic_random_access_file&) = delete;
|
||||
|
||||
class initiate_async_write_some_at
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_write_some_at(basic_random_access_file* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(WriteHandler&& handler,
|
||||
uint64_t offset, const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_write_some_at(
|
||||
self_->impl_.get_implementation(), offset, buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_random_access_file* self_;
|
||||
};
|
||||
|
||||
class initiate_async_read_some_at
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_read_some_at(basic_random_access_file* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ReadHandler&& handler,
|
||||
uint64_t offset, const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_read_some_at(
|
||||
self_->impl_.get_implementation(), offset, buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_random_access_file* self_;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_FILE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_RANDOM_ACCESS_FILE_HPP
|
||||
1356
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_raw_socket.hpp
vendored
Normal file
1356
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_raw_socket.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
626
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_readable_pipe.hpp
vendored
Normal file
626
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_readable_pipe.hpp
vendored
Normal file
@@ -0,0 +1,626 @@
|
||||
//
|
||||
// basic_readable_pipe.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_READABLE_PIPE_HPP
|
||||
#define ASIO_BASIC_READABLE_PIPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_PIPE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
# include "asio/detail/win_iocp_handle_service.hpp"
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
# include "asio/detail/io_uring_descriptor_service.hpp"
|
||||
#else
|
||||
# include "asio/detail/reactive_descriptor_service.hpp"
|
||||
#endif
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Provides pipe functionality.
|
||||
/**
|
||||
* The basic_readable_pipe class provides a wrapper over pipe
|
||||
* functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_readable_pipe
|
||||
{
|
||||
private:
|
||||
class initiate_async_read_some;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the pipe type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The pipe type when rebound to the specified executor.
|
||||
typedef basic_readable_pipe<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a pipe.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#elif defined(ASIO_HAS_IOCP)
|
||||
typedef detail::win_iocp_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
typedef detail::io_uring_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#else
|
||||
typedef detail::reactive_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// A basic_readable_pipe is always the lowest layer.
|
||||
typedef basic_readable_pipe lowest_layer_type;
|
||||
|
||||
/// Construct a basic_readable_pipe without opening it.
|
||||
/**
|
||||
* This constructor creates a pipe without opening it.
|
||||
*
|
||||
* @param ex The I/O executor that the pipe will use, by default, to dispatch
|
||||
* handlers for any asynchronous operations performed on the pipe.
|
||||
*/
|
||||
explicit basic_readable_pipe(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_readable_pipe without opening it.
|
||||
/**
|
||||
* This constructor creates a pipe without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the pipe will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the pipe.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_readable_pipe(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_readable_pipe on an existing native pipe.
|
||||
/**
|
||||
* This constructor creates a pipe object to hold an existing native
|
||||
* pipe.
|
||||
*
|
||||
* @param ex The I/O executor that the pipe will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_readable_pipe(const executor_type& ex,
|
||||
const native_handle_type& native_pipe)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct a basic_readable_pipe on an existing native pipe.
|
||||
/**
|
||||
* This constructor creates a pipe object to hold an existing native
|
||||
* pipe.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the pipe will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_readable_pipe(ExecutionContext& context,
|
||||
const native_handle_type& native_pipe,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_readable_pipe from another.
|
||||
/**
|
||||
* This constructor moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_readable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_readable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_readable_pipe(basic_readable_pipe&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_readable_pipe from another.
|
||||
/**
|
||||
* This assignment operator moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_readable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_readable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_readable_pipe& operator=(basic_readable_pipe&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All pipes have access to each other's implementations.
|
||||
template <typename Executor1>
|
||||
friend class basic_readable_pipe;
|
||||
|
||||
/// Move-construct a basic_readable_pipe from a pipe of another executor type.
|
||||
/**
|
||||
* This constructor moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_readable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_readable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_readable_pipe(basic_readable_pipe<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_readable_pipe from a pipe of another executor type.
|
||||
/**
|
||||
* This assignment operator moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_readable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_readable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_readable_pipe&
|
||||
> operator=(basic_readable_pipe<Executor1>&& other)
|
||||
{
|
||||
basic_readable_pipe tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the pipe.
|
||||
/**
|
||||
* This function destroys the pipe, cancelling any outstanding
|
||||
* asynchronous wait operations associated with the pipe as if by
|
||||
* calling @c cancel.
|
||||
*/
|
||||
~basic_readable_pipe()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_readable_pipe cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_readable_pipe cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assign an existing native pipe to the pipe.
|
||||
/*
|
||||
* This function opens the pipe to hold an existing native pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& native_pipe)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native pipe to the pipe.
|
||||
/*
|
||||
* This function opens the pipe to hold an existing native pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID assign(const native_handle_type& native_pipe,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_pipe, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the pipe is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the pipe.
|
||||
/**
|
||||
* This function is used to close the pipe. Any asynchronous read operations
|
||||
* will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the pipe.
|
||||
/**
|
||||
* This function is used to close the pipe. Any asynchronous read operations
|
||||
* will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID close(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error. Ownership of the
|
||||
* native pipe is then transferred to the caller.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release()
|
||||
{
|
||||
asio::error_code ec;
|
||||
native_handle_type s = impl_.get_service().release(
|
||||
impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "release");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error. Ownership of the
|
||||
* native pipe is then transferred to the caller.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().release(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Get the native pipe representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* pipe. This is intended to allow access to native pipe
|
||||
* functionality that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read operations to finish
|
||||
* immediately, and the handlers for cancelled operations will be passed the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read operations to finish
|
||||
* immediately, and the handlers for cancelled operations will be passed the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Read some data from the pipe.
|
||||
/**
|
||||
* This function is used to read data from the pipe. The function call will
|
||||
* block until one or more bytes of data has been read successfully, or until
|
||||
* an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @returns The number of bytes read.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_readable_pipe.read_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().read_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Read some data from the pipe.
|
||||
/**
|
||||
* This function is used to read data from the pipe. The function call will
|
||||
* block until one or more bytes of data has been read successfully, or until
|
||||
* an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes read. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().read_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
/**
|
||||
* This function is used to asynchronously read data from the pipe. It is an
|
||||
* initiating function for an @ref asynchronous_operation, and always returns
|
||||
* immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the read completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read function if you need to ensure that the
|
||||
* requested amount of data is read before the asynchronous operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_readable_pipe.async_read_some(
|
||||
* asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_read_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_read_some(this), token, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_readable_pipe(const basic_readable_pipe&) = delete;
|
||||
basic_readable_pipe& operator=(const basic_readable_pipe&) = delete;
|
||||
|
||||
class initiate_async_read_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_read_some(basic_readable_pipe* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ReadHandler&& handler,
|
||||
const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_read_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_readable_pipe* self_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
detail::io_object_impl<detail::win_iocp_handle_service, Executor> impl_;
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
detail::io_object_impl<detail::io_uring_descriptor_service, Executor> impl_;
|
||||
#else
|
||||
detail::io_object_impl<detail::reactive_descriptor_service, Executor> impl_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_PIPE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_READABLE_PIPE_HPP
|
||||
823
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_seq_packet_socket.hpp
vendored
Normal file
823
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_seq_packet_socket.hpp
vendored
Normal file
@@ -0,0 +1,823 @@
|
||||
//
|
||||
// basic_seq_packet_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
#define ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <cstddef>
|
||||
#include "asio/basic_socket.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/error.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if !defined(ASIO_BASIC_SEQ_PACKET_SOCKET_FWD_DECL)
|
||||
#define ASIO_BASIC_SEQ_PACKET_SOCKET_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Protocol, typename Executor = any_io_executor>
|
||||
class basic_seq_packet_socket;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_SEQ_PACKET_SOCKET_FWD_DECL)
|
||||
|
||||
/// Provides sequenced packet socket functionality.
|
||||
/**
|
||||
* The basic_seq_packet_socket class template provides asynchronous and blocking
|
||||
* sequenced packet socket functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* Synchronous @c send, @c receive, @c connect, and @c shutdown operations are
|
||||
* thread safe with respect to each other, if the underlying operating system
|
||||
* calls are also thread safe. This means that it is permitted to perform
|
||||
* concurrent calls to these synchronous operations on a single socket object.
|
||||
* Other synchronous operations, such as @c open or @c close, are not thread
|
||||
* safe.
|
||||
*/
|
||||
template <typename Protocol, typename Executor>
|
||||
class basic_seq_packet_socket
|
||||
: public basic_socket<Protocol, Executor>
|
||||
{
|
||||
private:
|
||||
class initiate_async_send;
|
||||
class initiate_async_receive_with_flags;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the socket type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The socket type when rebound to the specified executor.
|
||||
typedef basic_seq_packet_socket<Protocol, Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a socket.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef typename basic_socket<Protocol,
|
||||
Executor>::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// Construct a basic_seq_packet_socket without opening it.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket without opening it. The
|
||||
* socket needs to be opened and then connected or accepted before data can
|
||||
* be sent or received on it.
|
||||
*
|
||||
* @param ex The I/O executor that the socket will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the socket.
|
||||
*/
|
||||
explicit basic_seq_packet_socket(const executor_type& ex)
|
||||
: basic_socket<Protocol, Executor>(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket without opening it.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket without opening it. The
|
||||
* socket needs to be opened and then connected or accepted before data can
|
||||
* be sent or received on it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the socket will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the socket.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_seq_packet_socket(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: basic_socket<Protocol, Executor>(context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_seq_packet_socket.
|
||||
/**
|
||||
* This constructor creates and opens a sequenced_packet socket. The socket
|
||||
* needs to be connected or accepted before data can be sent or received on
|
||||
* it.
|
||||
*
|
||||
* @param ex The I/O executor that the socket will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(const executor_type& ex,
|
||||
const protocol_type& protocol)
|
||||
: basic_socket<Protocol, Executor>(ex, protocol)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_seq_packet_socket.
|
||||
/**
|
||||
* This constructor creates and opens a sequenced_packet socket. The socket
|
||||
* needs to be connected or accepted before data can be sent or received on
|
||||
* it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the socket will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_seq_packet_socket(ExecutionContext& context,
|
||||
const protocol_type& protocol,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_socket<Protocol, Executor>(context, protocol)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket, opening it and binding it to the
|
||||
/// given local endpoint.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket and automatically opens
|
||||
* it bound to the specified endpoint on the local machine. The protocol used
|
||||
* is the protocol associated with the given endpoint.
|
||||
*
|
||||
* @param ex The I/O executor that the socket will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the socket.
|
||||
*
|
||||
* @param endpoint An endpoint on the local machine to which the sequenced
|
||||
* packet socket will be bound.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(const executor_type& ex,
|
||||
const endpoint_type& endpoint)
|
||||
: basic_socket<Protocol, Executor>(ex, endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket, opening it and binding it to the
|
||||
/// given local endpoint.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket and automatically opens
|
||||
* it bound to the specified endpoint on the local machine. The protocol used
|
||||
* is the protocol associated with the given endpoint.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the socket will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the socket.
|
||||
*
|
||||
* @param endpoint An endpoint on the local machine to which the sequenced
|
||||
* packet socket will be bound.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_seq_packet_socket(ExecutionContext& context,
|
||||
const endpoint_type& endpoint,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: basic_socket<Protocol, Executor>(context, endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket on an existing native socket.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket object to hold an
|
||||
* existing native socket.
|
||||
*
|
||||
* @param ex The I/O executor that the socket will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @param native_socket The new underlying socket implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(const executor_type& ex,
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_socket<Protocol, Executor>(ex, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket on an existing native socket.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket object to hold an
|
||||
* existing native socket.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the socket will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @param native_socket The new underlying socket implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_seq_packet_socket(ExecutionContext& context,
|
||||
const protocol_type& protocol, const native_handle_type& native_socket,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: basic_socket<Protocol, Executor>(context, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-construct a basic_seq_packet_socket from another.
|
||||
/**
|
||||
* This constructor moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_seq_packet_socket(basic_seq_packet_socket&& other) noexcept
|
||||
: basic_socket<Protocol, Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_seq_packet_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_seq_packet_socket& operator=(basic_seq_packet_socket&& other)
|
||||
{
|
||||
basic_socket<Protocol, Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move-construct a basic_seq_packet_socket from a socket of another protocol
|
||||
/// type.
|
||||
/**
|
||||
* This constructor moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Protocol1, typename Executor1>
|
||||
basic_seq_packet_socket(basic_seq_packet_socket<Protocol1, Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Protocol1, Protocol>::value
|
||||
&& is_convertible<Executor1, Executor>::value
|
||||
> = 0)
|
||||
: basic_socket<Protocol, Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_seq_packet_socket from a socket of another protocol
|
||||
/// type.
|
||||
/**
|
||||
* This assignment operator moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Protocol1, typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Protocol1, Protocol>::value
|
||||
&& is_convertible<Executor1, Executor>::value,
|
||||
basic_seq_packet_socket&
|
||||
> operator=(basic_seq_packet_socket<Protocol1, Executor1>&& other)
|
||||
{
|
||||
basic_socket<Protocol, Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the socket.
|
||||
/**
|
||||
* This function destroys the socket, cancelling any outstanding asynchronous
|
||||
* operations associated with the socket as if by calling @c cancel.
|
||||
*/
|
||||
~basic_seq_packet_socket()
|
||||
{
|
||||
}
|
||||
|
||||
/// Send some data on the socket.
|
||||
/**
|
||||
* This function is used to send data on the sequenced packet socket. The
|
||||
* function call will block until the data has been sent successfully, or an
|
||||
* until error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @returns The number of bytes sent.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @par Example
|
||||
* To send a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* socket.send(asio::buffer(data, size), 0);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on sending multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().send(
|
||||
this->impl_.get_implementation(), buffers, flags, ec);
|
||||
asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Send some data on the socket.
|
||||
/**
|
||||
* This function is used to send data on the sequenced packet socket. The
|
||||
* function call will block the data has been sent successfully, or an until
|
||||
* error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes sent. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The send operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref write function if you need to ensure that all data
|
||||
* is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().send(
|
||||
this->impl_.get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
/**
|
||||
* This function is used to asynchronously send data on the sequenced packet
|
||||
* socket. It is an initiating function for an @ref asynchronous_operation,
|
||||
* and always returns immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket. Although
|
||||
* the buffers object may be copied as necessary, ownership of the underlying
|
||||
* memory blocks is retained by the caller, which must guarantee that they
|
||||
* remain valid until the completion handler is called.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the send completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes sent.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @par Example
|
||||
* To send a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* socket.async_send(asio::buffer(data, size), 0, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on sending multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename ConstBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) WriteToken
|
||||
= default_completion_token_t<executor_type>>
|
||||
auto async_send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags,
|
||||
WriteToken&& token
|
||||
= default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_send>(), token, buffers, flags))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_send(this), token, buffers, flags);
|
||||
}
|
||||
|
||||
/// Receive some data on the socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @returns The number of bytes received.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.receive(asio::buffer(data, size), out_flags);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags& out_flags)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().receive_with_flags(
|
||||
this->impl_.get_implementation(), buffers, 0, out_flags, ec);
|
||||
asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Receive some data on the socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @returns The number of bytes received.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The receive operation may not receive all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that the
|
||||
* requested amount of data is read before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.receive(asio::buffer(data, size), 0, out_flags);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().receive_with_flags(
|
||||
this->impl_.get_implementation(), buffers, in_flags, out_flags, ec);
|
||||
asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Receive some data on a connected socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes received. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The receive operation may not receive all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that the
|
||||
* requested amount of data is read before the blocking operation completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags, asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().receive_with_flags(
|
||||
this->impl_.get_implementation(), buffers, in_flags, out_flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
/**
|
||||
* This function is used to asynchronously receive data from the sequenced
|
||||
* packet socket. It is an initiating function for an @ref
|
||||
* asynchronous_operation, and always returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param out_flags Once the asynchronous operation completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record. The caller must guarantee that the referenced
|
||||
* variable remains valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the receive completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes received.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.async_receive(asio::buffer(data, size), out_flags, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags& out_flags,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_receive_with_flags>(), token,
|
||||
buffers, socket_base::message_flags(0), &out_flags))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_receive_with_flags(this), token,
|
||||
buffers, socket_base::message_flags(0), &out_flags);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
/**
|
||||
* This function is used to asynchronously receive data from the sequenced
|
||||
* data socket. It is an initiating function for an @ref
|
||||
* asynchronous_operation, and always returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags Once the asynchronous operation completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record. The caller must guarantee that the referenced
|
||||
* variable remains valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the receive completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes received.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.async_receive(
|
||||
* asio::buffer(data, size),
|
||||
* 0, out_flags, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_receive_with_flags>(),
|
||||
token, buffers, in_flags, &out_flags))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_receive_with_flags(this),
|
||||
token, buffers, in_flags, &out_flags);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_seq_packet_socket(const basic_seq_packet_socket&) = delete;
|
||||
basic_seq_packet_socket& operator=(
|
||||
const basic_seq_packet_socket&) = delete;
|
||||
|
||||
class initiate_async_send
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_send(basic_seq_packet_socket* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(WriteHandler&& handler,
|
||||
const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_send(
|
||||
self_->impl_.get_implementation(), buffers, flags,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_seq_packet_socket* self_;
|
||||
};
|
||||
|
||||
class initiate_async_receive_with_flags
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_receive_with_flags(basic_seq_packet_socket* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ReadHandler&& handler,
|
||||
const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags* out_flags) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_receive_with_flags(
|
||||
self_->impl_.get_implementation(), buffers, in_flags,
|
||||
*out_flags, handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_seq_packet_socket* self_;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
987
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_serial_port.hpp
vendored
Normal file
987
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_serial_port.hpp
vendored
Normal file
@@ -0,0 +1,987 @@
|
||||
//
|
||||
// basic_serial_port.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_SERIAL_PORT_HPP
|
||||
#define ASIO_BASIC_SERIAL_PORT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_SERIAL_PORT) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#include "asio/serial_port_base.hpp"
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
# include "asio/detail/win_iocp_serial_port_service.hpp"
|
||||
#else
|
||||
# include "asio/detail/posix_serial_port_service.hpp"
|
||||
#endif
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Provides serial port functionality.
|
||||
/**
|
||||
* The basic_serial_port class provides a wrapper over serial port
|
||||
* functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_serial_port
|
||||
: public serial_port_base
|
||||
{
|
||||
private:
|
||||
class initiate_async_write_some;
|
||||
class initiate_async_read_some;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the serial port type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The serial port type when rebound to the specified executor.
|
||||
typedef basic_serial_port<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a serial port.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#elif defined(ASIO_HAS_IOCP)
|
||||
typedef detail::win_iocp_serial_port_service::native_handle_type
|
||||
native_handle_type;
|
||||
#else
|
||||
typedef detail::posix_serial_port_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// A basic_basic_serial_port is always the lowest layer.
|
||||
typedef basic_serial_port lowest_layer_type;
|
||||
|
||||
/// Construct a basic_serial_port without opening it.
|
||||
/**
|
||||
* This constructor creates a serial port without opening it.
|
||||
*
|
||||
* @param ex The I/O executor that the serial port will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* serial port.
|
||||
*/
|
||||
explicit basic_serial_port(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_serial_port without opening it.
|
||||
/**
|
||||
* This constructor creates a serial port without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the serial port will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the serial port.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_serial_port(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_serial_port.
|
||||
/**
|
||||
* This constructor creates and opens a serial port for the specified device
|
||||
* name.
|
||||
*
|
||||
* @param ex The I/O executor that the serial port will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* serial port.
|
||||
*
|
||||
* @param device The platform-specific device name for this serial
|
||||
* port.
|
||||
*/
|
||||
basic_serial_port(const executor_type& ex, const char* device)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_serial_port.
|
||||
/**
|
||||
* This constructor creates and opens a serial port for the specified device
|
||||
* name.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the serial port will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the serial port.
|
||||
*
|
||||
* @param device The platform-specific device name for this serial
|
||||
* port.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_serial_port(ExecutionContext& context, const char* device,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_serial_port.
|
||||
/**
|
||||
* This constructor creates and opens a serial port for the specified device
|
||||
* name.
|
||||
*
|
||||
* @param ex The I/O executor that the serial port will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* serial port.
|
||||
*
|
||||
* @param device The platform-specific device name for this serial
|
||||
* port.
|
||||
*/
|
||||
basic_serial_port(const executor_type& ex, const std::string& device)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_serial_port.
|
||||
/**
|
||||
* This constructor creates and opens a serial port for the specified device
|
||||
* name.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the serial port will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the serial port.
|
||||
*
|
||||
* @param device The platform-specific device name for this serial
|
||||
* port.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_serial_port(ExecutionContext& context, const std::string& device,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_serial_port on an existing native serial port.
|
||||
/**
|
||||
* This constructor creates a serial port object to hold an existing native
|
||||
* serial port.
|
||||
*
|
||||
* @param ex The I/O executor that the serial port will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* serial port.
|
||||
*
|
||||
* @param native_serial_port A native serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_serial_port(const executor_type& ex,
|
||||
const native_handle_type& native_serial_port)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_serial_port, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct a basic_serial_port on an existing native serial port.
|
||||
/**
|
||||
* This constructor creates a serial port object to hold an existing native
|
||||
* serial port.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the serial port will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the serial port.
|
||||
*
|
||||
* @param native_serial_port A native serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_serial_port(ExecutionContext& context,
|
||||
const native_handle_type& native_serial_port,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_serial_port, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_serial_port from another.
|
||||
/**
|
||||
* This constructor moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_serial_port(basic_serial_port&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_serial_port from another.
|
||||
/**
|
||||
* This assignment operator moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_serial_port& operator=(basic_serial_port&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All serial ports have access to each other's implementations.
|
||||
template <typename Executor1>
|
||||
friend class basic_serial_port;
|
||||
|
||||
/// Move-construct a basic_serial_port from a serial port of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This constructor moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_serial_port(basic_serial_port<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_serial_port from a serial port of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This assignment operator moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_serial_port&
|
||||
> operator=(basic_serial_port<Executor1>&& other)
|
||||
{
|
||||
basic_serial_port tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the serial port.
|
||||
/**
|
||||
* This function destroys the serial port, cancelling any outstanding
|
||||
* asynchronous wait operations associated with the serial port as if by
|
||||
* calling @c cancel.
|
||||
*/
|
||||
~basic_serial_port()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_serial_port cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_serial_port cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Open the serial port using the specified device name.
|
||||
/**
|
||||
* This function opens the serial port for the specified device name.
|
||||
*
|
||||
* @param device The platform-specific device name.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void open(const std::string& device)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the serial port using the specified device name.
|
||||
/**
|
||||
* This function opens the serial port using the given platform-specific
|
||||
* device name.
|
||||
*
|
||||
* @param device The platform-specific device name.
|
||||
*
|
||||
* @param ec Set the indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID open(const std::string& device,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().open(impl_.get_implementation(), device, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Assign an existing native serial port to the serial port.
|
||||
/*
|
||||
* This function opens the serial port to hold an existing native serial port.
|
||||
*
|
||||
* @param native_serial_port A native serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& native_serial_port)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_serial_port, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native serial port to the serial port.
|
||||
/*
|
||||
* This function opens the serial port to hold an existing native serial port.
|
||||
*
|
||||
* @param native_serial_port A native serial port.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID assign(const native_handle_type& native_serial_port,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_serial_port, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the serial port is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the serial port.
|
||||
/**
|
||||
* This function is used to close the serial port. Any asynchronous read or
|
||||
* write operations will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the serial port.
|
||||
/**
|
||||
* This function is used to close the serial port. Any asynchronous read or
|
||||
* write operations will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID close(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Get the native serial port representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* serial port. This is intended to allow access to native serial port
|
||||
* functionality that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the serial port.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the serial port.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous read or write operations
|
||||
* to finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Send a break sequence to the serial port.
|
||||
/**
|
||||
* This function causes a break sequence of platform-specific duration to be
|
||||
* sent out the serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void send_break()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().send_break(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "send_break");
|
||||
}
|
||||
|
||||
/// Send a break sequence to the serial port.
|
||||
/**
|
||||
* This function causes a break sequence of platform-specific duration to be
|
||||
* sent out the serial port.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID send_break(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().send_break(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Set an option on the serial port.
|
||||
/**
|
||||
* This function is used to set an option on the serial port.
|
||||
*
|
||||
* @param option The option value to be set on the serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @sa SettableSerialPortOption @n
|
||||
* asio::serial_port_base::baud_rate @n
|
||||
* asio::serial_port_base::flow_control @n
|
||||
* asio::serial_port_base::parity @n
|
||||
* asio::serial_port_base::stop_bits @n
|
||||
* asio::serial_port_base::character_size
|
||||
*/
|
||||
template <typename SettableSerialPortOption>
|
||||
void set_option(const SettableSerialPortOption& option)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().set_option(impl_.get_implementation(), option, ec);
|
||||
asio::detail::throw_error(ec, "set_option");
|
||||
}
|
||||
|
||||
/// Set an option on the serial port.
|
||||
/**
|
||||
* This function is used to set an option on the serial port.
|
||||
*
|
||||
* @param option The option value to be set on the serial port.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @sa SettableSerialPortOption @n
|
||||
* asio::serial_port_base::baud_rate @n
|
||||
* asio::serial_port_base::flow_control @n
|
||||
* asio::serial_port_base::parity @n
|
||||
* asio::serial_port_base::stop_bits @n
|
||||
* asio::serial_port_base::character_size
|
||||
*/
|
||||
template <typename SettableSerialPortOption>
|
||||
ASIO_SYNC_OP_VOID set_option(const SettableSerialPortOption& option,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().set_option(impl_.get_implementation(), option, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Get an option from the serial port.
|
||||
/**
|
||||
* This function is used to get the current value of an option on the serial
|
||||
* port.
|
||||
*
|
||||
* @param option The option value to be obtained from the serial port.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @sa GettableSerialPortOption @n
|
||||
* asio::serial_port_base::baud_rate @n
|
||||
* asio::serial_port_base::flow_control @n
|
||||
* asio::serial_port_base::parity @n
|
||||
* asio::serial_port_base::stop_bits @n
|
||||
* asio::serial_port_base::character_size
|
||||
*/
|
||||
template <typename GettableSerialPortOption>
|
||||
void get_option(GettableSerialPortOption& option) const
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().get_option(impl_.get_implementation(), option, ec);
|
||||
asio::detail::throw_error(ec, "get_option");
|
||||
}
|
||||
|
||||
/// Get an option from the serial port.
|
||||
/**
|
||||
* This function is used to get the current value of an option on the serial
|
||||
* port.
|
||||
*
|
||||
* @param option The option value to be obtained from the serial port.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @sa GettableSerialPortOption @n
|
||||
* asio::serial_port_base::baud_rate @n
|
||||
* asio::serial_port_base::flow_control @n
|
||||
* asio::serial_port_base::parity @n
|
||||
* asio::serial_port_base::stop_bits @n
|
||||
* asio::serial_port_base::character_size
|
||||
*/
|
||||
template <typename GettableSerialPortOption>
|
||||
ASIO_SYNC_OP_VOID get_option(GettableSerialPortOption& option,
|
||||
asio::error_code& ec) const
|
||||
{
|
||||
impl_.get_service().get_option(impl_.get_implementation(), option, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Write some data to the serial port.
|
||||
/**
|
||||
* This function is used to write data to the serial port. The function call
|
||||
* will block until one or more bytes of the data has been written
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the serial port.
|
||||
*
|
||||
* @returns The number of bytes written.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_serial_port.write_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().write_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Write some data to the serial port.
|
||||
/**
|
||||
* This function is used to write data to the serial port. The function call
|
||||
* will block until one or more bytes of the data has been written
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the serial port.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes written. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().write_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
/**
|
||||
* This function is used to asynchronously write data to the serial port.
|
||||
* It is an initiating function for an @ref asynchronous_operation, and always
|
||||
* returns immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the serial port.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the write completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write function if you need to ensure that all
|
||||
* data is written before the asynchronous operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_serial_port.async_write_some(
|
||||
* asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename ConstBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) WriteToken = default_completion_token_t<executor_type>>
|
||||
auto async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_write_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_write_some(this), token, buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the serial port.
|
||||
/**
|
||||
* This function is used to read data from the serial port. The function
|
||||
* call will block until one or more bytes of data has been read successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @returns The number of bytes read.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_serial_port.read_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().read_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Read some data from the serial port.
|
||||
/**
|
||||
* This function is used to read data from the serial port. The function
|
||||
* call will block until one or more bytes of data has been read successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes read. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().read_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
/**
|
||||
* This function is used to asynchronously read data from the serial port.
|
||||
* It is an initiating function for an @ref asynchronous_operation, and always
|
||||
* returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the read completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read function if you need to ensure that the
|
||||
* requested amount of data is read before the asynchronous operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* basic_serial_port.async_read_some(
|
||||
* asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_read_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_read_some(this), token, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_serial_port(const basic_serial_port&) = delete;
|
||||
basic_serial_port& operator=(const basic_serial_port&) = delete;
|
||||
|
||||
class initiate_async_write_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_write_some(basic_serial_port* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(WriteHandler&& handler,
|
||||
const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_write_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_serial_port* self_;
|
||||
};
|
||||
|
||||
class initiate_async_read_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_read_some(basic_serial_port* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ReadHandler&& handler,
|
||||
const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_read_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_serial_port* self_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
detail::io_object_impl<detail::win_iocp_serial_port_service, Executor> impl_;
|
||||
#else
|
||||
detail::io_object_impl<detail::posix_serial_port_service, Executor> impl_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_SERIAL_PORT)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_SERIAL_PORT_HPP
|
||||
648
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_signal_set.hpp
vendored
Normal file
648
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_signal_set.hpp
vendored
Normal file
@@ -0,0 +1,648 @@
|
||||
//
|
||||
// basic_signal_set.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_SIGNAL_SET_HPP
|
||||
#define ASIO_BASIC_SIGNAL_SET_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/signal_set_service.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#include "asio/signal_set_base.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Provides signal functionality.
|
||||
/**
|
||||
* The basic_signal_set class provides the ability to perform an asynchronous
|
||||
* wait for one or more signals to occur.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Example
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(
|
||||
* const asio::error_code& error,
|
||||
* int signal_number)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // A signal occurred.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a signal set registered for process termination.
|
||||
* asio::signal_set signals(my_context, SIGINT, SIGTERM);
|
||||
*
|
||||
* // Start an asynchronous wait for one of the signals to occur.
|
||||
* signals.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Queueing of signal notifications
|
||||
*
|
||||
* If a signal is registered with a signal_set, and the signal occurs when
|
||||
* there are no waiting handlers, then the signal notification is queued. The
|
||||
* next async_wait operation on that signal_set will dequeue the notification.
|
||||
* If multiple notifications are queued, subsequent async_wait operations
|
||||
* dequeue them one at a time. Signal notifications are dequeued in order of
|
||||
* ascending signal number.
|
||||
*
|
||||
* If a signal number is removed from a signal_set (using the @c remove or @c
|
||||
* erase member functions) then any queued notifications for that signal are
|
||||
* discarded.
|
||||
*
|
||||
* @par Multiple registration of signals
|
||||
*
|
||||
* The same signal number may be registered with different signal_set objects.
|
||||
* When the signal occurs, one handler is called for each signal_set object.
|
||||
*
|
||||
* Note that multiple registration only works for signals that are registered
|
||||
* using Asio. The application must not also register a signal handler using
|
||||
* functions such as @c signal() or @c sigaction().
|
||||
*
|
||||
* @par Signal masking on POSIX platforms
|
||||
*
|
||||
* POSIX allows signals to be blocked using functions such as @c sigprocmask()
|
||||
* and @c pthread_sigmask(). For signals to be delivered, programs must ensure
|
||||
* that any signals registered using signal_set objects are unblocked in at
|
||||
* least one thread.
|
||||
*/
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_signal_set : public signal_set_base
|
||||
{
|
||||
private:
|
||||
class initiate_async_wait;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the signal set type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The signal set type when rebound to the specified executor.
|
||||
typedef basic_signal_set<Executor1> other;
|
||||
};
|
||||
|
||||
/// Construct a signal set without adding any signals.
|
||||
/**
|
||||
* This constructor creates a signal set without registering for any signals.
|
||||
*
|
||||
* @param ex The I/O executor that the signal set will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* signal set.
|
||||
*/
|
||||
explicit basic_signal_set(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a signal set without adding any signals.
|
||||
/**
|
||||
* This constructor creates a signal set without registering for any signals.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the signal set will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the signal set.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_signal_set(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a signal set and add one signal.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for one signal.
|
||||
*
|
||||
* @param ex The I/O executor that the signal set will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* signal set.
|
||||
*
|
||||
* @param signal_number_1 The signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(ex);
|
||||
* signals.add(signal_number_1); @endcode
|
||||
*/
|
||||
basic_signal_set(const executor_type& ex, int signal_number_1)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add one signal.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for one signal.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the signal set will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the signal set.
|
||||
*
|
||||
* @param signal_number_1 The signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(context);
|
||||
* signals.add(signal_number_1); @endcode
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_signal_set(ExecutionContext& context, int signal_number_1,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add two signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for two signals.
|
||||
*
|
||||
* @param ex The I/O executor that the signal set will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* signal set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(ex);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2); @endcode
|
||||
*/
|
||||
basic_signal_set(const executor_type& ex, int signal_number_1,
|
||||
int signal_number_2)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_2, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add two signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for two signals.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the signal set will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the signal set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(context);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2); @endcode
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_signal_set(ExecutionContext& context, int signal_number_1,
|
||||
int signal_number_2,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_2, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add three signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for three signals.
|
||||
*
|
||||
* @param ex The I/O executor that the signal set will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* signal set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @param signal_number_3 The third signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(ex);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2);
|
||||
* signals.add(signal_number_3); @endcode
|
||||
*/
|
||||
basic_signal_set(const executor_type& ex, int signal_number_1,
|
||||
int signal_number_2, int signal_number_3)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_2, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_3, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add three signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for three signals.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the signal set will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the signal set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @param signal_number_3 The third signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code asio::signal_set signals(context);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2);
|
||||
* signals.add(signal_number_3); @endcode
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_signal_set(ExecutionContext& context, int signal_number_1,
|
||||
int signal_number_2, int signal_number_3,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_2, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number_3, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Destroys the signal set.
|
||||
/**
|
||||
* This function destroys the signal set, cancelling any outstanding
|
||||
* asynchronous wait operations associated with the signal set as if by
|
||||
* calling @c cancel.
|
||||
*/
|
||||
~basic_signal_set()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void add(int signal_number)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID add(int signal_number,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set with the specified flags.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* Flags other than flags::dont_care require OS support for the @c sigaction
|
||||
* call, and this function will fail with @c error::operation_not_supported if
|
||||
* this is unavailable.
|
||||
*
|
||||
* The specified flags will conflict with a prior, active registration of the
|
||||
* same signal, if either specified a flags value other than flags::dont_care.
|
||||
* In this case, the @c add will fail with @c error::invalid_argument.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @param f Flags to modify the behaviour of the specified signal.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void add(int signal_number, flags_t f)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number, f, ec);
|
||||
asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set with the specified flags.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* Flags other than flags::dont_care require OS support for the @c sigaction
|
||||
* call, and this function will fail with @c error::operation_not_supported if
|
||||
* this is unavailable.
|
||||
*
|
||||
* The specified flags will conflict with a prior, active registration of the
|
||||
* same signal, if either specified a flags value other than flags::dont_care.
|
||||
* In this case, the @c add will fail with @c error::invalid_argument.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @param f Flags to modify the behaviour of the specified signal.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID add(int signal_number, flags_t f,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().add(impl_.get_implementation(), signal_number, f, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Remove a signal from a signal_set.
|
||||
/**
|
||||
* This function removes the specified signal from the set. It has no effect
|
||||
* if the signal is not in the set.
|
||||
*
|
||||
* @param signal_number The signal to be removed from the set.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note Removes any notifications that have been queued for the specified
|
||||
* signal number.
|
||||
*/
|
||||
void remove(int signal_number)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().remove(impl_.get_implementation(), signal_number, ec);
|
||||
asio::detail::throw_error(ec, "remove");
|
||||
}
|
||||
|
||||
/// Remove a signal from a signal_set.
|
||||
/**
|
||||
* This function removes the specified signal from the set. It has no effect
|
||||
* if the signal is not in the set.
|
||||
*
|
||||
* @param signal_number The signal to be removed from the set.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note Removes any notifications that have been queued for the specified
|
||||
* signal number.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID remove(int signal_number,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().remove(impl_.get_implementation(), signal_number, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Remove all signals from a signal_set.
|
||||
/**
|
||||
* This function removes all signals from the set. It has no effect if the set
|
||||
* is already empty.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note Removes all queued notifications.
|
||||
*/
|
||||
void clear()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().clear(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "clear");
|
||||
}
|
||||
|
||||
/// Remove all signals from a signal_set.
|
||||
/**
|
||||
* This function removes all signals from the set. It has no effect if the set
|
||||
* is already empty.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note Removes all queued notifications.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID clear(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().clear(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Cancel all operations associated with the signal set.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the signal set. The handler for each cancelled
|
||||
* operation will be invoked with the asio::error::operation_aborted
|
||||
* error code.
|
||||
*
|
||||
* Cancellation does not alter the set of registered signals.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If a registered signal occurred before cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all operations associated with the signal set.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the signal set. The handler for each cancelled
|
||||
* operation will be invoked with the asio::error::operation_aborted
|
||||
* error code.
|
||||
*
|
||||
* Cancellation does not alter the set of registered signals.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note If a registered signal occurred before cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous operation to wait for a signal to be delivered.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* signal set. It is an initiating function for an @ref
|
||||
* asynchronous_operation, and always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the completion handler will be called
|
||||
* exactly once. The completion handler will be called when:
|
||||
*
|
||||
* @li One of the registered signals in the signal set occurs; or
|
||||
*
|
||||
* @li The signal set was cancelled, in which case the handler is passed the
|
||||
* error code asio::error::operation_aborted.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the wait completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* int signal_number // Indicates which signal occurred.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, int) @endcode
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code, int))
|
||||
SignalToken = default_completion_token_t<executor_type>>
|
||||
auto async_wait(
|
||||
SignalToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<SignalToken, void (asio::error_code, int)>(
|
||||
declval<initiate_async_wait>(), token))
|
||||
{
|
||||
return async_initiate<SignalToken, void (asio::error_code, int)>(
|
||||
initiate_async_wait(this), token);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_signal_set(const basic_signal_set&) = delete;
|
||||
basic_signal_set& operator=(const basic_signal_set&) = delete;
|
||||
|
||||
class initiate_async_wait
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_wait(basic_signal_set* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename SignalHandler>
|
||||
void operator()(SignalHandler&& handler) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a SignalHandler.
|
||||
ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<SignalHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_wait(
|
||||
self_->impl_.get_implementation(),
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_signal_set* self_;
|
||||
};
|
||||
|
||||
detail::io_object_impl<detail::signal_set_service, Executor> impl_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BASIC_SIGNAL_SET_HPP
|
||||
1936
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket.hpp
vendored
Normal file
1936
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2708
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_acceptor.hpp
vendored
Normal file
2708
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_acceptor.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
331
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_iostream.hpp
vendored
Normal file
331
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_iostream.hpp
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
//
|
||||
// basic_socket_iostream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
#define ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include "asio/basic_socket_streambuf.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// A separate base class is used to ensure that the streambuf is initialised
|
||||
// prior to the basic_socket_iostream's basic_iostream base class.
|
||||
template <typename Protocol, typename Clock, typename WaitTraits>
|
||||
class socket_iostream_base
|
||||
{
|
||||
protected:
|
||||
socket_iostream_base()
|
||||
{
|
||||
}
|
||||
|
||||
socket_iostream_base(socket_iostream_base&& other)
|
||||
: streambuf_(std::move(other.streambuf_))
|
||||
{
|
||||
}
|
||||
|
||||
socket_iostream_base(basic_stream_socket<Protocol> s)
|
||||
: streambuf_(std::move(s))
|
||||
{
|
||||
}
|
||||
|
||||
socket_iostream_base& operator=(socket_iostream_base&& other)
|
||||
{
|
||||
streambuf_ = std::move(other.streambuf_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
basic_socket_streambuf<Protocol, Clock, WaitTraits> streambuf_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(ASIO_BASIC_SOCKET_IOSTREAM_FWD_DECL)
|
||||
#define ASIO_BASIC_SOCKET_IOSTREAM_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Protocol,
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typename Clock = boost::posix_time::ptime,
|
||||
typename WaitTraits = time_traits<Clock>>
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typename Clock = chrono::steady_clock,
|
||||
typename WaitTraits = wait_traits<Clock>>
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
class basic_socket_iostream;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_SOCKET_IOSTREAM_FWD_DECL)
|
||||
|
||||
/// Iostream interface for a socket.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Protocol,
|
||||
typename Clock = chrono::steady_clock,
|
||||
typename WaitTraits = wait_traits<Clock>>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Protocol, typename Clock, typename WaitTraits>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
class basic_socket_iostream
|
||||
: private detail::socket_iostream_base<Protocol, Clock, WaitTraits>,
|
||||
public std::basic_iostream<char>
|
||||
{
|
||||
private:
|
||||
// These typedefs are intended keep this class's implementation independent
|
||||
// of whether it's using Boost.DateClock, Boost.Chrono or std::chrono.
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typedef WaitTraits traits_helper;
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typedef detail::chrono_time_traits<Clock, WaitTraits> traits_helper;
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
|
||||
public:
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// The clock type.
|
||||
typedef Clock clock_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// (Deprecated: Use time_point.) The time type.
|
||||
typedef typename WaitTraits::time_type time_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename WaitTraits::time_point time_point;
|
||||
|
||||
/// (Deprecated: Use duration.) The duration type.
|
||||
typedef typename WaitTraits::duration_type duration_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename WaitTraits::duration duration;
|
||||
#else
|
||||
# if !defined(ASIO_NO_DEPRECATED)
|
||||
typedef typename traits_helper::time_type time_type;
|
||||
typedef typename traits_helper::duration_type duration_type;
|
||||
# endif // !defined(ASIO_NO_DEPRECATED)
|
||||
typedef typename traits_helper::time_type time_point;
|
||||
typedef typename traits_helper::duration_type duration;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_socket_iostream without establishing a connection.
|
||||
basic_socket_iostream()
|
||||
: std::basic_iostream<char>(
|
||||
&this->detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::streambuf_)
|
||||
{
|
||||
this->setf(std::ios_base::unitbuf);
|
||||
}
|
||||
|
||||
/// Construct a basic_socket_iostream from the supplied socket.
|
||||
explicit basic_socket_iostream(basic_stream_socket<protocol_type> s)
|
||||
: detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>(std::move(s)),
|
||||
std::basic_iostream<char>(
|
||||
&this->detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::streambuf_)
|
||||
{
|
||||
this->setf(std::ios_base::unitbuf);
|
||||
}
|
||||
|
||||
/// Move-construct a basic_socket_iostream from another.
|
||||
basic_socket_iostream(basic_socket_iostream&& other)
|
||||
: detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>(std::move(other)),
|
||||
std::basic_iostream<char>(std::move(other))
|
||||
{
|
||||
this->set_rdbuf(&this->detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::streambuf_);
|
||||
}
|
||||
|
||||
/// Move-assign a basic_socket_iostream from another.
|
||||
basic_socket_iostream& operator=(basic_socket_iostream&& other)
|
||||
{
|
||||
std::basic_iostream<char>::operator=(std::move(other));
|
||||
detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This constructor automatically establishes a connection based on the
|
||||
* supplied resolver query parameters. The arguments are used to construct
|
||||
* a resolver query object.
|
||||
*/
|
||||
template <typename... T>
|
||||
explicit basic_socket_iostream(T... x)
|
||||
: std::basic_iostream<char>(
|
||||
&this->detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::streambuf_)
|
||||
{
|
||||
this->setf(std::ios_base::unitbuf);
|
||||
if (rdbuf()->connect(x...) == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*/
|
||||
template <typename... T>
|
||||
void connect(T... x)
|
||||
{
|
||||
if (rdbuf()->connect(x...) == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
/// Close the connection.
|
||||
void close()
|
||||
{
|
||||
if (rdbuf()->close() == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
/// Return a pointer to the underlying streambuf.
|
||||
basic_socket_streambuf<Protocol, Clock, WaitTraits>* rdbuf() const
|
||||
{
|
||||
return const_cast<basic_socket_streambuf<Protocol, Clock, WaitTraits>*>(
|
||||
&this->detail::socket_iostream_base<
|
||||
Protocol, Clock, WaitTraits>::streambuf_);
|
||||
}
|
||||
|
||||
/// Get a reference to the underlying socket.
|
||||
basic_socket<Protocol>& socket()
|
||||
{
|
||||
return rdbuf()->socket();
|
||||
}
|
||||
|
||||
/// Get the last error associated with the stream.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream.
|
||||
*
|
||||
* @par Example
|
||||
* To print the error associated with a failure to establish a connection:
|
||||
* @code tcp::iostream s("www.boost.org", "http");
|
||||
* if (!s)
|
||||
* {
|
||||
* std::cout << "Error: " << s.error().message() << std::endl;
|
||||
* } @endcode
|
||||
*/
|
||||
const asio::error_code& error() const
|
||||
{
|
||||
return rdbuf()->error();
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use expiry().) Get the stream's expiry time as an absolute
|
||||
/// time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream's expiry time.
|
||||
*/
|
||||
time_point expires_at() const
|
||||
{
|
||||
return rdbuf()->expires_at();
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Get the stream's expiry time as an absolute time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream's expiry time.
|
||||
*/
|
||||
time_point expiry() const
|
||||
{
|
||||
return rdbuf()->expiry();
|
||||
}
|
||||
|
||||
/// Set the stream's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the stream.
|
||||
*/
|
||||
void expires_at(const time_point& expiry_time)
|
||||
{
|
||||
rdbuf()->expires_at(expiry_time);
|
||||
}
|
||||
|
||||
/// Set the stream's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_after(const duration& expiry_time)
|
||||
{
|
||||
rdbuf()->expires_after(expiry_time);
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use expiry().) Get the stream's expiry time relative to now.
|
||||
/**
|
||||
* @return A relative time value representing the stream's expiry time.
|
||||
*/
|
||||
duration expires_from_now() const
|
||||
{
|
||||
return rdbuf()->expires_from_now();
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expires_after().) Set the stream's expiry time relative
|
||||
/// to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_from_now(const duration& expiry_time)
|
||||
{
|
||||
rdbuf()->expires_from_now(expiry_time);
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_socket_iostream(const basic_socket_iostream&) = delete;
|
||||
basic_socket_iostream& operator=(
|
||||
const basic_socket_iostream&) = delete;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#endif // ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
642
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_streambuf.hpp
vendored
Normal file
642
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_socket_streambuf.hpp
vendored
Normal file
@@ -0,0 +1,642 @@
|
||||
//
|
||||
// basic_socket_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
#define ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#include <streambuf>
|
||||
#include <vector>
|
||||
#include "asio/basic_socket.hpp"
|
||||
#include "asio/basic_stream_socket.hpp"
|
||||
#include "asio/detail/buffer_sequence_adapter.hpp"
|
||||
#include "asio/detail/memory.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/io_context.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
# include "asio/detail/deadline_timer_service.hpp"
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
# include "asio/steady_timer.hpp"
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// A separate base class is used to ensure that the io_context member is
|
||||
// initialised prior to the basic_socket_streambuf's basic_socket base class.
|
||||
class socket_streambuf_io_context
|
||||
{
|
||||
protected:
|
||||
socket_streambuf_io_context(io_context* ctx)
|
||||
: default_io_context_(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<io_context> default_io_context_;
|
||||
};
|
||||
|
||||
// A separate base class is used to ensure that the dynamically allocated
|
||||
// buffers are constructed prior to the basic_socket_streambuf's basic_socket
|
||||
// base class. This makes moving the socket is the last potentially throwing
|
||||
// step in the streambuf's move constructor, giving the constructor a strong
|
||||
// exception safety guarantee.
|
||||
class socket_streambuf_buffers
|
||||
{
|
||||
protected:
|
||||
socket_streambuf_buffers()
|
||||
: get_buffer_(buffer_size),
|
||||
put_buffer_(buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
enum { buffer_size = 512 };
|
||||
std::vector<char> get_buffer_;
|
||||
std::vector<char> put_buffer_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(ASIO_BASIC_SOCKET_STREAMBUF_FWD_DECL)
|
||||
#define ASIO_BASIC_SOCKET_STREAMBUF_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Protocol,
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typename Clock = boost::posix_time::ptime,
|
||||
typename WaitTraits = time_traits<Clock>>
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typename Clock = chrono::steady_clock,
|
||||
typename WaitTraits = wait_traits<Clock>>
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
class basic_socket_streambuf;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_SOCKET_STREAMBUF_FWD_DECL)
|
||||
|
||||
/// Iostream streambuf for a socket.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Protocol,
|
||||
typename Clock = chrono::steady_clock,
|
||||
typename WaitTraits = wait_traits<Clock>>
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Protocol, typename Clock, typename WaitTraits>
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
class basic_socket_streambuf
|
||||
: public std::streambuf,
|
||||
private detail::socket_streambuf_io_context,
|
||||
private detail::socket_streambuf_buffers,
|
||||
#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
|
||||
private basic_socket<Protocol>
|
||||
#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
|
||||
public basic_socket<Protocol>
|
||||
#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
private:
|
||||
// These typedefs are intended keep this class's implementation independent
|
||||
// of whether it's using Boost.DateClock, Boost.Chrono or std::chrono.
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typedef WaitTraits traits_helper;
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
typedef detail::chrono_time_traits<Clock, WaitTraits> traits_helper;
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
|
||||
public:
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// The clock type.
|
||||
typedef Clock clock_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// (Deprecated: Use time_point.) The time type.
|
||||
typedef typename WaitTraits::time_type time_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename WaitTraits::time_point time_point;
|
||||
|
||||
/// (Deprecated: Use duration.) The duration type.
|
||||
typedef typename WaitTraits::duration_type duration_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename WaitTraits::duration duration;
|
||||
#else
|
||||
# if !defined(ASIO_NO_DEPRECATED)
|
||||
typedef typename traits_helper::time_type time_type;
|
||||
typedef typename traits_helper::duration_type duration_type;
|
||||
# endif // !defined(ASIO_NO_DEPRECATED)
|
||||
typedef typename traits_helper::time_type time_point;
|
||||
typedef typename traits_helper::duration_type duration;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_socket_streambuf without establishing a connection.
|
||||
basic_socket_streambuf()
|
||||
: detail::socket_streambuf_io_context(new io_context),
|
||||
basic_socket<Protocol>(*default_io_context_),
|
||||
expiry_time_(max_expiry_time())
|
||||
{
|
||||
init_buffers();
|
||||
}
|
||||
|
||||
/// Construct a basic_socket_streambuf from the supplied socket.
|
||||
explicit basic_socket_streambuf(basic_stream_socket<protocol_type> s)
|
||||
: detail::socket_streambuf_io_context(0),
|
||||
basic_socket<Protocol>(std::move(s)),
|
||||
expiry_time_(max_expiry_time())
|
||||
{
|
||||
init_buffers();
|
||||
}
|
||||
|
||||
/// Move-construct a basic_socket_streambuf from another.
|
||||
basic_socket_streambuf(basic_socket_streambuf&& other)
|
||||
: detail::socket_streambuf_io_context(other),
|
||||
basic_socket<Protocol>(std::move(other.socket())),
|
||||
ec_(other.ec_),
|
||||
expiry_time_(other.expiry_time_)
|
||||
{
|
||||
get_buffer_.swap(other.get_buffer_);
|
||||
put_buffer_.swap(other.put_buffer_);
|
||||
setg(other.eback(), other.gptr(), other.egptr());
|
||||
setp(other.pptr(), other.epptr());
|
||||
other.ec_ = asio::error_code();
|
||||
other.expiry_time_ = max_expiry_time();
|
||||
other.init_buffers();
|
||||
}
|
||||
|
||||
/// Move-assign a basic_socket_streambuf from another.
|
||||
basic_socket_streambuf& operator=(basic_socket_streambuf&& other)
|
||||
{
|
||||
this->close();
|
||||
socket() = std::move(other.socket());
|
||||
detail::socket_streambuf_io_context::operator=(other);
|
||||
ec_ = other.ec_;
|
||||
expiry_time_ = other.expiry_time_;
|
||||
get_buffer_.swap(other.get_buffer_);
|
||||
put_buffer_.swap(other.put_buffer_);
|
||||
setg(other.eback(), other.gptr(), other.egptr());
|
||||
setp(other.pptr(), other.epptr());
|
||||
other.ec_ = asio::error_code();
|
||||
other.expiry_time_ = max_expiry_time();
|
||||
other.put_buffer_.resize(buffer_size);
|
||||
other.init_buffers();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destructor flushes buffered data.
|
||||
virtual ~basic_socket_streambuf()
|
||||
{
|
||||
if (pptr() != pbase())
|
||||
overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function establishes a connection to the specified endpoint.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf* connect(const endpoint_type& endpoint)
|
||||
{
|
||||
init_buffers();
|
||||
ec_ = asio::error_code();
|
||||
this->connect_to_endpoints(&endpoint, &endpoint + 1);
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
template <typename... T>
|
||||
basic_socket_streambuf* connect(T... x)
|
||||
{
|
||||
init_buffers();
|
||||
typedef typename Protocol::resolver resolver_type;
|
||||
resolver_type resolver(socket().get_executor());
|
||||
connect_to_endpoints(resolver.resolve(x..., ec_));
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
|
||||
/// Close the connection.
|
||||
/**
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf* close()
|
||||
{
|
||||
sync();
|
||||
socket().close(ec_);
|
||||
if (!ec_)
|
||||
init_buffers();
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
|
||||
/// Get a reference to the underlying socket.
|
||||
basic_socket<Protocol>& socket()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get the last error associated with the stream buffer.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream
|
||||
* buffer.
|
||||
*/
|
||||
const asio::error_code& error() const
|
||||
{
|
||||
return ec_;
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use error().) Get the last error associated with the stream
|
||||
/// buffer.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream
|
||||
* buffer.
|
||||
*/
|
||||
const asio::error_code& puberror() const
|
||||
{
|
||||
return error();
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expiry().) Get the stream buffer's expiry time as an
|
||||
/// absolute time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream buffer's expiry
|
||||
* time.
|
||||
*/
|
||||
time_point expires_at() const
|
||||
{
|
||||
return expiry_time_;
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Get the stream buffer's expiry time as an absolute time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream buffer's expiry
|
||||
* time.
|
||||
*/
|
||||
time_point expiry() const
|
||||
{
|
||||
return expiry_time_;
|
||||
}
|
||||
|
||||
/// Set the stream buffer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the stream.
|
||||
*/
|
||||
void expires_at(const time_point& expiry_time)
|
||||
{
|
||||
expiry_time_ = expiry_time;
|
||||
}
|
||||
|
||||
/// Set the stream buffer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_after(const duration& expiry_time)
|
||||
{
|
||||
expiry_time_ = traits_helper::add(traits_helper::now(), expiry_time);
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use expiry().) Get the stream buffer's expiry time relative
|
||||
/// to now.
|
||||
/**
|
||||
* @return A relative time value representing the stream buffer's expiry time.
|
||||
*/
|
||||
duration expires_from_now() const
|
||||
{
|
||||
return traits_helper::subtract(expires_at(), traits_helper::now());
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expires_after().) Set the stream buffer's expiry time
|
||||
/// relative to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_from_now(const duration& expiry_time)
|
||||
{
|
||||
expiry_time_ = traits_helper::add(traits_helper::now(), expiry_time);
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
protected:
|
||||
int_type underflow()
|
||||
{
|
||||
#if defined(ASIO_WINDOWS_RUNTIME)
|
||||
ec_ = asio::error::operation_not_supported;
|
||||
return traits_type::eof();
|
||||
#else // defined(ASIO_WINDOWS_RUNTIME)
|
||||
if (gptr() != egptr())
|
||||
return traits_type::eof();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// Check if we are past the expiry time.
|
||||
if (traits_helper::less_than(expiry_time_, traits_helper::now()))
|
||||
{
|
||||
ec_ = asio::error::timed_out;
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Try to complete the operation without blocking.
|
||||
if (!socket().native_non_blocking())
|
||||
socket().native_non_blocking(true, ec_);
|
||||
detail::buffer_sequence_adapter<mutable_buffer, mutable_buffer>
|
||||
bufs(asio::buffer(get_buffer_) + putback_max);
|
||||
detail::signed_size_type bytes = detail::socket_ops::recv(
|
||||
socket().native_handle(), bufs.buffers(), bufs.count(), 0, ec_);
|
||||
|
||||
// Check if operation succeeded.
|
||||
if (bytes > 0)
|
||||
{
|
||||
setg(&get_buffer_[0], &get_buffer_[0] + putback_max,
|
||||
&get_buffer_[0] + putback_max + bytes);
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
|
||||
// Check for EOF.
|
||||
if (bytes == 0)
|
||||
{
|
||||
ec_ = asio::error::eof;
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Operation failed.
|
||||
if (ec_ != asio::error::would_block
|
||||
&& ec_ != asio::error::try_again)
|
||||
return traits_type::eof();
|
||||
|
||||
// Wait for socket to become ready.
|
||||
if (detail::socket_ops::poll_read(
|
||||
socket().native_handle(), 0, timeout(), ec_) < 0)
|
||||
return traits_type::eof();
|
||||
}
|
||||
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
||||
}
|
||||
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
#if defined(ASIO_WINDOWS_RUNTIME)
|
||||
ec_ = asio::error::operation_not_supported;
|
||||
return traits_type::eof();
|
||||
#else // defined(ASIO_WINDOWS_RUNTIME)
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
|
||||
// Determine what needs to be sent.
|
||||
const_buffer output_buffer;
|
||||
if (put_buffer_.empty())
|
||||
{
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
return traits_type::not_eof(c); // Nothing to do.
|
||||
output_buffer = asio::buffer(&ch, sizeof(char_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
output_buffer = asio::buffer(pbase(),
|
||||
(pptr() - pbase()) * sizeof(char_type));
|
||||
}
|
||||
|
||||
while (output_buffer.size() > 0)
|
||||
{
|
||||
// Check if we are past the expiry time.
|
||||
if (traits_helper::less_than(expiry_time_, traits_helper::now()))
|
||||
{
|
||||
ec_ = asio::error::timed_out;
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Try to complete the operation without blocking.
|
||||
if (!socket().native_non_blocking())
|
||||
socket().native_non_blocking(true, ec_);
|
||||
detail::buffer_sequence_adapter<
|
||||
const_buffer, const_buffer> bufs(output_buffer);
|
||||
detail::signed_size_type bytes = detail::socket_ops::send(
|
||||
socket().native_handle(), bufs.buffers(), bufs.count(), 0, ec_);
|
||||
|
||||
// Check if operation succeeded.
|
||||
if (bytes > 0)
|
||||
{
|
||||
output_buffer += static_cast<std::size_t>(bytes);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Operation failed.
|
||||
if (ec_ != asio::error::would_block
|
||||
&& ec_ != asio::error::try_again)
|
||||
return traits_type::eof();
|
||||
|
||||
// Wait for socket to become ready.
|
||||
if (detail::socket_ops::poll_write(
|
||||
socket().native_handle(), 0, timeout(), ec_) < 0)
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
if (!put_buffer_.empty())
|
||||
{
|
||||
setp(&put_buffer_[0], &put_buffer_[0] + put_buffer_.size());
|
||||
|
||||
// If the new character is eof then our work here is done.
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
return traits_type::not_eof(c);
|
||||
|
||||
// Add the new character to the output buffer.
|
||||
*pptr() = ch;
|
||||
pbump(1);
|
||||
}
|
||||
|
||||
return c;
|
||||
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
||||
}
|
||||
|
||||
int sync()
|
||||
{
|
||||
return overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
std::streambuf* setbuf(char_type* s, std::streamsize n)
|
||||
{
|
||||
if (pptr() == pbase() && s == 0 && n == 0)
|
||||
{
|
||||
put_buffer_.clear();
|
||||
setp(0, 0);
|
||||
sync();
|
||||
return this;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_socket_streambuf(const basic_socket_streambuf&) = delete;
|
||||
basic_socket_streambuf& operator=(
|
||||
const basic_socket_streambuf&) = delete;
|
||||
|
||||
void init_buffers()
|
||||
{
|
||||
setg(&get_buffer_[0],
|
||||
&get_buffer_[0] + putback_max,
|
||||
&get_buffer_[0] + putback_max);
|
||||
|
||||
if (put_buffer_.empty())
|
||||
setp(0, 0);
|
||||
else
|
||||
setp(&put_buffer_[0], &put_buffer_[0] + put_buffer_.size());
|
||||
}
|
||||
|
||||
int timeout() const
|
||||
{
|
||||
int64_t msec = traits_helper::to_posix_duration(
|
||||
traits_helper::subtract(expiry_time_,
|
||||
traits_helper::now())).total_milliseconds();
|
||||
if (msec > (std::numeric_limits<int>::max)())
|
||||
msec = (std::numeric_limits<int>::max)();
|
||||
else if (msec < 0)
|
||||
msec = 0;
|
||||
return static_cast<int>(msec);
|
||||
}
|
||||
|
||||
template <typename EndpointSequence>
|
||||
void connect_to_endpoints(const EndpointSequence& endpoints)
|
||||
{
|
||||
this->connect_to_endpoints(endpoints.begin(), endpoints.end());
|
||||
}
|
||||
|
||||
template <typename EndpointIterator>
|
||||
void connect_to_endpoints(EndpointIterator begin, EndpointIterator end)
|
||||
{
|
||||
#if defined(ASIO_WINDOWS_RUNTIME)
|
||||
ec_ = asio::error::operation_not_supported;
|
||||
#else // defined(ASIO_WINDOWS_RUNTIME)
|
||||
if (ec_)
|
||||
return;
|
||||
|
||||
ec_ = asio::error::not_found;
|
||||
for (EndpointIterator i = begin; i != end; ++i)
|
||||
{
|
||||
// Check if we are past the expiry time.
|
||||
if (traits_helper::less_than(expiry_time_, traits_helper::now()))
|
||||
{
|
||||
ec_ = asio::error::timed_out;
|
||||
return;
|
||||
}
|
||||
|
||||
// Close and reopen the socket.
|
||||
typename Protocol::endpoint ep(*i);
|
||||
socket().close(ec_);
|
||||
socket().open(ep.protocol(), ec_);
|
||||
if (ec_)
|
||||
continue;
|
||||
|
||||
// Try to complete the operation without blocking.
|
||||
if (!socket().native_non_blocking())
|
||||
socket().native_non_blocking(true, ec_);
|
||||
detail::socket_ops::connect(socket().native_handle(),
|
||||
ep.data(), ep.size(), ec_);
|
||||
|
||||
// Check if operation succeeded.
|
||||
if (!ec_)
|
||||
return;
|
||||
|
||||
// Operation failed.
|
||||
if (ec_ != asio::error::in_progress
|
||||
&& ec_ != asio::error::would_block)
|
||||
continue;
|
||||
|
||||
// Wait for socket to become ready.
|
||||
if (detail::socket_ops::poll_connect(
|
||||
socket().native_handle(), timeout(), ec_) < 0)
|
||||
continue;
|
||||
|
||||
// Get the error code from the connect operation.
|
||||
int connect_error = 0;
|
||||
size_t connect_error_len = sizeof(connect_error);
|
||||
if (detail::socket_ops::getsockopt(socket().native_handle(), 0,
|
||||
SOL_SOCKET, SO_ERROR, &connect_error, &connect_error_len, ec_)
|
||||
== detail::socket_error_retval)
|
||||
return;
|
||||
|
||||
// Check the result of the connect operation.
|
||||
ec_ = asio::error_code(connect_error,
|
||||
asio::error::get_system_category());
|
||||
if (!ec_)
|
||||
return;
|
||||
}
|
||||
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
||||
}
|
||||
|
||||
// Helper function to get the maximum expiry time.
|
||||
static time_point max_expiry_time()
|
||||
{
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
&& defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
return boost::posix_time::pos_infin;
|
||||
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
return (time_point::max)();
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM)
|
||||
}
|
||||
|
||||
enum { putback_max = 8 };
|
||||
asio::error_code ec_;
|
||||
time_point expiry_time_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#endif // ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
744
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_stream_file.hpp
vendored
Normal file
744
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_stream_file.hpp
vendored
Normal file
@@ -0,0 +1,744 @@
|
||||
//
|
||||
// basic_stream_file.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_STREAM_FILE_HPP
|
||||
#define ASIO_BASIC_STREAM_FILE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_FILE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/basic_file.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/error.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if !defined(ASIO_BASIC_STREAM_FILE_FWD_DECL)
|
||||
#define ASIO_BASIC_STREAM_FILE_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_stream_file;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_STREAM_FILE_FWD_DECL)
|
||||
|
||||
/// Provides stream-oriented file functionality.
|
||||
/**
|
||||
* The basic_stream_file class template provides asynchronous and blocking
|
||||
* stream-oriented file functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Executor>
|
||||
class basic_stream_file
|
||||
: public basic_file<Executor>
|
||||
{
|
||||
private:
|
||||
class initiate_async_write_some;
|
||||
class initiate_async_read_some;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the file type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The file type when rebound to the specified executor.
|
||||
typedef basic_stream_file<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a file.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef typename basic_file<Executor>::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_stream_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it. The file needs to
|
||||
* be opened before data can be read from or or written to it.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*/
|
||||
explicit basic_stream_file(const executor_type& ex)
|
||||
: basic_file<Executor>(ex)
|
||||
{
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
}
|
||||
|
||||
/// Construct a basic_stream_file without opening it.
|
||||
/**
|
||||
* This constructor initialises a file without opening it. The file needs to
|
||||
* be opened before data can be read from or or written to it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_stream_file(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context)
|
||||
{
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
}
|
||||
|
||||
/// Construct and open a basic_stream_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_stream_file(const executor_type& ex,
|
||||
const char* path, file_base::flags open_flags)
|
||||
: basic_file<Executor>(ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
this->impl_.get_service().open(
|
||||
this->impl_.get_implementation(),
|
||||
path, open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_stream_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_stream_file(ExecutionContext& context,
|
||||
const char* path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
this->impl_.get_service().open(
|
||||
this->impl_.get_implementation(),
|
||||
path, open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_stream_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_stream_file(const executor_type& ex,
|
||||
const std::string& path, file_base::flags open_flags)
|
||||
: basic_file<Executor>(ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
this->impl_.get_service().open(
|
||||
this->impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_stream_file.
|
||||
/**
|
||||
* This constructor initialises and opens a file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param path The path name identifying the file to be opened.
|
||||
*
|
||||
* @param open_flags A set of flags that determine how the file should be
|
||||
* opened.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_stream_file(ExecutionContext& context,
|
||||
const std::string& path, file_base::flags open_flags,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
this->impl_.get_service().open(
|
||||
this->impl_.get_implementation(),
|
||||
path.c_str(), open_flags, ec);
|
||||
asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_stream_file on an existing native file.
|
||||
/**
|
||||
* This constructor initialises a stream file object to hold an existing
|
||||
* native file.
|
||||
*
|
||||
* @param ex The I/O executor that the file will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the file.
|
||||
*
|
||||
* @param native_file The new underlying file implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_stream_file(const executor_type& ex,
|
||||
const native_handle_type& native_file)
|
||||
: basic_file<Executor>(ex, native_file)
|
||||
{
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
}
|
||||
|
||||
/// Construct a basic_stream_file on an existing native file.
|
||||
/**
|
||||
* This constructor initialises a stream file object to hold an existing
|
||||
* native file.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the file will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the file.
|
||||
*
|
||||
* @param native_file The new underlying file implementation.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_stream_file(ExecutionContext& context,
|
||||
const native_handle_type& native_file,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(context, native_file)
|
||||
{
|
||||
this->impl_.get_service().set_is_stream(
|
||||
this->impl_.get_implementation(), true);
|
||||
}
|
||||
|
||||
/// Move-construct a basic_stream_file from another.
|
||||
/**
|
||||
* This constructor moves a stream file from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_stream_file(basic_stream_file&& other) noexcept
|
||||
: basic_file<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_stream_file from another.
|
||||
/**
|
||||
* This assignment operator moves a stream file from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_stream_file& operator=(basic_stream_file&& other)
|
||||
{
|
||||
basic_file<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move-construct a basic_stream_file from a file of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This constructor moves a stream file from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_stream_file(basic_stream_file<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: basic_file<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_stream_file from a file of another executor type.
|
||||
/**
|
||||
* This assignment operator moves a stream file from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_file object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_file(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_stream_file&
|
||||
> operator=(basic_stream_file<Executor1>&& other)
|
||||
{
|
||||
basic_file<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the file.
|
||||
/**
|
||||
* This function destroys the file, cancelling any outstanding asynchronous
|
||||
* operations associated with the file as if by calling @c cancel.
|
||||
*/
|
||||
~basic_stream_file()
|
||||
{
|
||||
}
|
||||
|
||||
/// Seek to a position in the file.
|
||||
/**
|
||||
* This function updates the current position in the file.
|
||||
*
|
||||
* @param offset The requested position in the file, relative to @c whence.
|
||||
*
|
||||
* @param whence One of @c seek_set, @c seek_cur or @c seek_end.
|
||||
*
|
||||
* @returns The new position relative to the beginning of the file.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
uint64_t seek(int64_t offset, file_base::seek_basis whence)
|
||||
{
|
||||
asio::error_code ec;
|
||||
uint64_t n = this->impl_.get_service().seek(
|
||||
this->impl_.get_implementation(), offset, whence, ec);
|
||||
asio::detail::throw_error(ec, "seek");
|
||||
return n;
|
||||
}
|
||||
|
||||
/// Seek to a position in the file.
|
||||
/**
|
||||
* This function updates the current position in the file.
|
||||
*
|
||||
* @param offset The requested position in the file, relative to @c whence.
|
||||
*
|
||||
* @param whence One of @c seek_set, @c seek_cur or @c seek_end.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The new position relative to the beginning of the file.
|
||||
*/
|
||||
uint64_t seek(int64_t offset, file_base::seek_basis whence,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().seek(
|
||||
this->impl_.get_implementation(), offset, whence, ec);
|
||||
}
|
||||
|
||||
/// Write some data to the file.
|
||||
/**
|
||||
* This function is used to write data to the stream file. The function call
|
||||
* will block until one or more bytes of the data has been written
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the file.
|
||||
*
|
||||
* @returns The number of bytes written.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the end of the file was reached.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* file.write_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().write_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Write some data to the file.
|
||||
/**
|
||||
* This function is used to write data to the stream file. The function call
|
||||
* will block until one or more bytes of the data has been written
|
||||
* successfully, or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the file.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes written. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().write_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
/**
|
||||
* This function is used to asynchronously write data to the stream file.
|
||||
* It is an initiating function for an @ref asynchronous_operation, and always
|
||||
* returns immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the file.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the write completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write function if you need to ensure that all
|
||||
* data is written before the asynchronous operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* file.async_write_some(asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename ConstBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) WriteToken = default_completion_token_t<executor_type>>
|
||||
auto async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_write_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_write_some(this), token, buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the file.
|
||||
/**
|
||||
* This function is used to read data from the stream file. The function
|
||||
* call will block until one or more bytes of data has been read successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @returns The number of bytes read.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the end of the file was reached.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* file.read_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = this->impl_.get_service().read_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Read some data from the file.
|
||||
/**
|
||||
* This function is used to read data from the stream file. The function
|
||||
* call will block until one or more bytes of data has been read successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes read. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The read_some operation may not read all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that
|
||||
* the requested amount of data is read before the blocking operation
|
||||
* completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return this->impl_.get_service().read_some(
|
||||
this->impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
/**
|
||||
* This function is used to asynchronously read data from the stream file.
|
||||
* It is an initiating function for an @ref asynchronous_operation, and always
|
||||
* returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be read.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the read completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read function if you need to ensure that the
|
||||
* requested amount of data is read before the asynchronous operation
|
||||
* completes.
|
||||
*
|
||||
* @par Example
|
||||
* To read into a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* file.async_read_some(asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on reading into multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* On POSIX or Windows operating systems, this asynchronous operation supports
|
||||
* cancellation for the following asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) ReadToken = default_completion_token_t<executor_type>>
|
||||
auto async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_read_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<ReadToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_read_some(this), token, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_stream_file(const basic_stream_file&) = delete;
|
||||
basic_stream_file& operator=(const basic_stream_file&) = delete;
|
||||
|
||||
class initiate_async_write_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_write_some(basic_stream_file* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(WriteHandler&& handler,
|
||||
const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_write_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_stream_file* self_;
|
||||
};
|
||||
|
||||
class initiate_async_read_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_read_some(basic_stream_file* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(ReadHandler&& handler,
|
||||
const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a ReadHandler.
|
||||
ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_read_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_stream_file* self_;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_FILE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_STREAM_FILE_HPP
|
||||
1163
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_stream_socket.hpp
vendored
Normal file
1163
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_stream_socket.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
450
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_streambuf.hpp
vendored
Normal file
450
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_streambuf.hpp
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
//
|
||||
// basic_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_STREAMBUF_HPP
|
||||
#define ASIO_BASIC_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <streambuf>
|
||||
#include <vector>
|
||||
#include "asio/basic_streambuf_fwd.hpp"
|
||||
#include "asio/buffer.hpp"
|
||||
#include "asio/detail/limits.hpp"
|
||||
#include "asio/detail/noncopyable.hpp"
|
||||
#include "asio/detail/throw_exception.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Automatically resizable buffer class based on std::streambuf.
|
||||
/**
|
||||
* The @c basic_streambuf class is derived from @c std::streambuf to associate
|
||||
* the streambuf's input and output sequences with one or more character
|
||||
* arrays. These character arrays are internal to the @c basic_streambuf
|
||||
* object, but direct access to the array elements is provided to permit them
|
||||
* to be used efficiently with I/O operations. Characters written to the output
|
||||
* sequence of a @c basic_streambuf object are appended to the input sequence
|
||||
* of the same object.
|
||||
*
|
||||
* The @c basic_streambuf class's public interface is intended to permit the
|
||||
* following implementation strategies:
|
||||
*
|
||||
* @li A single contiguous character array, which is reallocated as necessary
|
||||
* to accommodate changes in the size of the character sequence. This is the
|
||||
* implementation approach currently used in Asio.
|
||||
*
|
||||
* @li A sequence of one or more character arrays, where each array is of the
|
||||
* same size. Additional character array objects are appended to the sequence
|
||||
* to accommodate changes in the size of the character sequence.
|
||||
*
|
||||
* @li A sequence of one or more character arrays of varying sizes. Additional
|
||||
* character array objects are appended to the sequence to accommodate changes
|
||||
* in the size of the character sequence.
|
||||
*
|
||||
* The constructor for basic_streambuf accepts a @c size_t argument specifying
|
||||
* the maximum of the sum of the sizes of the input sequence and output
|
||||
* sequence. During the lifetime of the @c basic_streambuf object, the following
|
||||
* invariant holds:
|
||||
* @code size() <= max_size()@endcode
|
||||
* Any member function that would, if successful, cause the invariant to be
|
||||
* violated shall throw an exception of class @c std::length_error.
|
||||
*
|
||||
* The constructor for @c basic_streambuf takes an Allocator argument. A copy
|
||||
* of this argument is used for any memory allocation performed, by the
|
||||
* constructor and by all member functions, during the lifetime of each @c
|
||||
* basic_streambuf object.
|
||||
*
|
||||
* @par Examples
|
||||
* Writing directly from an streambuf to a socket:
|
||||
* @code
|
||||
* asio::streambuf b;
|
||||
* std::ostream os(&b);
|
||||
* os << "Hello, World!\n";
|
||||
*
|
||||
* // try sending some data in input sequence
|
||||
* size_t n = sock.send(b.data());
|
||||
*
|
||||
* b.consume(n); // sent data is removed from input sequence
|
||||
* @endcode
|
||||
*
|
||||
* Reading from a socket directly into a streambuf:
|
||||
* @code
|
||||
* asio::streambuf b;
|
||||
*
|
||||
* // reserve 512 bytes in output sequence
|
||||
* asio::streambuf::mutable_buffers_type bufs = b.prepare(512);
|
||||
*
|
||||
* size_t n = sock.receive(bufs);
|
||||
*
|
||||
* // received data is "committed" from output sequence to input sequence
|
||||
* b.commit(n);
|
||||
*
|
||||
* std::istream is(&b);
|
||||
* std::string s;
|
||||
* is >> s;
|
||||
* @endcode
|
||||
*/
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Allocator = std::allocator<char>>
|
||||
#else
|
||||
template <typename Allocator>
|
||||
#endif
|
||||
class basic_streambuf
|
||||
: public std::streambuf,
|
||||
private noncopyable
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
typedef implementation_defined const_buffers_type;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
typedef implementation_defined mutable_buffers_type;
|
||||
#else
|
||||
typedef ASIO_CONST_BUFFER const_buffers_type;
|
||||
typedef ASIO_MUTABLE_BUFFER mutable_buffers_type;
|
||||
#endif
|
||||
|
||||
/// Construct a basic_streambuf object.
|
||||
/**
|
||||
* Constructs a streambuf with the specified maximum size. The initial size
|
||||
* of the streambuf's input sequence is 0.
|
||||
*/
|
||||
explicit basic_streambuf(
|
||||
std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)(),
|
||||
const Allocator& allocator = Allocator())
|
||||
: max_size_(maximum_size),
|
||||
buffer_(allocator)
|
||||
{
|
||||
std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);
|
||||
buffer_.resize((std::max<std::size_t>)(pend, 1));
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0]);
|
||||
setp(&buffer_[0], &buffer_[0] + pend);
|
||||
}
|
||||
|
||||
/// Get the size of the input sequence.
|
||||
/**
|
||||
* @returns The size of the input sequence. The value is equal to that
|
||||
* calculated for @c s in the following code:
|
||||
* @code
|
||||
* size_t s = 0;
|
||||
* const_buffers_type bufs = data();
|
||||
* const_buffers_type::const_iterator i = bufs.begin();
|
||||
* while (i != bufs.end())
|
||||
* {
|
||||
* const_buffer buf(*i++);
|
||||
* s += buf.size();
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
std::size_t size() const noexcept
|
||||
{
|
||||
return pptr() - gptr();
|
||||
}
|
||||
|
||||
/// Get the maximum size of the basic_streambuf.
|
||||
/**
|
||||
* @returns The allowed maximum of the sum of the sizes of the input sequence
|
||||
* and output sequence.
|
||||
*/
|
||||
std::size_t max_size() const noexcept
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
/// Get the current capacity of the basic_streambuf.
|
||||
/**
|
||||
* @returns The current total capacity of the streambuf, i.e. for both the
|
||||
* input sequence and output sequence.
|
||||
*/
|
||||
std::size_t capacity() const noexcept
|
||||
{
|
||||
return buffer_.capacity();
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the input sequence.
|
||||
/**
|
||||
* @returns An object of type @c const_buffers_type that satisfies
|
||||
* ConstBufferSequence requirements, representing all character arrays in the
|
||||
* input sequence.
|
||||
*
|
||||
* @note The returned object is invalidated by any @c basic_streambuf member
|
||||
* function that modifies the input sequence or output sequence.
|
||||
*/
|
||||
const_buffers_type data() const noexcept
|
||||
{
|
||||
return asio::buffer(asio::const_buffer(gptr(),
|
||||
(pptr() - gptr()) * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the output sequence, with the given
|
||||
/// size.
|
||||
/**
|
||||
* Ensures that the output sequence can accommodate @c n characters,
|
||||
* reallocating character array objects as necessary.
|
||||
*
|
||||
* @returns An object of type @c mutable_buffers_type that satisfies
|
||||
* MutableBufferSequence requirements, representing character array objects
|
||||
* at the start of the output sequence such that the sum of the buffer sizes
|
||||
* is @c n.
|
||||
*
|
||||
* @throws std::length_error If <tt>size() + n > max_size()</tt>.
|
||||
*
|
||||
* @note The returned object is invalidated by any @c basic_streambuf member
|
||||
* function that modifies the input sequence or output sequence.
|
||||
*/
|
||||
mutable_buffers_type prepare(std::size_t n)
|
||||
{
|
||||
reserve(n);
|
||||
return asio::buffer(asio::mutable_buffer(
|
||||
pptr(), n * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Move characters from the output sequence to the input sequence.
|
||||
/**
|
||||
* Appends @c n characters from the start of the output sequence to the input
|
||||
* sequence. The beginning of the output sequence is advanced by @c n
|
||||
* characters.
|
||||
*
|
||||
* Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and
|
||||
* no intervening operations that modify the input or output sequence.
|
||||
*
|
||||
* @note If @c n is greater than the size of the output sequence, the entire
|
||||
* output sequence is moved to the input sequence and no error is issued.
|
||||
*/
|
||||
void commit(std::size_t n)
|
||||
{
|
||||
n = std::min<std::size_t>(n, epptr() - pptr());
|
||||
pbump(static_cast<int>(n));
|
||||
setg(eback(), gptr(), pptr());
|
||||
}
|
||||
|
||||
/// Remove characters from the input sequence.
|
||||
/**
|
||||
* Removes @c n characters from the beginning of the input sequence.
|
||||
*
|
||||
* @note If @c n is greater than the size of the input sequence, the entire
|
||||
* input sequence is consumed and no error is issued.
|
||||
*/
|
||||
void consume(std::size_t n)
|
||||
{
|
||||
if (egptr() < pptr())
|
||||
setg(&buffer_[0], gptr(), pptr());
|
||||
if (gptr() + n > pptr())
|
||||
n = pptr() - gptr();
|
||||
gbump(static_cast<int>(n));
|
||||
}
|
||||
|
||||
protected:
|
||||
enum { buffer_delta = 128 };
|
||||
|
||||
/// Override std::streambuf behaviour.
|
||||
/**
|
||||
* Behaves according to the specification of @c std::streambuf::underflow().
|
||||
*/
|
||||
int_type underflow()
|
||||
{
|
||||
if (gptr() < pptr())
|
||||
{
|
||||
setg(&buffer_[0], gptr(), pptr());
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
|
||||
/// Override std::streambuf behaviour.
|
||||
/**
|
||||
* Behaves according to the specification of @c std::streambuf::overflow(),
|
||||
* with the specialisation that @c std::length_error is thrown if appending
|
||||
* the character to the input sequence would require the condition
|
||||
* <tt>size() > max_size()</tt> to be true.
|
||||
*/
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
if (!traits_type::eq_int_type(c, traits_type::eof()))
|
||||
{
|
||||
if (pptr() == epptr())
|
||||
{
|
||||
std::size_t buffer_size = pptr() - gptr();
|
||||
if (buffer_size < max_size_ && max_size_ - buffer_size < buffer_delta)
|
||||
{
|
||||
reserve(max_size_ - buffer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
reserve(buffer_delta);
|
||||
}
|
||||
}
|
||||
|
||||
*pptr() = traits_type::to_char_type(c);
|
||||
pbump(1);
|
||||
return c;
|
||||
}
|
||||
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
|
||||
void reserve(std::size_t n)
|
||||
{
|
||||
// Get current stream positions as offsets.
|
||||
std::size_t gnext = gptr() - &buffer_[0];
|
||||
std::size_t pnext = pptr() - &buffer_[0];
|
||||
std::size_t pend = epptr() - &buffer_[0];
|
||||
|
||||
// Check if there is already enough space in the put area.
|
||||
if (n <= pend - pnext)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift existing contents of get area to start of buffer.
|
||||
if (gnext > 0)
|
||||
{
|
||||
pnext -= gnext;
|
||||
std::memmove(&buffer_[0], &buffer_[0] + gnext, pnext);
|
||||
}
|
||||
|
||||
// Ensure buffer is large enough to hold at least the specified size.
|
||||
if (n > pend - pnext)
|
||||
{
|
||||
if (n <= max_size_ && pnext <= max_size_ - n)
|
||||
{
|
||||
pend = pnext + n;
|
||||
buffer_.resize((std::max<std::size_t>)(pend, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::length_error ex("asio::streambuf too long");
|
||||
asio::detail::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Update stream positions.
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0] + pnext);
|
||||
setp(&buffer_[0] + pnext, &buffer_[0] + pend);
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t max_size_;
|
||||
std::vector<char_type, Allocator> buffer_;
|
||||
|
||||
// Helper function to get the preferred size for reading data.
|
||||
friend std::size_t read_size_helper(
|
||||
basic_streambuf& sb, std::size_t max_size)
|
||||
{
|
||||
return std::min<std::size_t>(
|
||||
std::max<std::size_t>(512, sb.buffer_.capacity() - sb.size()),
|
||||
std::min<std::size_t>(max_size, sb.max_size() - sb.size()));
|
||||
}
|
||||
};
|
||||
|
||||
/// Adapts basic_streambuf to the dynamic buffer sequence type requirements.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
template <typename Allocator = std::allocator<char>>
|
||||
#else
|
||||
template <typename Allocator>
|
||||
#endif
|
||||
class basic_streambuf_ref
|
||||
{
|
||||
public:
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
typedef typename basic_streambuf<Allocator>::const_buffers_type
|
||||
const_buffers_type;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
typedef typename basic_streambuf<Allocator>::mutable_buffers_type
|
||||
mutable_buffers_type;
|
||||
|
||||
/// Construct a basic_streambuf_ref for the given basic_streambuf object.
|
||||
explicit basic_streambuf_ref(basic_streambuf<Allocator>& sb)
|
||||
: sb_(sb)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy construct a basic_streambuf_ref.
|
||||
basic_streambuf_ref(const basic_streambuf_ref& other) noexcept
|
||||
: sb_(other.sb_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct a basic_streambuf_ref.
|
||||
basic_streambuf_ref(basic_streambuf_ref&& other) noexcept
|
||||
: sb_(other.sb_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the size of the input sequence.
|
||||
std::size_t size() const noexcept
|
||||
{
|
||||
return sb_.size();
|
||||
}
|
||||
|
||||
/// Get the maximum size of the dynamic buffer.
|
||||
std::size_t max_size() const noexcept
|
||||
{
|
||||
return sb_.max_size();
|
||||
}
|
||||
|
||||
/// Get the current capacity of the dynamic buffer.
|
||||
std::size_t capacity() const noexcept
|
||||
{
|
||||
return sb_.capacity();
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the input sequence.
|
||||
const_buffers_type data() const noexcept
|
||||
{
|
||||
return sb_.data();
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the output sequence, with the given
|
||||
/// size.
|
||||
mutable_buffers_type prepare(std::size_t n)
|
||||
{
|
||||
return sb_.prepare(n);
|
||||
}
|
||||
|
||||
/// Move bytes from the output sequence to the input sequence.
|
||||
void commit(std::size_t n)
|
||||
{
|
||||
return sb_.commit(n);
|
||||
}
|
||||
|
||||
/// Remove characters from the input sequence.
|
||||
void consume(std::size_t n)
|
||||
{
|
||||
return sb_.consume(n);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_streambuf<Allocator>& sb_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#endif // ASIO_BASIC_STREAMBUF_HPP
|
||||
36
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_streambuf_fwd.hpp
vendored
Normal file
36
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_streambuf_fwd.hpp
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// basic_streambuf_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_STREAMBUF_FWD_HPP
|
||||
#define ASIO_BASIC_STREAMBUF_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename Allocator = std::allocator<char>>
|
||||
class basic_streambuf;
|
||||
|
||||
template <typename Allocator = std::allocator<char>>
|
||||
class basic_streambuf_ref;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#endif // !defined(ASIO_NO_IOSTREAM)
|
||||
|
||||
#endif // ASIO_BASIC_STREAMBUF_FWD_HPP
|
||||
824
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp
vendored
Normal file
824
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp
vendored
Normal file
@@ -0,0 +1,824 @@
|
||||
//
|
||||
// basic_waitable_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
#define ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/detail/chrono_time_traits.hpp"
|
||||
#include "asio/detail/deadline_timer_service.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/wait_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if !defined(ASIO_BASIC_WAITABLE_TIMER_FWD_DECL)
|
||||
#define ASIO_BASIC_WAITABLE_TIMER_FWD_DECL
|
||||
|
||||
// Forward declaration with defaulted arguments.
|
||||
template <typename Clock,
|
||||
typename WaitTraits = asio::wait_traits<Clock>,
|
||||
typename Executor = any_io_executor>
|
||||
class basic_waitable_timer;
|
||||
|
||||
#endif // !defined(ASIO_BASIC_WAITABLE_TIMER_FWD_DECL)
|
||||
|
||||
/// Provides waitable timer functionality.
|
||||
/**
|
||||
* The basic_waitable_timer class template provides the ability to perform a
|
||||
* blocking or asynchronous wait for a timer to expire.
|
||||
*
|
||||
* A waitable timer is always in one of two states: "expired" or "not expired".
|
||||
* If the wait() or async_wait() function is called on an expired timer, the
|
||||
* wait operation will complete immediately.
|
||||
*
|
||||
* Most applications will use one of the asio::steady_timer,
|
||||
* asio::system_timer or asio::high_resolution_timer typedefs.
|
||||
*
|
||||
* @note This waitable timer functionality is for use with the C++11 standard
|
||||
* library's @c <chrono> facility, or with the Boost.Chrono library.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Examples
|
||||
* Performing a blocking wait (C++11):
|
||||
* @code
|
||||
* // Construct a timer without setting an expiry time.
|
||||
* asio::steady_timer timer(my_context);
|
||||
*
|
||||
* // Set an expiry time relative to now.
|
||||
* timer.expires_after(std::chrono::seconds(5));
|
||||
*
|
||||
* // Wait for the timer to expire.
|
||||
* timer.wait();
|
||||
* @endcode
|
||||
*
|
||||
* @par
|
||||
* Performing an asynchronous wait (C++11):
|
||||
* @code
|
||||
* void handler(const asio::error_code& error)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // Timer expired.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a timer with an absolute expiry time.
|
||||
* asio::steady_timer timer(my_context,
|
||||
* std::chrono::steady_clock::now() + std::chrono::seconds(60));
|
||||
*
|
||||
* // Start an asynchronous wait.
|
||||
* timer.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Changing an active waitable timer's expiry time
|
||||
*
|
||||
* Changing the expiry time of a timer while there are pending asynchronous
|
||||
* waits causes those wait operations to be cancelled. To ensure that the action
|
||||
* associated with the timer is performed only once, use something like this:
|
||||
* used:
|
||||
*
|
||||
* @code
|
||||
* void on_some_event()
|
||||
* {
|
||||
* if (my_timer.expires_after(seconds(5)) > 0)
|
||||
* {
|
||||
* // We managed to cancel the timer. Start new asynchronous wait.
|
||||
* my_timer.async_wait(on_timeout);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Too late, timer has already expired!
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void on_timeout(const asio::error_code& e)
|
||||
* {
|
||||
* if (e != asio::error::operation_aborted)
|
||||
* {
|
||||
* // Timer was not cancelled, take necessary action.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @li The asio::basic_waitable_timer::expires_after() function
|
||||
* cancels any pending asynchronous waits, and returns the number of
|
||||
* asynchronous waits that were cancelled. If it returns 0 then you were too
|
||||
* late and the wait handler has already been executed, or will soon be
|
||||
* executed. If it returns 1 then the wait handler was successfully cancelled.
|
||||
*
|
||||
* @li If a wait handler is cancelled, the asio::error_code passed to
|
||||
* it contains the value asio::error::operation_aborted.
|
||||
*/
|
||||
template <typename Clock, typename WaitTraits, typename Executor>
|
||||
class basic_waitable_timer
|
||||
{
|
||||
private:
|
||||
class initiate_async_wait;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the timer type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The timer type when rebound to the specified executor.
|
||||
typedef basic_waitable_timer<Clock, WaitTraits, Executor1> other;
|
||||
};
|
||||
|
||||
/// The clock type.
|
||||
typedef Clock clock_type;
|
||||
|
||||
/// The duration type of the clock.
|
||||
typedef typename clock_type::duration duration;
|
||||
|
||||
/// The time point type of the clock.
|
||||
typedef typename clock_type::time_point time_point;
|
||||
|
||||
/// The wait traits type.
|
||||
typedef WaitTraits traits_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_after() functions must be called to set an expiry
|
||||
* time before the timer can be waited on.
|
||||
*
|
||||
* @param ex The I/O executor that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*/
|
||||
explicit basic_waitable_timer(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_after() functions must be called to set an expiry
|
||||
* time before the timer can be waited on.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_waitable_timer(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param ex The I/O executor object that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
basic_waitable_timer(const executor_type& ex, const time_point& expiry_time)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_waitable_timer(ExecutionContext& context,
|
||||
const time_point& expiry_time,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param ex The I/O executor that the timer will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
basic_waitable_timer(const executor_type& ex, const duration& expiry_time)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_after(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_after");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the timer will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_waitable_timer(ExecutionContext& context,
|
||||
const duration& expiry_time,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().expires_after(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_after");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_waitable_timer from another.
|
||||
/**
|
||||
* This constructor moves a timer from one object to another.
|
||||
*
|
||||
* @param other The other basic_waitable_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_waitable_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_waitable_timer(basic_waitable_timer&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_waitable_timer from another.
|
||||
/**
|
||||
* This assignment operator moves a timer from one object to another. Cancels
|
||||
* any outstanding asynchronous operations associated with the target object.
|
||||
*
|
||||
* @param other The other basic_waitable_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_waitable_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_waitable_timer& operator=(basic_waitable_timer&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All timers have access to each other's implementations.
|
||||
template <typename Clock1, typename WaitTraits1, typename Executor1>
|
||||
friend class basic_waitable_timer;
|
||||
|
||||
/// Move-construct a basic_waitable_timer from another.
|
||||
/**
|
||||
* This constructor moves a timer from one object to another.
|
||||
*
|
||||
* @param other The other basic_waitable_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_waitable_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_waitable_timer(
|
||||
basic_waitable_timer<Clock, WaitTraits, Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value
|
||||
> = 0)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_waitable_timer from another.
|
||||
/**
|
||||
* This assignment operator moves a timer from one object to another. Cancels
|
||||
* any outstanding asynchronous operations associated with the target object.
|
||||
*
|
||||
* @param other The other basic_waitable_timer object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_waitable_timer(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_waitable_timer&
|
||||
> operator=(basic_waitable_timer<Clock, WaitTraits, Executor1>&& other)
|
||||
{
|
||||
basic_waitable_timer tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the timer.
|
||||
/**
|
||||
* This function destroys the timer, cancelling any outstanding asynchronous
|
||||
* wait operations associated with the timer as if by calling @c cancel.
|
||||
*/
|
||||
~basic_waitable_timer()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use non-error_code overload.) Cancel any asynchronous
|
||||
/// operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one()
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().cancel_one(
|
||||
impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel_one");
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use non-error_code overload.) Cancels one asynchronous
|
||||
/// operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().cancel_one(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expiry().) Get the timer's expiry time as an absolute
|
||||
/// time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_point expires_at() const
|
||||
{
|
||||
return impl_.get_service().expires_at(impl_.get_implementation());
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_point expiry() const
|
||||
{
|
||||
return impl_.get_service().expiry(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_point& expiry_time)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().expires_at(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use non-error_code overload.) Set the timer's expiry time as
|
||||
/// an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_point& expiry_time,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().expires_at(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_after() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_after(const duration& expiry_time)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().expires_after(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_after");
|
||||
return s;
|
||||
}
|
||||
|
||||
#if !defined(ASIO_NO_DEPRECATED)
|
||||
/// (Deprecated: Use expiry().) Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
duration expires_from_now() const
|
||||
{
|
||||
return impl_.get_service().expires_from_now(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expires_after().) Set the timer's expiry time relative
|
||||
/// to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration& expiry_time)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
asio::detail::throw_error(ec, "expires_from_now");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// (Deprecated: Use expires_after().) Set the timer's expiry time relative
|
||||
/// to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration& expiry_time,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().expires_from_now(
|
||||
impl_.get_implementation(), expiry_time, ec);
|
||||
}
|
||||
#endif // !defined(ASIO_NO_DEPRECATED)
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "wait");
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
void wait(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().wait(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the timer.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* timer. It is an initiating function for an @ref asynchronous_operation,
|
||||
* and always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the completion handler will be called
|
||||
* exactly once. The completion handler will be called when:
|
||||
*
|
||||
* @li The timer has expired.
|
||||
*
|
||||
* @li The timer was cancelled, in which case the handler is passed the error
|
||||
* code asio::error::operation_aborted.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the timer expires. Potential
|
||||
* completion tokens include @ref use_future, @ref use_awaitable, @ref
|
||||
* yield_context, or a function object with the correct completion signature.
|
||||
* The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code) @endcode
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code))
|
||||
WaitToken = default_completion_token_t<executor_type>>
|
||||
auto async_wait(
|
||||
WaitToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WaitToken, void (asio::error_code)>(
|
||||
declval<initiate_async_wait>(), token))
|
||||
{
|
||||
return async_initiate<WaitToken, void (asio::error_code)>(
|
||||
initiate_async_wait(this), token);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_waitable_timer(const basic_waitable_timer&) = delete;
|
||||
basic_waitable_timer& operator=(const basic_waitable_timer&) = delete;
|
||||
|
||||
class initiate_async_wait
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_wait(basic_waitable_timer* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WaitHandler>
|
||||
void operator()(WaitHandler&& handler) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WaitHandler.
|
||||
ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WaitHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_wait(
|
||||
self_->impl_.get_implementation(),
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_waitable_timer* self_;
|
||||
};
|
||||
|
||||
detail::io_object_impl<
|
||||
detail::deadline_timer_service<
|
||||
detail::chrono_time_traits<Clock, WaitTraits>>,
|
||||
executor_type > impl_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
622
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_writable_pipe.hpp
vendored
Normal file
622
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/basic_writable_pipe.hpp
vendored
Normal file
@@ -0,0 +1,622 @@
|
||||
//
|
||||
// basic_writable_pipe.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BASIC_WRITABLE_PIPE_HPP
|
||||
#define ASIO_BASIC_WRITABLE_PIPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_PIPE) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "asio/any_io_executor.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/handler_type_requirements.hpp"
|
||||
#include "asio/detail/io_object_impl.hpp"
|
||||
#include "asio/detail/non_const_lvalue.hpp"
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/execution_context.hpp"
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
# include "asio/detail/win_iocp_handle_service.hpp"
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
# include "asio/detail/io_uring_descriptor_service.hpp"
|
||||
#else
|
||||
# include "asio/detail/reactive_descriptor_service.hpp"
|
||||
#endif
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// Provides pipe functionality.
|
||||
/**
|
||||
* The basic_writable_pipe class provides a wrapper over pipe
|
||||
* functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_writable_pipe
|
||||
{
|
||||
private:
|
||||
class initiate_async_write_some;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the pipe type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The pipe type when rebound to the specified executor.
|
||||
typedef basic_writable_pipe<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a pipe.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#elif defined(ASIO_HAS_IOCP)
|
||||
typedef detail::win_iocp_handle_service::native_handle_type
|
||||
native_handle_type;
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
typedef detail::io_uring_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#else
|
||||
typedef detail::reactive_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
|
||||
/// A basic_writable_pipe is always the lowest layer.
|
||||
typedef basic_writable_pipe lowest_layer_type;
|
||||
|
||||
/// Construct a basic_writable_pipe without opening it.
|
||||
/**
|
||||
* This constructor creates a pipe without opening it.
|
||||
*
|
||||
* @param ex The I/O executor that the pipe will use, by default, to dispatch
|
||||
* handlers for any asynchronous operations performed on the pipe.
|
||||
*/
|
||||
explicit basic_writable_pipe(const executor_type& ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_writable_pipe without opening it.
|
||||
/**
|
||||
* This constructor creates a pipe without opening it.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the pipe will use, by default, to dispatch handlers for any asynchronous
|
||||
* operations performed on the pipe.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_writable_pipe(ExecutionContext& context,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_writable_pipe on an existing native pipe.
|
||||
/**
|
||||
* This constructor creates a pipe object to hold an existing native
|
||||
* pipe.
|
||||
*
|
||||
* @param ex The I/O executor that the pipe will use, by default, to
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
basic_writable_pipe(const executor_type& ex,
|
||||
const native_handle_type& native_pipe)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Construct a basic_writable_pipe on an existing native pipe.
|
||||
/**
|
||||
* This constructor creates a pipe object to hold an existing native
|
||||
* pipe.
|
||||
*
|
||||
* @param context An execution context which provides the I/O executor that
|
||||
* the pipe will use, by default, to dispatch handlers for any
|
||||
* asynchronous operations performed on the pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
basic_writable_pipe(ExecutionContext& context,
|
||||
const native_handle_type& native_pipe,
|
||||
constraint_t<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
> = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Move-construct a basic_writable_pipe from another.
|
||||
/**
|
||||
* This constructor moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_writable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_writable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_writable_pipe(basic_writable_pipe&& other)
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_writable_pipe from another.
|
||||
/**
|
||||
* This assignment operator moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_writable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_writable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_writable_pipe& operator=(basic_writable_pipe&& other)
|
||||
{
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All pipes have access to each other's implementations.
|
||||
template <typename Executor1>
|
||||
friend class basic_writable_pipe;
|
||||
|
||||
/// Move-construct a basic_writable_pipe from a pipe of another executor type.
|
||||
/**
|
||||
* This constructor moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_writable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_writable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_writable_pipe(basic_writable_pipe<Executor1>&& other,
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
> = defaulted_constraint())
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_writable_pipe from a pipe of another executor type.
|
||||
/**
|
||||
* This assignment operator moves a pipe from one object to another.
|
||||
*
|
||||
* @param other The other basic_writable_pipe object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_writable_pipe(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
constraint_t<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_writable_pipe&
|
||||
> operator=(basic_writable_pipe<Executor1>&& other)
|
||||
{
|
||||
basic_writable_pipe tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Destroys the pipe.
|
||||
/**
|
||||
* This function destroys the pipe, cancelling any outstanding
|
||||
* asynchronous wait operations associated with the pipe as if by
|
||||
* calling @c cancel.
|
||||
*/
|
||||
~basic_writable_pipe()
|
||||
{
|
||||
}
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
const executor_type& get_executor() noexcept
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_writable_pipe cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A reference to the lowest layer in the stack of layers. Ownership
|
||||
* is not transferred to the caller.
|
||||
*/
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a const reference to the lowest layer in a stack of
|
||||
* layers. Since a basic_writable_pipe cannot contain any further layers, it
|
||||
* simply returns a reference to itself.
|
||||
*
|
||||
* @return A const reference to the lowest layer in the stack of layers.
|
||||
* Ownership is not transferred to the caller.
|
||||
*/
|
||||
const lowest_layer_type& lowest_layer() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Assign an existing native pipe to the pipe.
|
||||
/*
|
||||
* This function opens the pipe to hold an existing native pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_handle_type& native_pipe)
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_pipe, ec);
|
||||
asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native pipe to the pipe.
|
||||
/*
|
||||
* This function opens the pipe to hold an existing native pipe.
|
||||
*
|
||||
* @param native_pipe A native pipe.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID assign(const native_handle_type& native_pipe,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().assign(impl_.get_implementation(), native_pipe, ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Determine whether the pipe is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return impl_.get_service().is_open(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Close the pipe.
|
||||
/**
|
||||
* This function is used to close the pipe. Any asynchronous write operations
|
||||
* will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the pipe.
|
||||
/**
|
||||
* This function is used to close the pipe. Any asynchronous write operations
|
||||
* will be cancelled immediately, and will complete with the
|
||||
* asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID close(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().close(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous write operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error. Ownership of the
|
||||
* native pipe is then transferred to the caller.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release()
|
||||
{
|
||||
asio::error_code ec;
|
||||
native_handle_type s = impl_.get_service().release(
|
||||
impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "release");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Release ownership of the underlying native pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous write operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error. Ownership of the
|
||||
* native pipe is then transferred to the caller.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note This function is unsupported on Windows versions prior to Windows
|
||||
* 8.1, and will fail with asio::error::operation_not_supported on
|
||||
* these platforms.
|
||||
*/
|
||||
#if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \
|
||||
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0603)
|
||||
__declspec(deprecated("This function always fails with "
|
||||
"operation_not_supported when used on Windows versions "
|
||||
"prior to Windows 8.1."))
|
||||
#endif
|
||||
native_handle_type release(asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().release(impl_.get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Get the native pipe representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* pipe. This is intended to allow access to native pipe
|
||||
* functionality that is not otherwise provided.
|
||||
*/
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return impl_.get_service().native_handle(impl_.get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous write operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
asio::error_code ec;
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the pipe.
|
||||
/**
|
||||
* This function causes all outstanding asynchronous write operations to
|
||||
* finish immediately, and the handlers for cancelled operations will be
|
||||
* passed the asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
ASIO_SYNC_OP_VOID cancel(asio::error_code& ec)
|
||||
{
|
||||
impl_.get_service().cancel(impl_.get_implementation(), ec);
|
||||
ASIO_SYNC_OP_VOID_RETURN(ec);
|
||||
}
|
||||
|
||||
/// Write some data to the pipe.
|
||||
/**
|
||||
* This function is used to write data to the pipe. The function call will
|
||||
* block until one or more bytes of the data has been written successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the pipe.
|
||||
*
|
||||
* @returns The number of bytes written.
|
||||
*
|
||||
* @throws asio::system_error Thrown on failure. An error code of
|
||||
* asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* pipe.write_some(asio::buffer(data, size));
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::size_t s = impl_.get_service().write_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Write some data to the pipe.
|
||||
/**
|
||||
* This function is used to write data to the pipe. The function call will
|
||||
* block until one or more bytes of the data has been written successfully,
|
||||
* or until an error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the pipe.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes written. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The write_some operation may not transmit all of the data to the
|
||||
* peer. Consider using the @ref write function if you need to ensure that
|
||||
* all data is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
asio::error_code& ec)
|
||||
{
|
||||
return impl_.get_service().write_some(
|
||||
impl_.get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
/**
|
||||
* This function is used to asynchronously write data to the pipe. It is an
|
||||
* initiating function for an @ref asynchronous_operation, and always returns
|
||||
* immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the pipe.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the write completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const asio::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the completion handler will not be invoked from within this function.
|
||||
* On immediate completion, invocation of the handler will be performed in a
|
||||
* manner equivalent to using asio::async_immediate().
|
||||
*
|
||||
* @par Completion Signature
|
||||
* @code void(asio::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write function if you need to ensure that all
|
||||
* data is written before the asynchronous operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To write a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* pipe.async_write_some(asio::buffer(data, size), handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on writing multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence,
|
||||
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
|
||||
std::size_t)) WriteToken = default_completion_token_t<executor_type>>
|
||||
auto async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteToken&& token = default_completion_token_t<executor_type>())
|
||||
-> decltype(
|
||||
async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
declval<initiate_async_write_some>(), token, buffers))
|
||||
{
|
||||
return async_initiate<WriteToken,
|
||||
void (asio::error_code, std::size_t)>(
|
||||
initiate_async_write_some(this), token, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_writable_pipe(const basic_writable_pipe&) = delete;
|
||||
basic_writable_pipe& operator=(const basic_writable_pipe&) = delete;
|
||||
|
||||
class initiate_async_write_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_write_some(basic_writable_pipe* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const noexcept
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(WriteHandler&& handler,
|
||||
const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WriteHandler.
|
||||
ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self_->impl_.get_service().async_write_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_writable_pipe* self_;
|
||||
};
|
||||
|
||||
#if defined(ASIO_HAS_IOCP)
|
||||
detail::io_object_impl<detail::win_iocp_handle_service, Executor> impl_;
|
||||
#elif defined(ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
detail::io_object_impl<detail::io_uring_descriptor_service, Executor> impl_;
|
||||
#else
|
||||
detail::io_object_impl<detail::reactive_descriptor_service, Executor> impl_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_PIPE)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_WRITABLE_PIPE_HPP
|
||||
596
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/bind_allocator.hpp
vendored
Normal file
596
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/bind_allocator.hpp
vendored
Normal file
@@ -0,0 +1,596 @@
|
||||
//
|
||||
// bind_allocator.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BIND_ALLOCATOR_HPP
|
||||
#define ASIO_BIND_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/associated_allocator.hpp"
|
||||
#include "asio/associated_executor.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/initiation_base.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Helper to automatically define nested typedef result_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct allocator_binder_result_type
|
||||
{
|
||||
protected:
|
||||
typedef void result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct allocator_binder_result_type<T, void_t<typename T::result_type>>
|
||||
{
|
||||
typedef typename T::result_type result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct allocator_binder_result_type<R(*)()>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct allocator_binder_result_type<R(&)()>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct allocator_binder_result_type<R(*)(A1)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct allocator_binder_result_type<R(&)(A1)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct allocator_binder_result_type<R(*)(A1, A2)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct allocator_binder_result_type<R(&)(A1, A2)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
// Helper to automatically define nested typedef argument_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct allocator_binder_argument_type {};
|
||||
|
||||
template <typename T>
|
||||
struct allocator_binder_argument_type<T, void_t<typename T::argument_type>>
|
||||
{
|
||||
typedef typename T::argument_type argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct allocator_binder_argument_type<R(*)(A1)>
|
||||
{
|
||||
typedef A1 argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct allocator_binder_argument_type<R(&)(A1)>
|
||||
{
|
||||
typedef A1 argument_type;
|
||||
};
|
||||
|
||||
// Helper to automatically define nested typedefs first_argument_type and
|
||||
// second_argument_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct allocator_binder_argument_types {};
|
||||
|
||||
template <typename T>
|
||||
struct allocator_binder_argument_types<T,
|
||||
void_t<typename T::first_argument_type>>
|
||||
{
|
||||
typedef typename T::first_argument_type first_argument_type;
|
||||
typedef typename T::second_argument_type second_argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct allocator_binder_argument_type<R(*)(A1, A2)>
|
||||
{
|
||||
typedef A1 first_argument_type;
|
||||
typedef A2 second_argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct allocator_binder_argument_type<R(&)(A1, A2)>
|
||||
{
|
||||
typedef A1 first_argument_type;
|
||||
typedef A2 second_argument_type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// A call wrapper type to bind an allocator of type @c Allocator
|
||||
/// to an object of type @c T.
|
||||
template <typename T, typename Allocator>
|
||||
class allocator_binder
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: public detail::allocator_binder_result_type<T>,
|
||||
public detail::allocator_binder_argument_type<T>,
|
||||
public detail::allocator_binder_argument_types<T>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
public:
|
||||
/// The type of the target object.
|
||||
typedef T target_type;
|
||||
|
||||
/// The type of the associated allocator.
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The return type if a function.
|
||||
/**
|
||||
* The type of @c result_type is based on the type @c T of the wrapper's
|
||||
* target object:
|
||||
*
|
||||
* @li if @c T is a pointer to function type, @c result_type is a synonym for
|
||||
* the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c result_type, then @c
|
||||
* result_type is a synonym for @c T::result_type;
|
||||
*
|
||||
* @li otherwise @c result_type is not defined.
|
||||
*/
|
||||
typedef see_below result_type;
|
||||
|
||||
/// The type of the function's argument.
|
||||
/**
|
||||
* The type of @c argument_type is based on the type @c T of the wrapper's
|
||||
* target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting a single argument,
|
||||
* @c argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c argument_type, then @c
|
||||
* argument_type is a synonym for @c T::argument_type;
|
||||
*
|
||||
* @li otherwise @c argument_type is not defined.
|
||||
*/
|
||||
typedef see_below argument_type;
|
||||
|
||||
/// The type of the function's first argument.
|
||||
/**
|
||||
* The type of @c first_argument_type is based on the type @c T of the
|
||||
* wrapper's target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting two arguments, @c
|
||||
* first_argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c first_argument_type,
|
||||
* then @c first_argument_type is a synonym for @c T::first_argument_type;
|
||||
*
|
||||
* @li otherwise @c first_argument_type is not defined.
|
||||
*/
|
||||
typedef see_below first_argument_type;
|
||||
|
||||
/// The type of the function's second argument.
|
||||
/**
|
||||
* The type of @c second_argument_type is based on the type @c T of the
|
||||
* wrapper's target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting two arguments, @c
|
||||
* second_argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c first_argument_type,
|
||||
* then @c second_argument_type is a synonym for @c T::second_argument_type;
|
||||
*
|
||||
* @li otherwise @c second_argument_type is not defined.
|
||||
*/
|
||||
typedef see_below second_argument_type;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct an allocator wrapper for the specified object.
|
||||
/**
|
||||
* This constructor is only valid if the type @c T is constructible from type
|
||||
* @c U.
|
||||
*/
|
||||
template <typename U>
|
||||
allocator_binder(const allocator_type& s, U&& u)
|
||||
: allocator_(s),
|
||||
target_(static_cast<U&&>(u))
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor.
|
||||
allocator_binder(const allocator_binder& other)
|
||||
: allocator_(other.get_allocator()),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy, but specify a different allocator.
|
||||
allocator_binder(const allocator_type& s, const allocator_binder& other)
|
||||
: allocator_(s),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy of a different allocator wrapper type.
|
||||
/**
|
||||
* This constructor is only valid if the @c Allocator type is
|
||||
* constructible from type @c OtherAllocator, and the type @c T is
|
||||
* constructible from type @c U.
|
||||
*/
|
||||
template <typename U, typename OtherAllocator>
|
||||
allocator_binder(const allocator_binder<U, OtherAllocator>& other,
|
||||
constraint_t<is_constructible<Allocator, OtherAllocator>::value> = 0,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: allocator_(other.get_allocator()),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy of a different allocator wrapper type, but
|
||||
/// specify a different allocator.
|
||||
/**
|
||||
* This constructor is only valid if the type @c T is constructible from type
|
||||
* @c U.
|
||||
*/
|
||||
template <typename U, typename OtherAllocator>
|
||||
allocator_binder(const allocator_type& s,
|
||||
const allocator_binder<U, OtherAllocator>& other,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: allocator_(s),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Move constructor.
|
||||
allocator_binder(allocator_binder&& other)
|
||||
: allocator_(static_cast<allocator_type&&>(
|
||||
other.get_allocator())),
|
||||
target_(static_cast<T&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct the target object, but specify a different allocator.
|
||||
allocator_binder(const allocator_type& s,
|
||||
allocator_binder&& other)
|
||||
: allocator_(s),
|
||||
target_(static_cast<T&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct from a different allocator wrapper type.
|
||||
template <typename U, typename OtherAllocator>
|
||||
allocator_binder(
|
||||
allocator_binder<U, OtherAllocator>&& other,
|
||||
constraint_t<is_constructible<Allocator, OtherAllocator>::value> = 0,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: allocator_(static_cast<OtherAllocator&&>(
|
||||
other.get_allocator())),
|
||||
target_(static_cast<U&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct from a different allocator wrapper type, but
|
||||
/// specify a different allocator.
|
||||
template <typename U, typename OtherAllocator>
|
||||
allocator_binder(const allocator_type& s,
|
||||
allocator_binder<U, OtherAllocator>&& other,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: allocator_(s),
|
||||
target_(static_cast<U&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
~allocator_binder()
|
||||
{
|
||||
}
|
||||
|
||||
/// Obtain a reference to the target object.
|
||||
target_type& get() noexcept
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
/// Obtain a reference to the target object.
|
||||
const target_type& get() const noexcept
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
/// Obtain the associated allocator.
|
||||
allocator_type get_allocator() const noexcept
|
||||
{
|
||||
return allocator_;
|
||||
}
|
||||
|
||||
/// Forwarding function call operator.
|
||||
template <typename... Args>
|
||||
result_of_t<T(Args...)> operator()(Args&&... args)
|
||||
{
|
||||
return target_(static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
/// Forwarding function call operator.
|
||||
template <typename... Args>
|
||||
result_of_t<T(Args...)> operator()(Args&&... args) const
|
||||
{
|
||||
return target_(static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
Allocator allocator_;
|
||||
T target_;
|
||||
};
|
||||
|
||||
/// A function object type that adapts a @ref completion_token to specify that
|
||||
/// the completion handler should have the supplied allocator as its associated
|
||||
/// allocator.
|
||||
/**
|
||||
* May also be used directly as a completion token, in which case it adapts the
|
||||
* asynchronous operation's default completion token (or asio::deferred
|
||||
* if no default is available).
|
||||
*/
|
||||
template <typename Allocator>
|
||||
struct partial_allocator_binder
|
||||
{
|
||||
/// Constructor that specifies associated allocator.
|
||||
explicit partial_allocator_binder(const Allocator& ex)
|
||||
: allocator_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Adapt a @ref completion_token to specify that the completion handler
|
||||
/// should have the allocator as its associated allocator.
|
||||
template <typename CompletionToken>
|
||||
ASIO_NODISCARD inline
|
||||
constexpr allocator_binder<decay_t<CompletionToken>, Allocator>
|
||||
operator()(CompletionToken&& completion_token) const
|
||||
{
|
||||
return allocator_binder<decay_t<CompletionToken>, Allocator>(
|
||||
allocator_, static_cast<CompletionToken&&>(completion_token));
|
||||
}
|
||||
|
||||
//private:
|
||||
Allocator allocator_;
|
||||
};
|
||||
|
||||
/// Create a partial completion token that associates an allocator.
|
||||
template <typename Allocator>
|
||||
ASIO_NODISCARD inline partial_allocator_binder<Allocator>
|
||||
bind_allocator(const Allocator& ex)
|
||||
{
|
||||
return partial_allocator_binder<Allocator>(ex);
|
||||
}
|
||||
|
||||
/// Associate an object of type @c T with an allocator of type
|
||||
/// @c Allocator.
|
||||
template <typename Allocator, typename T>
|
||||
ASIO_NODISCARD inline allocator_binder<decay_t<T>, Allocator>
|
||||
bind_allocator(const Allocator& s, T&& t)
|
||||
{
|
||||
return allocator_binder<decay_t<T>, Allocator>(s, static_cast<T&&>(t));
|
||||
}
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename TargetAsyncResult, typename Allocator, typename = void>
|
||||
class allocator_binder_completion_handler_async_result
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
explicit allocator_binder_completion_handler_async_result(T&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult, typename Allocator>
|
||||
class allocator_binder_completion_handler_async_result<
|
||||
TargetAsyncResult, Allocator,
|
||||
void_t<typename TargetAsyncResult::completion_handler_type>>
|
||||
{
|
||||
private:
|
||||
TargetAsyncResult target_;
|
||||
|
||||
public:
|
||||
typedef allocator_binder<
|
||||
typename TargetAsyncResult::completion_handler_type, Allocator>
|
||||
completion_handler_type;
|
||||
|
||||
explicit allocator_binder_completion_handler_async_result(
|
||||
typename TargetAsyncResult::completion_handler_type& handler)
|
||||
: target_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
auto get() -> decltype(target_.get())
|
||||
{
|
||||
return target_.get();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult, typename = void>
|
||||
struct allocator_binder_async_result_return_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult>
|
||||
struct allocator_binder_async_result_return_type<
|
||||
TargetAsyncResult, void_type<typename TargetAsyncResult::return_type>>
|
||||
{
|
||||
typedef typename TargetAsyncResult::return_type return_type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T, typename Allocator, typename Signature>
|
||||
class async_result<allocator_binder<T, Allocator>, Signature> :
|
||||
public detail::allocator_binder_completion_handler_async_result<
|
||||
async_result<T, Signature>, Allocator>,
|
||||
public detail::allocator_binder_async_result_return_type<
|
||||
async_result<T, Signature>>
|
||||
{
|
||||
public:
|
||||
explicit async_result(allocator_binder<T, Allocator>& b)
|
||||
: detail::allocator_binder_completion_handler_async_result<
|
||||
async_result<T, Signature>, Allocator>(b.get())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper : detail::initiation_base<Initiation>
|
||||
{
|
||||
using detail::initiation_base<Initiation>::initiation_base;
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(Handler&& handler, const Allocator& a, Args&&... args) &&
|
||||
{
|
||||
static_cast<Initiation&&>(*this)(
|
||||
allocator_binder<decay_t<Handler>, Allocator>(
|
||||
a, static_cast<Handler&&>(handler)),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(Handler&& handler,
|
||||
const Allocator& a, Args&&... args) const &
|
||||
{
|
||||
static_cast<const Initiation&>(*this)(
|
||||
allocator_binder<decay_t<Handler>, Allocator>(
|
||||
a, static_cast<Handler&&>(handler)),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static auto initiate(Initiation&& initiation,
|
||||
RawCompletionToken&& token, Args&&... args)
|
||||
-> decltype(
|
||||
async_initiate<
|
||||
conditional_t<
|
||||
is_const<remove_reference_t<RawCompletionToken>>::value, const T, T>,
|
||||
Signature>(
|
||||
declval<init_wrapper<decay_t<Initiation>>>(),
|
||||
token.get(), token.get_allocator(), static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_initiate<
|
||||
conditional_t<
|
||||
is_const<remove_reference_t<RawCompletionToken>>::value, const T, T>,
|
||||
Signature>(
|
||||
init_wrapper<decay_t<Initiation>>(
|
||||
static_cast<Initiation&&>(initiation)),
|
||||
token.get(), token.get_allocator(), static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
async_result(const async_result&) = delete;
|
||||
async_result& operator=(const async_result&) = delete;
|
||||
|
||||
async_result<T, Signature> target_;
|
||||
};
|
||||
|
||||
template <typename Allocator, typename... Signatures>
|
||||
struct async_result<partial_allocator_binder<Allocator>, Signatures...>
|
||||
{
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static auto initiate(Initiation&& initiation,
|
||||
RawCompletionToken&& token, Args&&... args)
|
||||
-> decltype(
|
||||
async_initiate<Signatures...>(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
allocator_binder<
|
||||
default_completion_token_t<associated_executor_t<Initiation>>,
|
||||
Allocator>(token.allocator_,
|
||||
default_completion_token_t<associated_executor_t<Initiation>>{}),
|
||||
static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_initiate<Signatures...>(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
allocator_binder<
|
||||
default_completion_token_t<associated_executor_t<Initiation>>,
|
||||
Allocator>(token.allocator_,
|
||||
default_completion_token_t<associated_executor_t<Initiation>>{}),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename T, typename Allocator, typename DefaultCandidate>
|
||||
struct associator<Associator, allocator_binder<T, Allocator>, DefaultCandidate>
|
||||
: Associator<T, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<T, DefaultCandidate>::type get(
|
||||
const allocator_binder<T, Allocator>& b) noexcept
|
||||
{
|
||||
return Associator<T, DefaultCandidate>::get(b.get());
|
||||
}
|
||||
|
||||
static auto get(const allocator_binder<T, Allocator>& b,
|
||||
const DefaultCandidate& c) noexcept
|
||||
-> decltype(Associator<T, DefaultCandidate>::get(b.get(), c))
|
||||
{
|
||||
return Associator<T, DefaultCandidate>::get(b.get(), c);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Allocator, typename Allocator1>
|
||||
struct associated_allocator<allocator_binder<T, Allocator>, Allocator1>
|
||||
{
|
||||
typedef Allocator type;
|
||||
|
||||
static auto get(const allocator_binder<T, Allocator>& b,
|
||||
const Allocator1& = Allocator1()) noexcept
|
||||
-> decltype(b.get_allocator())
|
||||
{
|
||||
return b.get_allocator();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BIND_ALLOCATOR_HPP
|
||||
613
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/bind_cancellation_slot.hpp
vendored
Normal file
613
third_party/socket.io-client-cpp/lib/asio/asio/include/asio/bind_cancellation_slot.hpp
vendored
Normal file
@@ -0,0 +1,613 @@
|
||||
//
|
||||
// bind_cancellation_slot.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef ASIO_BIND_CANCELLATION_SLOT_HPP
|
||||
#define ASIO_BIND_CANCELLATION_SLOT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include "asio/detail/config.hpp"
|
||||
#include "asio/associated_cancellation_slot.hpp"
|
||||
#include "asio/associated_executor.hpp"
|
||||
#include "asio/associator.hpp"
|
||||
#include "asio/async_result.hpp"
|
||||
#include "asio/detail/initiation_base.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Helper to automatically define nested typedef result_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct cancellation_slot_binder_result_type
|
||||
{
|
||||
protected:
|
||||
typedef void result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct cancellation_slot_binder_result_type<T, void_t<typename T::result_type>>
|
||||
{
|
||||
typedef typename T::result_type result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct cancellation_slot_binder_result_type<R(*)()>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R>
|
||||
struct cancellation_slot_binder_result_type<R(&)()>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct cancellation_slot_binder_result_type<R(*)(A1)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct cancellation_slot_binder_result_type<R(&)(A1)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct cancellation_slot_binder_result_type<R(*)(A1, A2)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct cancellation_slot_binder_result_type<R(&)(A1, A2)>
|
||||
{
|
||||
typedef R result_type;
|
||||
protected:
|
||||
typedef result_type result_type_or_void;
|
||||
};
|
||||
|
||||
// Helper to automatically define nested typedef argument_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct cancellation_slot_binder_argument_type {};
|
||||
|
||||
template <typename T>
|
||||
struct cancellation_slot_binder_argument_type<T,
|
||||
void_t<typename T::argument_type>>
|
||||
{
|
||||
typedef typename T::argument_type argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct cancellation_slot_binder_argument_type<R(*)(A1)>
|
||||
{
|
||||
typedef A1 argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct cancellation_slot_binder_argument_type<R(&)(A1)>
|
||||
{
|
||||
typedef A1 argument_type;
|
||||
};
|
||||
|
||||
// Helper to automatically define nested typedefs first_argument_type and
|
||||
// second_argument_type.
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct cancellation_slot_binder_argument_types {};
|
||||
|
||||
template <typename T>
|
||||
struct cancellation_slot_binder_argument_types<T,
|
||||
void_t<typename T::first_argument_type>>
|
||||
{
|
||||
typedef typename T::first_argument_type first_argument_type;
|
||||
typedef typename T::second_argument_type second_argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct cancellation_slot_binder_argument_type<R(*)(A1, A2)>
|
||||
{
|
||||
typedef A1 first_argument_type;
|
||||
typedef A2 second_argument_type;
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
struct cancellation_slot_binder_argument_type<R(&)(A1, A2)>
|
||||
{
|
||||
typedef A1 first_argument_type;
|
||||
typedef A2 second_argument_type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// A call wrapper type to bind a cancellation slot of type @c CancellationSlot
|
||||
/// to an object of type @c T.
|
||||
template <typename T, typename CancellationSlot>
|
||||
class cancellation_slot_binder
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
: public detail::cancellation_slot_binder_result_type<T>,
|
||||
public detail::cancellation_slot_binder_argument_type<T>,
|
||||
public detail::cancellation_slot_binder_argument_types<T>
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
{
|
||||
public:
|
||||
/// The type of the target object.
|
||||
typedef T target_type;
|
||||
|
||||
/// The type of the associated cancellation slot.
|
||||
typedef CancellationSlot cancellation_slot_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The return type if a function.
|
||||
/**
|
||||
* The type of @c result_type is based on the type @c T of the wrapper's
|
||||
* target object:
|
||||
*
|
||||
* @li if @c T is a pointer to function type, @c result_type is a synonym for
|
||||
* the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c result_type, then @c
|
||||
* result_type is a synonym for @c T::result_type;
|
||||
*
|
||||
* @li otherwise @c result_type is not defined.
|
||||
*/
|
||||
typedef see_below result_type;
|
||||
|
||||
/// The type of the function's argument.
|
||||
/**
|
||||
* The type of @c argument_type is based on the type @c T of the wrapper's
|
||||
* target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting a single argument,
|
||||
* @c argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c argument_type, then @c
|
||||
* argument_type is a synonym for @c T::argument_type;
|
||||
*
|
||||
* @li otherwise @c argument_type is not defined.
|
||||
*/
|
||||
typedef see_below argument_type;
|
||||
|
||||
/// The type of the function's first argument.
|
||||
/**
|
||||
* The type of @c first_argument_type is based on the type @c T of the
|
||||
* wrapper's target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting two arguments, @c
|
||||
* first_argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c first_argument_type,
|
||||
* then @c first_argument_type is a synonym for @c T::first_argument_type;
|
||||
*
|
||||
* @li otherwise @c first_argument_type is not defined.
|
||||
*/
|
||||
typedef see_below first_argument_type;
|
||||
|
||||
/// The type of the function's second argument.
|
||||
/**
|
||||
* The type of @c second_argument_type is based on the type @c T of the
|
||||
* wrapper's target object:
|
||||
*
|
||||
* @li if @c T is a pointer to a function type accepting two arguments, @c
|
||||
* second_argument_type is a synonym for the return type of @c T;
|
||||
*
|
||||
* @li if @c T is a class type with a member type @c first_argument_type,
|
||||
* then @c second_argument_type is a synonym for @c T::second_argument_type;
|
||||
*
|
||||
* @li otherwise @c second_argument_type is not defined.
|
||||
*/
|
||||
typedef see_below second_argument_type;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Construct a cancellation slot wrapper for the specified object.
|
||||
/**
|
||||
* This constructor is only valid if the type @c T is constructible from type
|
||||
* @c U.
|
||||
*/
|
||||
template <typename U>
|
||||
cancellation_slot_binder(const cancellation_slot_type& s, U&& u)
|
||||
: slot_(s),
|
||||
target_(static_cast<U&&>(u))
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor.
|
||||
cancellation_slot_binder(const cancellation_slot_binder& other)
|
||||
: slot_(other.get_cancellation_slot()),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy, but specify a different cancellation slot.
|
||||
cancellation_slot_binder(const cancellation_slot_type& s,
|
||||
const cancellation_slot_binder& other)
|
||||
: slot_(s),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy of a different cancellation slot wrapper type.
|
||||
/**
|
||||
* This constructor is only valid if the @c CancellationSlot type is
|
||||
* constructible from type @c OtherCancellationSlot, and the type @c T is
|
||||
* constructible from type @c U.
|
||||
*/
|
||||
template <typename U, typename OtherCancellationSlot>
|
||||
cancellation_slot_binder(
|
||||
const cancellation_slot_binder<U, OtherCancellationSlot>& other,
|
||||
constraint_t<is_constructible<CancellationSlot,
|
||||
OtherCancellationSlot>::value> = 0,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: slot_(other.get_cancellation_slot()),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a copy of a different cancellation slot wrapper type, but
|
||||
/// specify a different cancellation slot.
|
||||
/**
|
||||
* This constructor is only valid if the type @c T is constructible from type
|
||||
* @c U.
|
||||
*/
|
||||
template <typename U, typename OtherCancellationSlot>
|
||||
cancellation_slot_binder(const cancellation_slot_type& s,
|
||||
const cancellation_slot_binder<U, OtherCancellationSlot>& other,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: slot_(s),
|
||||
target_(other.get())
|
||||
{
|
||||
}
|
||||
|
||||
/// Move constructor.
|
||||
cancellation_slot_binder(cancellation_slot_binder&& other)
|
||||
: slot_(static_cast<cancellation_slot_type&&>(
|
||||
other.get_cancellation_slot())),
|
||||
target_(static_cast<T&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct the target object, but specify a different cancellation
|
||||
/// slot.
|
||||
cancellation_slot_binder(const cancellation_slot_type& s,
|
||||
cancellation_slot_binder&& other)
|
||||
: slot_(s),
|
||||
target_(static_cast<T&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct from a different cancellation slot wrapper type.
|
||||
template <typename U, typename OtherCancellationSlot>
|
||||
cancellation_slot_binder(
|
||||
cancellation_slot_binder<U, OtherCancellationSlot>&& other,
|
||||
constraint_t<is_constructible<CancellationSlot,
|
||||
OtherCancellationSlot>::value> = 0,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: slot_(static_cast<OtherCancellationSlot&&>(
|
||||
other.get_cancellation_slot())),
|
||||
target_(static_cast<U&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move construct from a different cancellation slot wrapper type, but
|
||||
/// specify a different cancellation slot.
|
||||
template <typename U, typename OtherCancellationSlot>
|
||||
cancellation_slot_binder(const cancellation_slot_type& s,
|
||||
cancellation_slot_binder<U, OtherCancellationSlot>&& other,
|
||||
constraint_t<is_constructible<T, U>::value> = 0)
|
||||
: slot_(s),
|
||||
target_(static_cast<U&&>(other.get()))
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
~cancellation_slot_binder()
|
||||
{
|
||||
}
|
||||
|
||||
/// Obtain a reference to the target object.
|
||||
target_type& get() noexcept
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
/// Obtain a reference to the target object.
|
||||
const target_type& get() const noexcept
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
/// Obtain the associated cancellation slot.
|
||||
cancellation_slot_type get_cancellation_slot() const noexcept
|
||||
{
|
||||
return slot_;
|
||||
}
|
||||
|
||||
/// Forwarding function call operator.
|
||||
template <typename... Args>
|
||||
result_of_t<T(Args...)> operator()(Args&&... args)
|
||||
{
|
||||
return target_(static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
/// Forwarding function call operator.
|
||||
template <typename... Args>
|
||||
result_of_t<T(Args...)> operator()(Args&&... args) const
|
||||
{
|
||||
return target_(static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
CancellationSlot slot_;
|
||||
T target_;
|
||||
};
|
||||
|
||||
/// A function object type that adapts a @ref completion_token to specify that
|
||||
/// the completion handler should have the supplied cancellation slot as its
|
||||
/// associated cancellation slot.
|
||||
/**
|
||||
* May also be used directly as a completion token, in which case it adapts the
|
||||
* asynchronous operation's default completion token (or asio::deferred
|
||||
* if no default is available).
|
||||
*/
|
||||
template <typename CancellationSlot>
|
||||
struct partial_cancellation_slot_binder
|
||||
{
|
||||
/// Constructor that specifies associated cancellation slot.
|
||||
explicit partial_cancellation_slot_binder(const CancellationSlot& ex)
|
||||
: cancellation_slot_(ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// Adapt a @ref completion_token to specify that the completion handler
|
||||
/// should have the cancellation slot as its associated cancellation slot.
|
||||
template <typename CompletionToken>
|
||||
ASIO_NODISCARD inline
|
||||
constexpr cancellation_slot_binder<decay_t<CompletionToken>, CancellationSlot>
|
||||
operator()(CompletionToken&& completion_token) const
|
||||
{
|
||||
return cancellation_slot_binder<decay_t<CompletionToken>, CancellationSlot>(
|
||||
static_cast<CompletionToken&&>(completion_token), cancellation_slot_);
|
||||
}
|
||||
|
||||
//private:
|
||||
CancellationSlot cancellation_slot_;
|
||||
};
|
||||
|
||||
/// Create a partial completion token that associates a cancellation slot.
|
||||
template <typename CancellationSlot>
|
||||
ASIO_NODISCARD inline partial_cancellation_slot_binder<CancellationSlot>
|
||||
bind_cancellation_slot(const CancellationSlot& ex)
|
||||
{
|
||||
return partial_cancellation_slot_binder<CancellationSlot>(ex);
|
||||
}
|
||||
|
||||
/// Associate an object of type @c T with a cancellation slot of type
|
||||
/// @c CancellationSlot.
|
||||
template <typename CancellationSlot, typename T>
|
||||
ASIO_NODISCARD inline
|
||||
cancellation_slot_binder<decay_t<T>, CancellationSlot>
|
||||
bind_cancellation_slot(const CancellationSlot& s, T&& t)
|
||||
{
|
||||
return cancellation_slot_binder<decay_t<T>, CancellationSlot>(
|
||||
s, static_cast<T&&>(t));
|
||||
}
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename TargetAsyncResult,
|
||||
typename CancellationSlot, typename = void>
|
||||
class cancellation_slot_binder_completion_handler_async_result
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
explicit cancellation_slot_binder_completion_handler_async_result(T&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult, typename CancellationSlot>
|
||||
class cancellation_slot_binder_completion_handler_async_result<
|
||||
TargetAsyncResult, CancellationSlot,
|
||||
void_t<typename TargetAsyncResult::completion_handler_type>>
|
||||
{
|
||||
private:
|
||||
TargetAsyncResult target_;
|
||||
|
||||
public:
|
||||
typedef cancellation_slot_binder<
|
||||
typename TargetAsyncResult::completion_handler_type, CancellationSlot>
|
||||
completion_handler_type;
|
||||
|
||||
explicit cancellation_slot_binder_completion_handler_async_result(
|
||||
typename TargetAsyncResult::completion_handler_type& handler)
|
||||
: target_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
auto get() -> decltype(target_.get())
|
||||
{
|
||||
return target_.get();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult, typename = void>
|
||||
struct cancellation_slot_binder_async_result_return_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename TargetAsyncResult>
|
||||
struct cancellation_slot_binder_async_result_return_type<
|
||||
TargetAsyncResult, void_t<typename TargetAsyncResult::return_type>>
|
||||
{
|
||||
typedef typename TargetAsyncResult::return_type return_type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T, typename CancellationSlot, typename Signature>
|
||||
class async_result<cancellation_slot_binder<T, CancellationSlot>, Signature> :
|
||||
public detail::cancellation_slot_binder_completion_handler_async_result<
|
||||
async_result<T, Signature>, CancellationSlot>,
|
||||
public detail::cancellation_slot_binder_async_result_return_type<
|
||||
async_result<T, Signature>>
|
||||
{
|
||||
public:
|
||||
explicit async_result(cancellation_slot_binder<T, CancellationSlot>& b)
|
||||
: detail::cancellation_slot_binder_completion_handler_async_result<
|
||||
async_result<T, Signature>, CancellationSlot>(b.get())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Initiation>
|
||||
struct init_wrapper : detail::initiation_base<Initiation>
|
||||
{
|
||||
using detail::initiation_base<Initiation>::initiation_base;
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(Handler&& handler,
|
||||
const CancellationSlot& slot, Args&&... args) &&
|
||||
{
|
||||
static_cast<Initiation&&>(*this)(
|
||||
cancellation_slot_binder<decay_t<Handler>, CancellationSlot>(
|
||||
slot, static_cast<Handler&&>(handler)),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename Handler, typename... Args>
|
||||
void operator()(Handler&& handler,
|
||||
const CancellationSlot& slot, Args&&... args) const &
|
||||
{
|
||||
static_cast<const Initiation&>(*this)(
|
||||
cancellation_slot_binder<decay_t<Handler>, CancellationSlot>(
|
||||
slot, static_cast<Handler&&>(handler)),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static auto initiate(Initiation&& initiation,
|
||||
RawCompletionToken&& token, Args&&... args)
|
||||
-> decltype(
|
||||
async_initiate<
|
||||
conditional_t<
|
||||
is_const<remove_reference_t<RawCompletionToken>>::value, const T, T>,
|
||||
Signature>(
|
||||
declval<init_wrapper<decay_t<Initiation>>>(),
|
||||
token.get(), token.get_cancellation_slot(),
|
||||
static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_initiate<
|
||||
conditional_t<
|
||||
is_const<remove_reference_t<RawCompletionToken>>::value, const T, T>,
|
||||
Signature>(
|
||||
init_wrapper<decay_t<Initiation>>(
|
||||
static_cast<Initiation&&>(initiation)),
|
||||
token.get(), token.get_cancellation_slot(),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
async_result(const async_result&) = delete;
|
||||
async_result& operator=(const async_result&) = delete;
|
||||
|
||||
async_result<T, Signature> target_;
|
||||
};
|
||||
|
||||
template <typename CancellationSlot, typename... Signatures>
|
||||
struct async_result<partial_cancellation_slot_binder<CancellationSlot>,
|
||||
Signatures...>
|
||||
{
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static auto initiate(Initiation&& initiation,
|
||||
RawCompletionToken&& token, Args&&... args)
|
||||
-> decltype(
|
||||
async_initiate<Signatures...>(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
cancellation_slot_binder<
|
||||
default_completion_token_t<associated_executor_t<Initiation>>,
|
||||
CancellationSlot>(token.cancellation_slot_,
|
||||
default_completion_token_t<associated_executor_t<Initiation>>{}),
|
||||
static_cast<Args&&>(args)...))
|
||||
{
|
||||
return async_initiate<Signatures...>(
|
||||
static_cast<Initiation&&>(initiation),
|
||||
cancellation_slot_binder<
|
||||
default_completion_token_t<associated_executor_t<Initiation>>,
|
||||
CancellationSlot>(token.cancellation_slot_,
|
||||
default_completion_token_t<associated_executor_t<Initiation>>{}),
|
||||
static_cast<Args&&>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename> class Associator,
|
||||
typename T, typename CancellationSlot, typename DefaultCandidate>
|
||||
struct associator<Associator,
|
||||
cancellation_slot_binder<T, CancellationSlot>,
|
||||
DefaultCandidate>
|
||||
: Associator<T, DefaultCandidate>
|
||||
{
|
||||
static typename Associator<T, DefaultCandidate>::type get(
|
||||
const cancellation_slot_binder<T, CancellationSlot>& b) noexcept
|
||||
{
|
||||
return Associator<T, DefaultCandidate>::get(b.get());
|
||||
}
|
||||
|
||||
static auto get(const cancellation_slot_binder<T, CancellationSlot>& b,
|
||||
const DefaultCandidate& c) noexcept
|
||||
-> decltype(Associator<T, DefaultCandidate>::get(b.get(), c))
|
||||
{
|
||||
return Associator<T, DefaultCandidate>::get(b.get(), c);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename CancellationSlot, typename CancellationSlot1>
|
||||
struct associated_cancellation_slot<
|
||||
cancellation_slot_binder<T, CancellationSlot>,
|
||||
CancellationSlot1>
|
||||
{
|
||||
typedef CancellationSlot type;
|
||||
|
||||
static auto get(const cancellation_slot_binder<T, CancellationSlot>& b,
|
||||
const CancellationSlot1& = CancellationSlot1()) noexcept
|
||||
-> decltype(b.get_cancellation_slot())
|
||||
{
|
||||
return b.get_cancellation_slot();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BIND_CANCELLATION_SLOT_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user