Skip to content

Commit

Permalink
Migrate NTS to fine-grained NTSCFG_TYPE_TRAIT_*
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrm456 authored Oct 9, 2024
1 parent 28e4264 commit cfd4b1c
Show file tree
Hide file tree
Showing 54 changed files with 500 additions and 268 deletions.
6 changes: 2 additions & 4 deletions groups/ntc/ntccfg/ntccfg_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ BSLS_IDENT("$Id: $")
/// Declare the specified 'TYPE' is bitwise-movable.
/// @ingroup module_ntccfg
#define NTCCFG_DECLARE_NESTED_BITWISE_MOVABLE_TRAITS(TYPE) \
BSLALG_DECLARE_NESTED_TRAITS4( \
BSLALG_DECLARE_NESTED_TRAITS2( \
TYPE, \
bslalg::TypeTraitBitwiseMoveable, \
bslalg::TypeTraitBitwiseCopyable, \
bslalg::TypeTraitBitwiseEqualityComparable, \
bslalg::TypeTraitHasTrivialDefaultConstructor)
bslalg::TypeTraitBitwiseCopyable)

/// Declare the specified 'TYPE' uses an allocator to supply memory.
/// @ingroup module_ntccfg
Expand Down
83 changes: 39 additions & 44 deletions groups/nts/ntsa/ntsa_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,9 @@ class AbstractSyntaxEncoderOptions
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractSyntaxEncoderOptions);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractSyntaxEncoderOptions);
};

/// Write the specified 'object' to the specified 'stream'. Return
Expand Down Expand Up @@ -879,10 +878,9 @@ class AbstractSyntaxDecoderOptions
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractSyntaxDecoderOptions);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractSyntaxDecoderOptions);
};

/// Write the specified 'object' to the specified 'stream'. Return
Expand Down Expand Up @@ -1045,10 +1043,15 @@ class AbstractSyntaxDecoderFrame
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_BITWISE_MOVABLE_TRAITS(AbstractSyntaxDecoderFrame);
/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(AbstractSyntaxDecoderFrame);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(AbstractSyntaxDecoderFrame);
};

/// Write the specified 'object' to the specified 'stream'. Return
Expand Down Expand Up @@ -1615,10 +1618,9 @@ class AbstractObjectIdentifier
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractObjectIdentifier);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractObjectIdentifier);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -1774,10 +1776,9 @@ class AbstractValue
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractValue);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractValue);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -1930,10 +1931,9 @@ class AbstractString
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractString);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractString);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -2090,10 +2090,9 @@ class AbstractByteSequence
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractByteSequence);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractByteSequence);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -2270,10 +2269,9 @@ class AbstractBitSequence
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractBitSequence);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractBitSequence);
};

/// Define a type alias for the representation of an abstract octet sequence.
Expand Down Expand Up @@ -2652,10 +2650,9 @@ class AbstractIntegerRepresentation
AbstractIntegerSign::Value sign,
AbstractIntegerBase::Value base);

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractIntegerRepresentation);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractIntegerRepresentation);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -3302,10 +3299,9 @@ class AbstractIntegerQuantity
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractIntegerQuantity);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractIntegerQuantity);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down Expand Up @@ -4037,10 +4033,9 @@ class AbstractInteger
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(AbstractInteger);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(AbstractInteger);
};

/// Format the specified 'object' to the specified output 'stream' and
Expand Down
4 changes: 4 additions & 0 deletions groups/nts/ntsa/ntsa_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class Adapter
/// Return the flag that indicates this adapter can be a multicast
/// recipient.
bool multicast() const;

/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(Adapter);
};

} // close package namespace
Expand Down
92 changes: 62 additions & 30 deletions groups/nts/ntsa/ntsa_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,19 @@ class MutableBuffer
bsl::size_t bufferCount,
bsl::size_t offset);

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(MutableBuffer,
bslalg::TypeTraitBitwiseCopyable);
/// This type's default constructor is equivalent to setting each byte of
/// the object's footprint to zero.
NTSCFG_TYPE_TRAIT_BITWISE_INITIALIZABLE(MutableBuffer);

/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(MutableBuffer);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(MutableBuffer);
};

/// Return true if the specified 'lhs' has the same value as the specified
Expand Down Expand Up @@ -292,11 +300,19 @@ class ConstBuffer
bsl::size_t bufferCount,
bsl::size_t offset);

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(ConstBuffer,
bslalg::TypeTraitBitwiseCopyable);
/// This type's default constructor is equivalent to setting each byte of
/// the object's footprint to zero.
NTSCFG_TYPE_TRAIT_BITWISE_INITIALIZABLE(ConstBuffer);

/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(ConstBuffer);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(ConstBuffer);
};

/// Return true if the specified 'lhs' has the same value as the specified
Expand Down Expand Up @@ -424,11 +440,9 @@ class ConstBufferArray
const bdlbb::Blob& data,
bsl::size_t maxBytes);

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(ConstBufferArray,
bslalg::TypeTraitUsesBslmaAllocator);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(ConstBufferArray);
};

/// Provide a held pointer to an array of contiguous pointers to potentially
Expand Down Expand Up @@ -506,11 +520,19 @@ class ConstBufferPtrArray
/// array.
bsl::size_t numBytes() const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(ConstBufferPtrArray,
bslalg::TypeTraitBitwiseCopyable);
/// This type's default constructor is equivalent to setting each byte of
/// the object's footprint to zero.
NTSCFG_TYPE_TRAIT_BITWISE_INITIALIZABLE(ConstBufferPtrArray);

/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(ConstBufferPtrArray);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(ConstBufferPtrArray);
};

/// Provide an array of contiguous pointers to potentially discontiguous,
Expand Down Expand Up @@ -626,11 +648,9 @@ class MutableBufferArray
bdlbb::Blob* data,
bsl::size_t maxBytes);

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(MutableBufferArray,
bslalg::TypeTraitUsesBslmaAllocator);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(MutableBufferArray);
};

/// Provide a held pointer to an array of contiguous pointers to potentially
Expand Down Expand Up @@ -709,11 +729,19 @@ class MutableBufferPtrArray
/// array.
bsl::size_t numBytes() const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(MutableBufferPtrArray,
bslalg::TypeTraitBitwiseCopyable);
/// This type's default constructor is equivalent to setting each byte of
/// the object's footprint to zero.
NTSCFG_TYPE_TRAIT_BITWISE_INITIALIZABLE(MutableBufferPtrArray);

/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(MutableBufferPtrArray);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(MutableBufferPtrArray);
};

/// Provide a sequence of non-modifiable buffers.
Expand Down Expand Up @@ -1219,6 +1247,10 @@ class StreamBuffer : public bsl::streambuf

/// Return the number of writable bytes.
bsl::size_t capacity() const;

/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(StreamBuffer);
};

NTSCFG_INLINE
Expand Down
7 changes: 3 additions & 4 deletions groups/nts/ntsa/ntsa_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,9 @@ class Data
/// Return the allocator used by this data container.
bslma::Allocator* allocator() const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_USES_ALLOCATOR_TRAITS(Data);
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(Data);
};

/// Provide utilities for data containers.
Expand Down
20 changes: 6 additions & 14 deletions groups/nts/ntsa/ntsa_distinguishedname.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,9 @@ class DistinguishedName
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(DistinguishedName,
bslalg::TypeTraitUsesBslmaAllocator);

// FRIEND OPERATORS
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(DistinguishedName);

/// Format the specified 'rhs' to the specified output 'stream' and
/// return a reference to the modifiable 'stream'.
Expand Down Expand Up @@ -347,13 +343,9 @@ class DistinguishedName::Component
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
BSLALG_DECLARE_NESTED_TRAITS(Component,
bslalg::TypeTraitUsesBslmaAllocator);

// FRIEND OPERATORS
/// This type accepts an allocator argument to its constructors and may
/// dynamically allocate memory during its operation.
NTSCFG_TYPE_TRAIT_ALLOCATOR_AWARE(Component);

/// Format the specified 'rhs' to the specified output 'stream' and
/// return a reference to the modifiable 'stream'.
Expand Down
13 changes: 9 additions & 4 deletions groups/nts/ntsa/ntsa_domainname.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,15 @@ class DomainName
int level = 0,
int spacesPerLevel = 4) const;

/// Defines the traits of this type. These traits can be used to select,
/// at compile-time, the most efficient algorithm to manipulate objects
/// of this type.
NTSCFG_DECLARE_NESTED_BITWISE_MOVABLE_TRAITS(DomainName);
/// This type's copy-constructor and copy-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_COPYABLE(DomainName);

/// This type's move-constructor and move-assignment operator is equivalent
/// to copying each byte of the source object's footprint to each
/// corresponding byte of the destination object's footprint.
NTSCFG_TYPE_TRAIT_BITWISE_MOVABLE(DomainName);
};

/// Write the specified 'object' to the specified 'stream'. Return a
Expand Down
Loading

0 comments on commit cfd4b1c

Please sign in to comment.