Skip to content

Commit

Permalink
Use std_vector and std_array aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jul 2, 2024
1 parent 60f68cf commit 927bc7d
Show file tree
Hide file tree
Showing 95 changed files with 410 additions and 409 deletions.
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class BC_API block
sizes size_;
};

typedef std::vector<block> blocks;
typedef std_vector<block> blocks;

DECLARE_JSON_VALUE_CONVERTORS(block);
DECLARE_JSON_VALUE_CONVERTORS(block::cptr);
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/checkpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace chain {
class BC_API checkpoint
{
public:
typedef std::vector<checkpoint> list;
typedef std_vector<checkpoint> list;

DEFAULT_COPY_MOVE_DESTRUCT(checkpoint);

Expand Down Expand Up @@ -111,7 +111,7 @@ bool operator!=(const checkpoint& left, const checkpoint& right) NOEXCEPT;
std::istream& operator>>(std::istream& stream, checkpoint& out) THROWS;
std::ostream& operator<<(std::ostream& stream, const checkpoint& in) NOEXCEPT;

typedef std::vector<checkpoint> checkpoints;
typedef std_vector<checkpoint> checkpoints;

DECLARE_JSON_VALUE_CONVERTORS(checkpoint);

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class BC_API header
mutable std::shared_ptr<const hash_digest> hash_{};
};

typedef std::vector<header> headers;
typedef std::vector<header::cptr> header_cptrs;
typedef std_vector<header> headers;
typedef std_vector<header::cptr> header_cptrs;
typedef std::shared_ptr<header_cptrs> headers_ptr;
typedef std::shared_ptr<const header_cptrs> headers_cptr;

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class BC_API input
mutable chain::prevout metadata{ zero, max_uint32, false, false };
};

typedef std::vector<input> inputs;
typedef std::vector<input::cptr> input_cptrs;
typedef std_vector<input> inputs;
typedef std_vector<input::cptr> input_cptrs;
typedef std::shared_ptr<input_cptrs> inputs_ptr;
typedef std::shared_ptr<const input_cptrs> inputs_cptr;

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class BC_API operation
bool underflow_;
};

typedef std::vector<operation> operations;
typedef std_vector<operation> operations;

DECLARE_JSON_VALUE_CONVERTORS(operation);
DECLARE_JSON_VALUE_CONVERTORS(operation::cptr);
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class BC_API output
size_t size_;
};

typedef std::vector<output> outputs;
typedef std::vector<output::cptr> output_cptrs;
typedef std_vector<output> outputs;
typedef std_vector<output::cptr> output_cptrs;
typedef std::shared_ptr<output_cptrs> outputs_ptr;
typedef std::shared_ptr<const output_cptrs> outputs_cptr;

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BC_API point
/// Arbitrary compare, for uniqueness sorting.
bool operator<(const point& left, const point& right) NOEXCEPT;

typedef std::vector<point> points;
typedef std_vector<point> points;

DECLARE_JSON_VALUE_CONVERTORS(point);
DECLARE_JSON_VALUE_CONVERTORS(point::cptr);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class BC_API script
mutable iterator offset;
};

typedef std::vector<script> scripts;
typedef std_vector<script> scripts;

DECLARE_JSON_VALUE_CONVERTORS(script);
DECLARE_JSON_VALUE_CONVERTORS(script::cptr);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/stripper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ inline bool operator==(const operation& op, const stripper& strip) NOEXCEPT
return op.code() == strip.code() && op.data() == strip.data();
}

typedef std::vector<stripper> strippers;
typedef std_vector<stripper> strippers;

} // namespace chain
} // namespace system
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class BC_API transaction
mutable std::unique_ptr<const sighash_cache> sighash_cache_{};
};

typedef std::vector<transaction> transactions;
typedef std::vector<transaction::cptr> transaction_cptrs;
typedef std_vector<transaction> transactions;
typedef std_vector<transaction::cptr> transaction_cptrs;
typedef std::shared_ptr<transaction_cptrs> transactions_ptr;
typedef std::shared_ptr<const transaction_cptrs> transactions_cptr;

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/witness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class BC_API witness
size_t size_;
};

typedef std::vector<witness> witnesses;
typedef std_vector<witness> witnesses;

DECLARE_JSON_VALUE_CONVERTORS(witness);
DECLARE_JSON_VALUE_CONVERTORS(witness::cptr);
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/config/hash256.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace config {
class BC_API hash256 final
{
public:
typedef std::vector<hash256> list;
typedef std_vector<hash256> list;

hash256() NOEXCEPT;
hash256(hash_digest&& value) NOEXCEPT;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/config/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ namespace config {
typedef std::pair<const std::string, int> argument_pair;

/// A type to represent the list of positional argument name counts.
typedef std::vector<argument_pair> argument_list;
typedef std_vector<argument_pair> argument_list;

/// A type to represent a list of parameter structures.
class parameter;
typedef std::vector<parameter> parameter_list;
typedef std_vector<parameter> parameter_list;

/// Not thread safe, non-virtual.
/// Normalized storage for command line arguments and options.
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/config/printer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BC_API printer final
/// This always sets at least one line and always collapses whitespace.
/// paragraph The paragraph to columnize.
/// return The column, as a list of fragments.
std::vector<std::string> columnize(const std::string& paragraph,
std_vector<std::string> columnize(const std::string& paragraph,
size_t width) NOEXCEPT;

/// Format stuff.
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/config/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BC_API script final

/// Split or unsplit tokens.
script(const std::string& mnemonic) THROWS;
script(const std::vector<std::string>& tokens) THROWS;
script(const std_vector<std::string>& tokens) THROWS;

/// Default text encoding is mnemonic, so provide data for base16.
script(const data_chunk& value) NOEXCEPT;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/constraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ using if_little_endian_integral_integer = bool_if<
is_integral_integer<Integer> &&
is_little_endian>;

/// std::array/std::vector
/// std_array/std_vector

template <typename Type>
using if_std_array = bool_if<
Expand All @@ -254,7 +254,7 @@ using if_integral_array = bool_if<
template <typename Type>
using if_byte_insertable = bool_if<
std::is_base_of<std::string, Type>::value ||
std::is_base_of<std::vector<uint8_t>, Type>::value>;
std::is_base_of<std_vector<uint8_t>, Type>::value>;

} // namespace libbitcoin

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/crypto/ring_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace system {
/// valid signature, we must use a private key from each of those sets.
/// For example A and E and X. We can summarize this operation as:
/// (A or B or C) and (D or E or F) and (X or Y)
typedef std::vector<compressed_list> key_rings;
typedef std_vector<compressed_list> key_rings;

/// A borromean ring signature.
/// theta = {e_0, s_{i_j} : 0 <= i <= n, 0 <= j <= m_i}
struct BC_API ring_signature
{
typedef std::vector<secret_list> proof_list;
typedef std_vector<secret_list> proof_list;

ec_secret challenge;
proof_list proofs;
Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/system/crypto/secp256k1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ static constexpr uint8_t ec_even_sign = 2;
static constexpr size_t ec_secret_size = 32;
typedef data_array<ec_secret_size> ec_secret;

typedef std::vector<ec_secret> secret_list;
typedef std_vector<ec_secret> secret_list;

/// Compressed public key:
static constexpr size_t ec_compressed_size = 33;
typedef data_array<ec_compressed_size> ec_compressed;
typedef std::vector<ec_compressed> compressed_list;
typedef std_vector<ec_compressed> compressed_list;

/// Uncompressed public key:
static constexpr size_t ec_uncompressed_size = 65;
typedef data_array<ec_uncompressed_size> ec_uncompressed;
typedef std::vector<ec_uncompressed> uncompressed_list;
typedef std_vector<ec_uncompressed> uncompressed_list;

// Parsed ECDSA signature:
static constexpr size_t ec_signature_size = 64;
Expand All @@ -58,7 +58,7 @@ typedef data_chunk der_signature;
static constexpr size_t min_endorsement_size = 9;
static constexpr size_t max_endorsement_size = 73;
typedef data_chunk endorsement;
typedef std::vector<endorsement> endorsements;
typedef std_vector<endorsement> endorsements;

// secg.org/sec2-v2.pdf
constexpr ec_compressed ec_compressed_generator = base16_array("02"
Expand Down
12 changes: 6 additions & 6 deletions include/bitcoin/system/data/byte_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ namespace system {
template <typename Byte = uint8_t, typename Integral,
if_one_byte<Byte> = true,
if_integral_integer<Integral> = true>
inline std::array<Byte, sizeof(Integral)>&
inline std_array<Byte, sizeof(Integral)>&
byte_cast(Integral& value) NOEXCEPT;

/// Cast const integral& to const byte array& with byte length of the integral.
template <typename Byte = uint8_t, typename Integral,
if_one_byte<Byte> = true,
if_integral_integer<Integral> = true>
inline const std::array<Byte, sizeof(Integral)>&
inline const std_array<Byte, sizeof(Integral)>&
byte_cast(const Integral& value) NOEXCEPT;

/// Cast integral&& to byte array with byte length of the integral.
template <typename Byte = uint8_t, typename Integral,
if_one_byte<Byte> = true,
if_integral_integer<Integral> = true>
inline std::array<Byte, sizeof(Integral)>
inline std_array<Byte, sizeof(Integral)>
byte_cast(Integral&& value) NOEXCEPT;

/// Cast array& of Byte to same-sized Integral&.
Expand All @@ -68,21 +68,21 @@ template <typename Byte, size_t Size,
if_one_byte<Byte> = true,
if_integral_size<Size> = true>
inline unsigned_type<Size>&
byte_cast(std::array<Byte, Size>& bytes) NOEXCEPT;
byte_cast(std_array<Byte, Size>& bytes) NOEXCEPT;

/// Cast const byte array& to const unsigned integral& of same byte length.
template <typename Byte, size_t Size,
if_one_byte<Byte> = true,
if_integral_size<Size> = true>
inline const unsigned_type<Size>&
byte_cast(const std::array<Byte, Size>& bytes) NOEXCEPT;
byte_cast(const std_array<Byte, Size>& bytes) NOEXCEPT;

/// Cast byte array&& to unsigned integral of same byte length.
template <typename Byte, size_t Size,
if_one_byte<Byte> = true,
if_integral_size<Size> = true>
inline unsigned_type<Size>
byte_cast(std::array<Byte, Size>&& bytes) NOEXCEPT;
byte_cast(std_array<Byte, Size>&& bytes) NOEXCEPT;

/// Cast Byte* to Integral&.
/// ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/data/data_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace system {

/// Byte array of a specified length.
template <size_t Size>
using data_array = std::array<uint8_t, Size>;
using data_array = std_array<uint8_t, Size>;

/// Return type for splitters.
template <size_t Size>
Expand All @@ -52,7 +52,7 @@ constexpr data_array<Size> to_array(const data_slice& bytes) NOEXCEPT;
/// Create a data stack from vector of data array.
template <size_t Size>
const data_stack to_stack(
const std::vector<data_array<Size>>& values) NOEXCEPT;
const std_vector<data_array<Size>>& values) NOEXCEPT;

/// Concatenate several data slices into a single array.
/// Underfill is padded with 0x00, excess is truncated.
Expand Down
12 changes: 6 additions & 6 deletions include/bitcoin/system/data/data_chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// C++ now allows only vectors of "any non-const object type".
// stackoverflow.com/questions/6954906/does-c11-allow-vectorconst-t
// Since const std::vector<T> implies all elements are const, this is ok.
// Since const std_vector<T> implies all elements are const, this is ok.
// The following naming conventions are applied to pointers and vectors.
//
// T::ptr implies shared_ptr<T>.
Expand All @@ -54,13 +54,13 @@ namespace system {

/// Define data_chunk types.

typedef std::vector<uint8_t> data_chunk;
typedef std_vector<uint8_t> data_chunk;

typedef std::shared_ptr<data_chunk> chunk_ptr;
typedef std::shared_ptr<const data_chunk> chunk_cptr;

typedef std::vector<chunk_ptr> chunk_ptrs;
typedef std::vector<chunk_cptr> chunk_cptrs;
typedef std_vector<chunk_ptr> chunk_ptrs;
typedef std_vector<chunk_cptr> chunk_cptrs;

typedef std::shared_ptr<chunk_ptrs> chunk_ptrs_ptr;
typedef std::shared_ptr<const chunk_ptrs> chunk_ptrs_cptr;
Expand All @@ -70,14 +70,14 @@ typedef std::shared_ptr<const chunk_cptrs> chunk_cptrs_cptr;

/// Define data_stack types.

typedef std::vector<data_chunk> data_stack;
typedef std_vector<data_chunk> data_stack;
typedef std::shared_ptr<data_stack> stack_ptr;
typedef std::shared_ptr<const data_stack> stack_cptr;

// Define chunk_xptr types.

typedef external_ptr<data_chunk> chunk_xptr;
typedef std::vector<chunk_xptr> chunk_xptrs;
typedef std_vector<chunk_xptr> chunk_xptrs;

/// Create a single byte data_chunk with given element value.
BC_API data_chunk to_chunk(uint8_t byte) NOEXCEPT;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/data/data_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class data_reference

/// Byte array constructor (casts Byte to uint8_t).
template <size_type Size, typename Byte, if_one_byte<Byte> = true>
constexpr data_reference(const std::array<Byte, Size>& data) NOEXCEPT;
constexpr data_reference(const std_array<Byte, Size>& data) NOEXCEPT;

/// Byte vector constructor (casts Byte to uint8_t).
template <typename Byte, if_one_byte<Byte> = true>
VCONSTEXPR data_reference(const std::vector<Byte>& data) NOEXCEPT;
VCONSTEXPR data_reference(const std_vector<Byte>& data) NOEXCEPT;

/// Byte iterators constructor (casts to uint8_t).
template <typename Iterator>
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/system/data/data_slab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class data_slab
// TODO: test.
/// Byte vector constructor (casts Byte to uint8_t).
template <typename Byte, if_one_byte<Byte> = true>
VCONSTEXPR data_slab(std::vector<Byte>& data) NOEXCEPT;
VCONSTEXPR data_slab(std_vector<Byte>& data) NOEXCEPT;

// TODO: restrict to iterator-to-non-const references.
/// Byte iterators constructor (casts to uint8_t).
Expand All @@ -95,7 +95,7 @@ class data_slab
constexpr std_array<value_type, Size> to_array() const NOEXCEPT;

/// Copy data to a vector.
VCONSTEXPR std::vector<value_type> to_chunk() const NOEXCEPT;
VCONSTEXPR std_vector<value_type> to_chunk() const NOEXCEPT;

/// Convert data to a string (casts uint8_t to char).
SCONSTEXPR std::string to_string() const NOEXCEPT;
Expand All @@ -122,7 +122,7 @@ class data_slab
/// -----------------------------------------------------------------------
////template<size_type Size>
////constexpr operator std_array<value_type, Size>() const NOEXCEPT;
////VCONSTEXPR operator std::vector<value_type>() const NOEXCEPT;
////VCONSTEXPR operator std_vector<value_type>() const NOEXCEPT;
constexpr operator data_slice() const NOEXCEPT;
constexpr value_type operator[](size_type index) const NOEXCEPT;

Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/system/data/data_slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class data_slice

/// Byte vector constructor (casts Byte to uint8_t).
template <typename Byte, if_one_byte<Byte> = true>
VCONSTEXPR data_slice(const std::vector<Byte>& data) NOEXCEPT;
VCONSTEXPR data_slice(const std_vector<Byte>& data) NOEXCEPT;

// TODO: restrict to iterator-to-const references.
/// Byte iterators constructor (casts to uint8_t).
Expand All @@ -106,7 +106,7 @@ class data_slice
constexpr std_array<value_type, Size> to_array() const NOEXCEPT;

/// Copy data to a vector.
VCONSTEXPR std::vector<value_type> to_chunk() const NOEXCEPT;
VCONSTEXPR std_vector<value_type> to_chunk() const NOEXCEPT;

/// Convert data to a string (casts uint8_t to char).
SCONSTEXPR std::string to_string() const NOEXCEPT;
Expand All @@ -130,7 +130,7 @@ class data_slice
/// -----------------------------------------------------------------------
////template<size_type Size>
////constexpr operator std_array<value_type, Size>() const NOEXCEPT;
////VCONSTEXPR operator std::vector<value_type>() const NOEXCEPT;
////VCONSTEXPR operator std_vector<value_type>() const NOEXCEPT;
constexpr value_type operator[](size_type index) const NOEXCEPT;

private:
Expand Down
Loading

0 comments on commit 927bc7d

Please sign in to comment.