C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
basic_types.h
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * ==--==
17 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
18 *
19 * Platform-dependent type definitions
20 *
21 * For the latest on this and related APIs, please see http://casablanca.codeplex.com.
22 *
23 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
24 ****/
25 
26 #pragma once
27 
28 #include <string>
29 #include <fstream>
30 #include <iostream>
31 #include <sstream>
32 #include "cpprest/details/cpprest_compat.h"
33 
34 #ifndef _WIN32
35 # define __STDC_LIMIT_MACROS
36 # include <stdint.h>
37 #else
38 #include <cstdint>
39 #endif
40 
41 #include "cpprest/details/SafeInt3.hpp"
42 
43 namespace utility
44 {
45 
46 #ifdef _WIN32
47 #define _UTF16_STRINGS
48 #endif
49 
50 // We should be using a 64-bit size type for most situations that do
51 // not involve specifying the size of a memory allocation or buffer.
52 typedef uint64_t size64_t;
53 
54 #ifndef _WIN32
55 typedef uint32_t HRESULT; // Needed for PPLX
56 #endif
57 
58 #ifdef _UTF16_STRINGS
59 //
60 // On Windows, all strings are wide
61 //
62 typedef wchar_t char_t ;
63 typedef std::wstring string_t;
64 #define _XPLATSTR(x) L ## x
65 typedef std::wostringstream ostringstream_t;
66 typedef std::wofstream ofstream_t;
67 typedef std::wostream ostream_t;
68 typedef std::wistream istream_t;
69 typedef std::wifstream ifstream_t;
70 typedef std::wistringstream istringstream_t;
71 typedef std::wstringstream stringstream_t;
72 #define ucout std::wcout
73 #define ucin std::wcin
74 #define ucerr std::wcerr
75 #else
76 //
77 // On POSIX platforms, all strings are narrow
78 //
79 typedef char char_t;
80 typedef std::string string_t;
81 #define _XPLATSTR(x) x
82 typedef std::ostringstream ostringstream_t;
83 typedef std::ofstream ofstream_t;
84 typedef std::ostream ostream_t;
85 typedef std::istream istream_t;
86 typedef std::ifstream ifstream_t;
87 typedef std::istringstream istringstream_t;
88 typedef std::stringstream stringstream_t;
89 #define ucout std::cout
90 #define ucin std::cin
91 #define ucerr std::cerr
92 #endif // endif _UTF16_STRINGS
93 
94 #ifndef _TURN_OFF_PLATFORM_STRING
95 #define U(x) _XPLATSTR(x)
96 #endif // !_TURN_OFF_PLATFORM_STRING
97 
98 }// namespace utility
99 
100 typedef char utf8char;
101 typedef std::string utf8string;
102 typedef std::stringstream utf8stringstream;
103 typedef std::ostringstream utf8ostringstream;
104 typedef std::ostream utf8ostream;
105 typedef std::istream utf8istream;
106 typedef std::istringstream utf8istringstream;
107 
108 #ifdef _UTF16_STRINGS
109 typedef wchar_t utf16char;
110 typedef std::wstring utf16string;
111 typedef std::wstringstream utf16stringstream;
112 typedef std::wostringstream utf16ostringstream;
113 typedef std::wostream utf16ostream;
114 typedef std::wistream utf16istream;
115 typedef std::wistringstream utf16istringstream;
116 #else
117 typedef char16_t utf16char;
118 typedef std::u16string utf16string;
119 typedef std::basic_stringstream<utf16char> utf16stringstream;
120 typedef std::basic_ostringstream<utf16char> utf16ostringstream;
121 typedef std::basic_ostream<utf16char> utf16ostream;
122 typedef std::basic_istream<utf16char> utf16istream;
123 typedef std::basic_istringstream<utf16char> utf16istringstream;
124 #endif
125 
126 
127 #if defined(_WIN32)
128 // Include on everything except Windows Desktop ARM, unless explicitly excluded.
129 #if !defined(CPPREST_EXCLUDE_WEBSOCKETS)
130 #if defined(WINAPI_FAMILY)
131 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && defined(_M_ARM)
132 #define CPPREST_EXCLUDE_WEBSOCKETS
133 #endif
134 #else
135 #if defined(_M_ARM)
136 #define CPPREST_EXCLUDE_WEBSOCKETS
137 #endif
138 #endif
139 #endif
140 #endif
Various utilities for string conversions and date and time manipulation.
Definition: asyncrt_utils.h:50