--- a/src/lib/GenericASN1ContentHandler.h Thu Jul 22 20:01:03 2021 +0200
+++ b/src/lib/GenericASN1ContentHandler.h Wed Jul 28 01:40:05 2021 +0200
@@ -39,6 +39,8 @@
XMLContentHandlerProxy handlers;
std::string rootName = "asn1";
+ std::string bitStringSymbol0 = "0";
+ std::string bitStringSymbol1 = "1";
bool treeWithNamespaces = false;
/**
@@ -98,6 +100,8 @@
else if (uri == xml::TreeWithNamespaces) treeWithNamespaces = parseBoolean(value);
else if (uri == xml::TreeStyle && value == "standard"); // the only style currently supported
else if (uri == xml::TreeStyle && value == "literal") throw std::invalid_argument("Tree style 'literal' is not yet supported"); // will require ASN.1 schema, might be implemented in another class
+ else if (uri == xml::BitStringSymbol0) bitStringSymbol0 = value;
+ else if (uri == xml::BitStringSymbol1) bitStringSymbol1 = value;
else if (uri == xml::TreeStyle) throw std::invalid_argument("Unsupported tree-style: " + value);
else return false;
@@ -165,8 +169,7 @@
void writeBitString(const Header& header, std::vector<bool> 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);
handlers.writeStartElement("bit-string", getCommonAttributes(header,{"length", std::to_string(value.size())}));
handlers.writeCharacters(bits.str());
handlers.writeEndElement();