Skip to content

Commit e26027a

Browse files
committed
rename enum
1 parent 8a40df3 commit e26027a

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

include/boost/http_proto/serializer.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,22 @@ class serializer
534534
bool
535535
is_done() const noexcept;
536536

537+
/** Return true if headers have been set.
538+
539+
Returns `true` if @ref set_headers has been
540+
called and no @ref start or @ref start_stream
541+
function has been called since. This indicates
542+
that the serializer is ready to begin
543+
serialization with a body style.
544+
545+
@see
546+
@ref set_headers,
547+
@ref is_done.
548+
*/
549+
BOOST_HTTP_PROTO_DECL
550+
bool
551+
is_headers_set() const noexcept;
552+
537553
/** Set the message headers for serialization.
538554
539555
This function prepares the serializer with the
@@ -817,10 +833,6 @@ class serializer
817833
detail::workspace&
818834
ws();
819835

820-
BOOST_HTTP_PROTO_DECL
821-
void
822-
start_empty_impl();
823-
824836
BOOST_HTTP_PROTO_DECL
825837
void
826838
start_buffers_impl(
@@ -831,10 +843,6 @@ class serializer
831843
start_source_impl(
832844
source&);
833845

834-
BOOST_HTTP_PROTO_DECL
835-
stream
836-
start_stream_impl();
837-
838846
impl* impl_ = nullptr;
839847
};
840848

src/serializer.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class serializer::impl
282282
enum class state
283283
{
284284
reset,
285-
start,
285+
initialized,
286286
headers_set,
287287
header,
288288
body
@@ -309,7 +309,7 @@ class serializer::impl
309309
detail::array_of_const_buffers prepped_;
310310
buffers::const_buffer tmp_;
311311

312-
state state_ = state::start;
312+
state state_ = state::initialized;
313313
style style_ = style::empty;
314314
uint8_t chunk_header_len_ = 0;
315315
bool more_input_ = false;
@@ -333,7 +333,7 @@ class serializer::impl
333333
reset() noexcept
334334
{
335335
ws_.clear();
336-
state_ = state::start;
336+
state_ = state::initialized;
337337
}
338338

339339
auto
@@ -639,11 +639,11 @@ class serializer::impl
639639
message_base const& m)
640640
{
641641
// Precondition violation
642-
if(state_ != state::start)
642+
if(state_ != state::initialized)
643643
detail::throw_logic_error();
644644

645645
// TODO: To uphold the strong exception guarantee,
646-
// `state_` must be reset to `state::start` if an
646+
// `state_` must be reset to `state::initialized` if an
647647
// exception is thrown during the start operation.
648648
state_ = state::headers_set;
649649

@@ -880,7 +880,13 @@ class serializer::impl
880880
bool
881881
is_done() const noexcept
882882
{
883-
return state_ == state::start;
883+
return state_ == state::initialized;
884+
}
885+
886+
bool
887+
is_headers_set() const noexcept
888+
{
889+
return state_ == state::headers_set;
884890
}
885891

886892
detail::workspace&
@@ -1093,22 +1099,22 @@ is_done() const noexcept
10931099
return impl_->is_done();
10941100
}
10951101

1096-
//------------------------------------------------
1097-
1098-
detail::workspace&
1102+
bool
10991103
serializer::
1100-
ws()
1104+
is_headers_set() const noexcept
11011105
{
11021106
BOOST_ASSERT(impl_);
1103-
return impl_->ws();
1107+
return impl_->is_headers_set();
11041108
}
11051109

1106-
void
1110+
//------------------------------------------------
1111+
1112+
detail::workspace&
11071113
serializer::
1108-
start_empty_impl()
1114+
ws()
11091115
{
11101116
BOOST_ASSERT(impl_);
1111-
impl_->start_empty_impl();
1117+
return impl_->ws();
11121118
}
11131119

11141120
void
@@ -1129,14 +1135,6 @@ start_source_impl(
11291135
impl_->start_source_impl(source);
11301136
}
11311137

1132-
auto
1133-
serializer::
1134-
start_stream_impl() -> stream
1135-
{
1136-
BOOST_ASSERT(impl_);
1137-
return impl_->start_stream_impl();
1138-
}
1139-
11401138
//------------------------------------------------
11411139

11421140
std::size_t

0 commit comments

Comments
 (0)