Skip to content

Commit

Permalink
Add concepts to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jan 8, 2025
1 parent 2b94ca5 commit f8c811f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/crypt.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ include::crypt/hash_drbg.adoc[]
include::crypt/hmac_drbg.adoc[]
////
include::crypt/concepts.adoc[]

include::crypt/config.adoc[]

include::crypt/reference.adoc[]
Expand Down
4 changes: 4 additions & 0 deletions doc/crypt/api_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ https://www.boost.org/LICENSE_1_0.txt

- None

== Concepts

- <<file_system_path, `file_system_path`>>

== Macros

See: <<configuration>>
51 changes: 51 additions & 0 deletions doc/crypt/concepts.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
////
Copyright 2025 Matt Borland
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////

[#Concepts]
= Concepts
:idprefix: concepts_

The following are the defintions of the concepts used throughout the library to ensure consistency.

[#file_system_path]
== File System Path

Used for the one-shot hashing of files.
Allows a diverse range of ways to specify the file path.
This concept is disabled on CUDA because there is no `std::ifstream` on that platform.

[source, c++]
----
namespace boost::crypt::concepts {
#ifndef BOOST_CRYPT_HAS_CUDA
template <typename T>
concept file_system_path = std::is_convertible_v<T, std::string> ||
std::is_convertible_v<T, std::string_view> ||
std::is_same_v<std::remove_cvref<T>, std::filesystem::path>;
#endif
} // namespace boost::crypt::concepts
----

[#writable_output_range]
== Writeable Output Range

This concept is used to define the ranges that we can write to such as the `get_digest(Range&& data)` function of the hashers.

[source, c++]
----
namespace boost::crypt::concepts {
template <typename Range>
concept writable_output_range = compat::output_range<Range, compat::range_value_t<Range>> &&
compat::sized_range<Range> &&
compat::is_trivially_copyable_v<compat::range_value_t<Range>>;
} // namespace boost::crypt::concepts
----

0 comments on commit f8c811f

Please sign in to comment.