3 * Copyright (c) 1998-2002
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE regex_raw_buffer.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Raw character buffer for regex code.
17 * Note this is an internal header file included
18 * by regex.hpp, do not include on its own.
21 #ifndef BOOST_REGEX_RAW_BUFFER_HPP
22 #define BOOST_REGEX_RAW_BUFFER_HPP
24 #ifndef BOOST_REGEX_CONFIG_HPP
25 #include <boost/regex/config.hpp>
36 #pragma warning(disable: 4103)
38 #ifdef BOOST_HAS_ABI_HEADERS
39 # include BOOST_ABI_PREFIX
45 struct empty_padding{};
99 padding_size = padding3<sizeof(padding)>::padding_size,
100 padding_mask = padding3<sizeof(padding)>::padding_mask
105 // basically this is a simplified vector<unsigned char>
106 // this is used by basic_regex for expression storage
109 class BOOST_REGEX_DECL raw_storage
112 typedef std::size_t size_type;
113 typedef unsigned char* pointer;
115 pointer last, start, end;
119 raw_storage(size_type n);
123 ::operator delete(start);
126 void BOOST_REGEX_CALL resize(size_type n);
128 void* BOOST_REGEX_CALL extend(size_type n)
130 if(size_type(last - end) < n)
131 resize(n + (end - start));
132 register pointer result = end;
137 void* BOOST_REGEX_CALL insert(size_type pos, size_type n);
139 size_type BOOST_REGEX_CALL size()
144 size_type BOOST_REGEX_CALL capacity()
149 void* BOOST_REGEX_CALL data()const
154 size_type BOOST_REGEX_CALL index(void* ptr)
156 return static_cast<pointer>(ptr) - static_cast<pointer>(data());
159 void BOOST_REGEX_CALL clear()
164 void BOOST_REGEX_CALL align()
166 // move end up to a boundary:
167 end = start + (((end - start) + padding_mask) & ~padding_mask);
169 void swap(raw_storage& that)
171 std::swap(start, that.start);
172 std::swap(end, that.end);
173 std::swap(last, that.last);
177 inline raw_storage::raw_storage()
179 last = start = end = 0;
182 inline raw_storage::raw_storage(size_type n)
184 start = end = static_cast<pointer>(::operator new(n));
185 BOOST_REGEX_NOEH_ASSERT(start)
191 #pragma warning(push)
192 #pragma warning(disable: 4103)
194 #ifdef BOOST_HAS_ABI_HEADERS
195 # include BOOST_ABI_SUFFIX
201 } // namespace re_detail