|
||||
File indexing completed on 2025-01-18 09:29:36
0001 // 0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/beast 0008 // 0009 // This is a derivative work based on Zlib, copyright below: 0010 /* 0011 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 0012 0013 This software is provided 'as-is', without any express or implied 0014 warranty. In no event will the authors be held liable for any damages 0015 arising from the use of this software. 0016 0017 Permission is granted to anyone to use this software for any purpose, 0018 including commercial applications, and to alter it and redistribute it 0019 freely, subject to the following restrictions: 0020 0021 1. The origin of this software must not be misrepresented; you must not 0022 claim that you wrote the original software. If you use this software 0023 in a product, an acknowledgment in the product documentation would be 0024 appreciated but is not required. 0025 2. Altered source versions must be plainly marked as such, and must not be 0026 misrepresented as being the original software. 0027 3. This notice may not be removed or altered from any source distribution. 0028 0029 Jean-loup Gailly Mark Adler 0030 jloup@gzip.org madler@alumni.caltech.edu 0031 0032 The data format used by the zlib library is described by RFCs (Request for 0033 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 0034 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). 0035 */ 0036 0037 #ifndef BOOST_BEAST_ZLIB_DETAIL_RANGES_HPP 0038 #define BOOST_BEAST_ZLIB_DETAIL_RANGES_HPP 0039 0040 #include <cstdint> 0041 #include <type_traits> 0042 0043 namespace boost { 0044 namespace beast { 0045 namespace zlib { 0046 namespace detail { 0047 0048 struct ranges 0049 { 0050 template<bool isConst> 0051 struct range 0052 { 0053 using iter_t = 0054 typename std::conditional<isConst, 0055 std::uint8_t const*, 0056 std::uint8_t*>::type; 0057 0058 iter_t first; 0059 iter_t last; 0060 iter_t next; 0061 0062 // total bytes in range 0063 std::size_t 0064 size() const 0065 { 0066 return last - first; 0067 } 0068 0069 // bytes consumed 0070 std::size_t 0071 used() const 0072 { 0073 return next - first; 0074 } 0075 0076 // bytes remaining 0077 std::size_t 0078 avail() const 0079 { 0080 return last - next; 0081 } 0082 }; 0083 0084 range<true> in; 0085 range<false> out; 0086 }; 0087 0088 // Clamp u to v where u and v are different types 0089 template<class U, class V> 0090 U clamp(U u, V v) 0091 { 0092 if(u > v) 0093 u = static_cast<U>(v); 0094 return u; 0095 } 0096 0097 } // detail 0098 } // zlib 0099 } // beast 0100 } // boost 0101 0102 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |