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>
34 #ifdef BOOST_HAS_ABI_HEADERS
35 # include BOOST_ABI_PREFIX
38 struct empty_padding{};
92 padding_size = padding3<sizeof(padding)>::padding_size,
93 padding_mask = padding3<sizeof(padding)>::padding_mask
98 // basically this is a simplified vector<unsigned char>
99 // this is used by basic_regex for expression storage
102 class BOOST_REGEX_DECL raw_storage
105 typedef std::size_t size_type;
106 typedef unsigned char* pointer;
108 pointer last, start, end;
112 raw_storage(size_type n);
116 ::operator delete(start);
119 void BOOST_REGEX_CALL resize(size_type n);
121 void* BOOST_REGEX_CALL extend(size_type n)
123 if(size_type(last - end) < n)
124 resize(n + (end - start));
125 register pointer result = end;
130 void* BOOST_REGEX_CALL insert(size_type pos, size_type n);
132 size_type BOOST_REGEX_CALL size()
137 size_type BOOST_REGEX_CALL capacity()
142 void* BOOST_REGEX_CALL data()const
147 size_type BOOST_REGEX_CALL index(void* ptr)
149 return static_cast<pointer>(ptr) - static_cast<pointer>(data());
152 void BOOST_REGEX_CALL clear()
157 void BOOST_REGEX_CALL align()
159 // move end up to a boundary:
160 end = start + (((end - start) + padding_mask) & ~padding_mask);
162 void swap(raw_storage& that)
164 std::swap(start, that.start);
165 std::swap(end, that.end);
166 std::swap(last, that.last);
170 inline raw_storage::raw_storage()
172 last = start = end = 0;
175 inline raw_storage::raw_storage(size_type n)
177 start = end = static_cast<pointer>(::operator new(n));
178 BOOST_REGEX_NOEH_ASSERT(start)
183 #ifdef BOOST_HAS_ABI_HEADERS
184 # include BOOST_ABI_SUFFIX
187 } // namespace re_detail