Skip to content

Commit 2e85be8

Browse files
docs: Add Javadoc documentation to all public symbols (#25)
* docs: Add Javadoc documentation to all public symbols Added comprehensive Boost-style Javadoc documentation comments to all public symbols in the include/boost/capy directory, including: - datastore.hpp: class and member documentation - polystore_fwd.hpp: forward declaration comment - brotli.hpp: file-level documentation - brotli/encode.hpp: enums, constants, service interface, and functions - brotli/decode.hpp: enums, result codes, service interface, and functions - brotli/shared_dictionary.hpp: enum and service documentation - zlib.hpp: file-level documentation - zlib/stream.hpp: structure and member documentation - zlib/deflate.hpp: service interface and all member functions - zlib/inflate.hpp: service interface and all member functions - zlib/flush.hpp: enum values with descriptions - zlib/compression_level.hpp: compression level constants - zlib/compression_method.hpp: compression method constants - zlib/compression_strategy.hpp: strategy constants with explanations - zlib/data_type.hpp: data type constants All documentation follows Boost C++ Libraries Javadoc conventions with: - Brief descriptions starting with appropriate verb forms - @param tags for function parameters - @return tags for return values - Proper formatting and structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Vinnie Falco <vinniefalco@users.noreply.github.com> * docs: Enhance documentation with detailed descriptions and examples Added comprehensive descriptions explaining what each component does and how to use it. Included practical code examples demonstrating: - Brotli compression/decompression (one-shot and streaming) - ZLib deflate/inflate operations with different formats - Compression levels, strategies, and flush modes - Stream state management and datastore usage All examples follow Boost-style Javadoc conventions with @code blocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Vinnie Falco <vinniefalco@users.noreply.github.com> --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Vinnie Falco <vinniefalco@users.noreply.github.com>
1 parent 6597d11 commit 2e85be8

15 files changed

Lines changed: 922 additions & 33 deletions

include/boost/capy/brotli.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@
77
// Official repository: https://github.com/cppalliance/capy
88
//
99

10+
/** @file
11+
Brotli compression and decompression library.
12+
13+
This header includes all Brotli-related functionality including
14+
encoding, decoding, error handling, and shared dictionary support.
15+
16+
Brotli is a generic-purpose lossless compression algorithm that compresses
17+
data using a combination of a modern variant of the LZ77 algorithm, Huffman
18+
coding and 2nd order context modeling, with a compression ratio comparable
19+
to the best currently available general-purpose compression methods.
20+
21+
@code
22+
#include <boost/capy/brotli.hpp>
23+
#include <boost/capy/datastore.hpp>
24+
25+
// Create a datastore for services
26+
boost::capy::datastore ctx;
27+
28+
// Install compression and decompression services
29+
auto& encoder = boost::capy::brotli::install_encode_service(ctx);
30+
auto& decoder = boost::capy::brotli::install_decode_service(ctx);
31+
@endcode
32+
*/
33+
1034
#ifndef BOOST_CAPY_BROTLI_HPP
1135
#define BOOST_CAPY_BROTLI_HPP
1236

include/boost/capy/brotli/decode.hpp

Lines changed: 132 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,36 @@ namespace brotli {
2222
/** Opaque structure that holds decoder state. */
2323
struct decoder_state;
2424

25-
/** Result type for decompress and decompress_stream functions. */
25+
/** Decoder result codes.
26+
27+
These values indicate the result of decompression operations.
28+
*/
2629
enum class decoder_result
2730
{
31+
/** Decompression error occurred. */
2832
error = 0,
33+
34+
/** Decompression completed successfully. */
2935
success = 1,
36+
37+
/** More input data is needed. */
3038
needs_more_input = 2,
39+
40+
/** More output space is needed. */
3141
needs_more_output = 3
3242
};
3343

34-
/** Options to be used with set_parameter. */
44+
/** Decoder parameter identifiers.
45+
46+
These values identify parameters that can be set
47+
on a decoder instance.
48+
*/
3549
enum class decoder_param
3650
{
51+
/** Disable automatic ring buffer reallocation. */
3752
disable_ring_buffer_reallocation = 0,
53+
54+
/** Enable large window mode. */
3855
large_window = 1
3956
};
4057

@@ -44,32 +61,112 @@ using metadata_start_func = void (*)(void* opaque, std::size_t size);
4461
/** Callback to fire on metadata block chunk becomes available. */
4562
using metadata_chunk_func = void (*)(void* opaque, const std::uint8_t* data, std::size_t size);
4663

47-
/** Provides the Brotli decompression API */
64+
/** Provides the Brotli decompression API.
65+
66+
This service interface exposes Brotli decoder functionality
67+
through a set of virtual functions. The decoder can operate
68+
in one-shot mode for simple decompression or streaming mode
69+
for processing data in chunks.
70+
71+
@code
72+
// Example: Simple one-shot decompression
73+
boost::capy::datastore ctx;
74+
auto& decoder = boost::capy::brotli::install_decode_service(ctx);
75+
76+
std::vector<std::uint8_t> compressed_data = get_compressed_data();
77+
std::vector<std::uint8_t> output(1024 * 1024); // 1MB buffer
78+
std::size_t decoded_size = output.size();
79+
80+
auto result = decoder.decompress(
81+
compressed_data.size(),
82+
compressed_data.data(),
83+
&decoded_size,
84+
output.data());
85+
86+
if (result == boost::capy::brotli::decoder_result::success)
87+
{
88+
output.resize(decoded_size);
89+
// Use decompressed data
90+
}
91+
@endcode
92+
93+
@code
94+
// Example: Streaming decompression
95+
auto* state = decoder.create_instance(nullptr, nullptr, nullptr);
96+
97+
std::size_t available_in = compressed_data.size();
98+
const std::uint8_t* next_in = compressed_data.data();
99+
std::size_t available_out = output.size();
100+
std::uint8_t* next_out = output.data();
101+
std::size_t total_out = 0;
102+
103+
auto result = decoder.decompress_stream(
104+
state,
105+
&available_in,
106+
&next_in,
107+
&available_out,
108+
&next_out,
109+
&total_out);
110+
111+
decoder.destroy_instance(state);
112+
@endcode
113+
*/
48114
struct BOOST_SYMBOL_VISIBLE
49115
decode_service
50116
{
117+
/** Set a decoder parameter.
118+
@param state The decoder state.
119+
@param param The parameter identifier.
120+
@param value The parameter value.
121+
@return True on success, false on error.
122+
*/
51123
virtual bool
52124
set_parameter(
53125
decoder_state* state,
54126
decoder_param param,
55127
std::uint32_t value) const noexcept = 0;
56128

129+
/** Create a new decoder instance.
130+
@param alloc_func Allocation function.
131+
@param free_func Deallocation function.
132+
@param opaque Opaque pointer passed to allocation functions.
133+
@return Pointer to decoder state, or nullptr on error.
134+
*/
57135
virtual decoder_state*
58136
create_instance(
59137
alloc_func alloc_func,
60138
free_func free_func,
61139
void* opaque) const noexcept = 0;
62140

141+
/** Destroy a decoder instance.
142+
@param state The decoder state to destroy.
143+
*/
63144
virtual void
64145
destroy_instance(decoder_state* state) const noexcept = 0;
65146

147+
/** Decompress data in one call.
148+
@param encoded_size Input data size.
149+
@param encoded_buffer Input data buffer.
150+
@param decoded_size Pointer to variable receiving output size.
151+
@param decoded_buffer Output buffer.
152+
@return Result code indicating success or failure.
153+
*/
66154
virtual decoder_result
67155
decompress(
68156
std::size_t encoded_size,
69157
const std::uint8_t encoded_buffer[],
70158
std::size_t* decoded_size,
71159
std::uint8_t decoded_buffer[]) const noexcept = 0;
72160

161+
/** Decompress data in streaming mode.
162+
@param state The decoder state.
163+
@param available_in Pointer to input bytes available.
164+
@param next_in Pointer to pointer to input data.
165+
@param available_out Pointer to output space available.
166+
@param next_out Pointer to pointer to output buffer.
167+
@param total_out Pointer to variable receiving total bytes written.
168+
@return Result code indicating decoder state.
169+
*/
73170
virtual decoder_result
74171
decompress_stream(
75172
decoder_state* state,
@@ -79,24 +176,52 @@ struct BOOST_SYMBOL_VISIBLE
79176
std::uint8_t** next_out,
80177
std::size_t* total_out) const noexcept = 0;
81178

179+
/** Check if more output is available.
180+
@param state The decoder state.
181+
@return True if output is available, false otherwise.
182+
*/
82183
virtual bool
83184
has_more_output(const decoder_state* state) const noexcept = 0;
84185

186+
/** Return buffered output data.
187+
@param state The decoder state.
188+
@param size Pointer to variable receiving output size.
189+
@return Pointer to output buffer.
190+
*/
85191
virtual const std::uint8_t*
86192
take_output(decoder_state* state, std::size_t* size) const noexcept = 0;
87193

194+
/** Check if decoder has been used.
195+
@param state The decoder state.
196+
@return True if decoder has processed data, false otherwise.
197+
*/
88198
virtual bool
89199
is_used(const decoder_state* state) const noexcept = 0;
90200

201+
/** Check if decompression is finished.
202+
@param state The decoder state.
203+
@return True if decompression is complete, false otherwise.
204+
*/
91205
virtual bool
92206
is_finished(const decoder_state* state) const noexcept = 0;
93207

208+
/** Return the error code from the decoder.
209+
@param state The decoder state.
210+
@return The error code.
211+
*/
94212
virtual error
95213
get_error_code(const decoder_state* state) const noexcept = 0;
96214

215+
/** Return a string description of an error code.
216+
@param c The error code.
217+
@return Pointer to error description string.
218+
*/
97219
virtual const char*
98220
error_string(error c) const noexcept = 0;
99221

222+
/** Return the Brotli library version.
223+
@return Version number.
224+
*/
100225
virtual std::uint32_t
101226
version() const noexcept = 0;
102227

@@ -117,6 +242,10 @@ struct BOOST_SYMBOL_VISIBLE
117242
#endif
118243
};
119244

245+
/** Install the decode service into a polystore.
246+
@param ctx The polystore to install the service into.
247+
@return A reference to the installed decode service.
248+
*/
120249
BOOST_CAPY_DECL
121250
decode_service&
122251
install_decode_service(polystore& ctx);

0 commit comments

Comments
 (0)