8#ifndef INCLUDED_BALBER_BERENCODER
9#define INCLUDED_BALBER_BERENCODER
200#include <balscm_version.h>
226#include <bsl_ostream.h>
227#include <bsl_string.h>
228#include <bsl_vector.h>
229#include <bsl_typeinfo.h>
235struct BerEncoder_encodeProxy;
236class BerEncoder_Visitor;
237class BerEncoder_UniversalElementVisitor;
238class BerEncoder_LevelGuard;
264 class MemOutStream :
public bsl::ostream {
270 MemOutStream(
const MemOutStream&);
271 MemOutStream& operator=(
const MemOutStream&);
298 const
char *
data() const;
311#ifndef BDE_OMIT_INTERNAL_DEPRECATED
327 MemOutStream *d_logStream;
331 bsl::streambuf *d_streamBuf;
345 const char *name = 0,
351 const char *name = 0,
356 bsl::ostream& logStream();
364 template <
typename TYPE>
365 int encodeArrayImpl(
const TYPE& value,
370 template <
typename TYPE>
371 int encodeImpl(
const TYPE& value,
377 template <
typename TYPE>
378 int encodeImpl(
const TYPE& value,
384 template <
typename TYPE>
385 int encodeImpl(
const TYPE& value,
391 template <
typename TYPE>
392 int encodeImpl(
const TYPE& value,
398 template <
typename TYPE>
399 int encodeImpl(
const TYPE& value,
405 template <
typename TYPE>
406 int encodeImpl(
const TYPE& value,
412 template <
typename TYPE>
413 int encodeImpl(
const TYPE& value,
419 template <
typename TYPE>
420 int encodeImpl(
const TYPE& value,
443 template <
typename TYPE>
444 int encode(bsl::streambuf *streamBuf,
const TYPE& value);
449 template <
typename TYPE>
450 int encode(bsl::ostream& stream,
const TYPE& value);
515 template <
typename TYPE,
typename INFO>
516 int operator()(
const TYPE& value,
const INFO& info);
533 int d_formattingMode;
552 template <
typename TYPE>
553 int operator()(
const TYPE& value);
578 template <
typename TYPE>
579 int operator()(
const TYPE&
object,
bslmf::Nil);
581 template <
typename TYPE,
typename ANY_CATEGORY>
582 int operator()(
const TYPE&
object, ANY_CATEGORY category);
584 template <
typename TYPE>
585 int operator()(
const TYPE&
object);
599balber::BerEncoder::MemOutStream::MemOutStream(
602, d_sb(
bslma::Default::allocator(basicAllocator))
624 return static_cast<int>(d_sb.length());
634BerEncoder_LevelGuard::BerEncoder_LevelGuard(
BerEncoder *encoder)
637 ++d_encoder->d_currentDepth;
643 --d_encoder->d_currentDepth;
650template <
typename TYPE>
658template <
typename TYPE,
typename ANY_CATEGORY>
661 ANY_CATEGORY category)
670template <
typename TYPE>
677 return this->
operator()(
object, TypeCategory());
708bsl::ostream& BerEncoder::logStream()
710 if (d_logStream == 0) {
711 d_logStream =
new(d_logArea.
buffer()) MemOutStream(d_allocator);
716template <
typename TYPE>
721 d_streamBuf = streamBuf;
724 if (d_logStream != 0) {
725 d_logStream->reset();
751 streamBuf->pubsync();
756template <
typename TYPE>
759 if (!stream.good()) {
763 if (0 != this->
encode(stream.rdbuf(), value)) {
764 stream.setstate(bsl::ios_base::failbit);
771template <
typename TYPE>
772int BerEncoder::encodeImpl(
const TYPE& value,
778 enum { k_SUCCESS = 0, k_FAILURE = -1 };
790 const bool isUntagged = formattingMode
820 this->logError(tagClass,
841template <
typename TYPE>
842int BerEncoder::encodeImpl(
const TYPE& value,
848 enum { k_SUCCESS = 0, k_FAILURE = -1 };
896template <
typename TYPE>
897int BerEncoder::encodeImpl(
const TYPE& value,
919template <
typename TYPE>
920int BerEncoder::encodeImpl(
const TYPE& value,
939template <
typename TYPE>
940int BerEncoder::encodeImpl(
const TYPE& value,
963template <
typename TYPE>
964int BerEncoder::encodeImpl(
const TYPE& value,
979template <
typename TYPE>
981int BerEncoder::encodeImpl(
const TYPE& value,
987 enum { k_SUCCESS = 0, k_FAILURE = -1 };
993 return this->encodeArrayImpl(value,
999template <
typename TYPE>
1001BerEncoder::encodeArrayImpl(
const TYPE& value,
1006 enum { k_FAILURE = -1, k_SUCCESS = 0 };
1027 for (
int i = 0; i <
size; ++i) {
1030 this->logError(tagClass,
1042template <
typename TYPE>
1044int BerEncoder::encodeImpl(
const TYPE& value,
1067, d_levelGuard(encoder)
1077template <
typename TYPE,
typename INFO>
1084 int rc = d_encoder->encodeImpl(value,
1087 info.formattingMode(),
1105BerEncoder_UniversalElementVisitor::
1106BerEncoder_UniversalElementVisitor(
BerEncoder *encoder,
1109, d_formattingMode(formattingMode)
1110, d_levelGuard(encoder)
1121template <
typename TYPE>
1124 enum { k_SUCCESS = 0, k_FAILURE = -1 };
1134 if (d_encoder->encodeImpl(value,
1136 static_cast<int>(tagNumber),
Definition balber_berencoderoptions.h:73
bool disableUnselectedChoiceEncoding() const
Definition balber_berencoderoptions.h:752
bool encodeEmptyArrays() const
Definition balber_berencoderoptions.h:734
Definition balber_berencoder.h:476
~BerEncoder_LevelGuard()
Definition balber_berencoder.h:641
Definition balber_berencoder.h:529
~BerEncoder_UniversalElementVisitor()
Definition balber_berencoder.h:1116
int operator()(const TYPE &value)
Definition balber_berencoder.h:1122
Definition balber_berencoder.h:499
~BerEncoder_Visitor()
Definition balber_berencoder.h:1072
int operator()(const TYPE &value, const INFO &info)
Definition balber_berencoder.h:1079
Definition balber_berencoder.h:248
int encode(bsl::streambuf *streamBuf, const TYPE &value)
Definition balber_berencoder.h:717
friend struct BerEncoder_encodeProxy
Definition balber_berencoder.h:252
ErrorSeverity errorSeverity() const
Definition balber_berencoder.h:692
ErrorSeverity
Definition balber_berencoder.h:307
@ e_BER_ERROR
Definition balber_berencoder.h:309
@ e_BER_SUCCESS
Definition balber_berencoder.h:308
@ BDEM_BER_SUCCESS
Definition balber_berencoder.h:312
@ BDEM_BER_ERROR
Definition balber_berencoder.h:313
friend class BerEncoder_Visitor
Definition balber_berencoder.h:253
const BerEncoderOptions * options() const
Return address of the options.
Definition balber_berencoder.h:686
friend class BerEncoder_LevelGuard
Definition balber_berencoder.h:255
friend class BerEncoder_UniversalElementVisitor
Definition balber_berencoder.h:254
bslstl::StringRef loggedMessages() const
Definition balber_berencoder.h:698
BerEncoder(const BerEncoderOptions *options=0, bslma::Allocator *basicAllocator=0)
Definition bdlsb_memoutstreambuf.h:212
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition bslstl_stringref.h:372
const char * data() const
Definition balber_berencoder.h:616
void reset()
Reset the internal streambuf to empty.
Definition balber_berencoder.h:609
int length() const
Definition balber_berencoder.h:622
static int accessByCategory(const TYPE &object, ACCESSOR &accessor)
Definition bdlat_typecategory.h:1444
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition balber_berconstants.h:82
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
int accessElement(const TYPE &array, ACCESSOR &accessor, int index)
int accessSelection(const TYPE &object, ACCESSOR &accessor)
@ k_UNDEFINED_SELECTION_ID
Definition bdlat_choicefunctions.h:511
int selectionId(const TYPE &object)
const BaseType< TYPE >::Type & convertToBaseType(const TYPE &object)
void toInt(int *result, const TYPE &value)
bool isNull(const TYPE &object)
int accessValue(const TYPE &object, ACCESSOR &accessor)
int accessAttributes(const TYPE &object, ACCESSOR &accessor)
Definition bdlb_printmethods.h:283
Definition balxml_encoderoptions.h:68
StringRefImp< char > StringRef
Definition bslstl_stringref.h:699
TagType
Definition balber_berconstants.h:113
@ e_PRIMITIVE
Definition balber_berconstants.h:116
@ e_CONSTRUCTED
Definition balber_berconstants.h:117
TagClass
Definition balber_berconstants.h:92
@ e_CONTEXT_SPECIFIC
Definition balber_berconstants.h:97
@ e_UNIVERSAL
Definition balber_berconstants.h:95
Definition balber_berencoder.h:566
BerEncoder * d_encoder
Definition balber_berencoder.h:569
BerConstants::TagClass d_tagClass
Definition balber_berencoder.h:570
int operator()(const TYPE &object, bslmf::Nil)
Definition balber_berencoder.h:652
int d_formattingMode
Definition balber_berencoder.h:572
int d_tagNumber
Definition balber_berencoder.h:571
Value
Definition balber_beruniversaltagnumber.h:194
static Value select(const TYPE &object, int formattingMode, int *alternateTag)
Definition balber_beruniversaltagnumber.h:595
static int putEndOfContentOctets(bsl::streambuf *streamBuf)
Definition balber_berutil.h:3951
static int putIndefiniteLengthOctet(bsl::streambuf *streamBuf)
Definition balber_berutil.h:3957
static int putValue(bsl::streambuf *streamBuf, const TYPE &value, const BerEncoderOptions *options=0)
Definition balber_berutil.h:3970
static int putIdentifierOctets(bsl::streambuf *streamBuf, BerConstants::TagClass tagClass, BerConstants::TagType tagType, int tagNumber)
TYPE::BaseType Type
Definition bdlat_customizedtypefunctions.h:536
Definition bdlat_typecategory.h:1035
Definition bdlat_typecategory.h:1036
Definition bdlat_typecategory.h:1037
Definition bdlat_typecategory.h:1034
Definition bdlat_typecategory.h:1038
Definition bdlat_typecategory.h:1039
Definition bdlat_typecategory.h:1040
Definition bdlat_typecategory.h:1041
This struct is empty and represents a nil type.
Definition bslmf_nil.h:131
Definition bsls_objectbuffer.h:276
char * buffer()
Definition bsls_objectbuffer.h:344