Skip to content

string_type in binary_reader #941

@kaidokert

Description

@kaidokert

Feature Request

  • Describe the feature in as much detail as possible.
    Currently binary_reader requires using std::string, which is cumbersome when trying to work with custom non-standard string classes. In my specific usecase, embedded system and cbor parsing.

  • Include sample usage where appropriate.
    The rest of the header currently compiles with a custom string type stand-in with a very minimal standard interface part:

struct awfully_poor_str {
    static const size_t npos = static_cast<size_t>(-1);
    using value_type = char;
    void push_back(char);
    awfully_poor_str();
    awfully_poor_str(const char *);
};

Changing binary_reader to

using string_t = typename BasicJsonType::string_t;

makes it compile as well. Or is there a definite reason why it should use std::string there ?

BTW, on a cortex-m0 compile with custom vector and string types, exceptions/rtti off, and std::streams stubbed out i get about 3kB for the library code size right now. Intel's C tinycbor is about 2.5kB, and a smaller custom c++ cbor-only limited-features parser is <1kB

binary_stringtype.diff.txt

Metadata

Metadata

Assignees

Labels

solution: proposed fixa fix for the issue has been proposed and waits for confirmation

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions