diff -r 3192dc8772de -r 7d309accc639 src/FreeformASN1ContentHandler.h --- a/src/FreeformASN1ContentHandler.h Tue Jul 27 18:33:27 2021 +0200 +++ b/src/FreeformASN1ContentHandler.h Wed Jul 28 18:01:09 2021 +0200 @@ -26,6 +26,11 @@ namespace in { namespace asn1 { +namespace freeformOption { +static const char* BitStringSymbol0 = "bit-string-symbol-0"; +static const char* BitStringSymbol1 = "bit-string-symbol-1"; +} + /** * Converts arbitrary ASN.1 stream of events to a relation * i.e. does not require any specific structures/schema. @@ -40,6 +45,9 @@ Configuration configuration; std::vector position; + std::string bitStringSymbol0 = "0"; + std::string bitStringSymbol1 = "1"; + class Record { public: const Header* header; @@ -105,7 +113,11 @@ } bool setOption(const std::string& uri, const std::string& value) override { - return false; + if (uri == freeformOption::BitStringSymbol0) bitStringSymbol0 = value; + else if (uri == freeformOption::BitStringSymbol1) bitStringSymbol1 = value; + else return false; + + return true; } void writeStreamStart() override { @@ -131,7 +143,7 @@ void writeStreamEnd() override { Record r(nullptr, position, L"stream-end"); write(r); - + auto id = position.back() + 1; position.pop_back(); position.back() = id; @@ -147,7 +159,7 @@ void writeCollectionEnd() override { Record r(nullptr, position, L"collection-end"); write(r); - + auto id = position.back() + 1; position.pop_back(); position.back() = id; @@ -155,8 +167,7 @@ void writeBitString(const Header& header, std::vector value) override { std::stringstream bits; - for (bool b : value) bits << (int) b; - // for (bool b : value) bits << (b ? ':' : '.'); // TODO: configurable true/false symbols? + for (bool b : value) bits << (b ? bitStringSymbol1 : bitStringSymbol0); position.back()++; Record r(&header, position, L"bit-string");