vector<char> is mapped to BIN #100

Merged
merged 1 commit into from Aug 10, 2014

Conversation

Projects
None yet
1 participant
Contributor

redboltz commented Aug 4, 2014

Added the new mapping:
std::vector is mapped to BIN.

So, currently BIN, STR, and ARRAY mappings are as follows:
std::vector is mapped to BIN
std::string is mapped to STR
std::vector is mapped to ARRAY // T is not char

This is a PR for poc/0.6. It is a breaking change so I'd like to have a discussion. The new msgpack format supports BIN and STR. BIN is binary. STR is UTF-8 string. https://github.com/msgpack/msgpack/blob/master/spec.md

C++ doesn't have UTF-8 string type. When users pack std::string, there are two design choice. Those are BIN or STR. I've chosen STR. This is not a part of this PR. That have already committed.

How about BIN? I believe that std::vector is suitable type to map to BIN. So I created the PR. Someone might consider that std::vectorstd::uint8_t is good. However, I don't think so. C++ uses char as binary byte data like as ostream::write:
http://www.cplusplus.com/reference/ostream/ostream/write/?kw=write

There is another design choice. That is, no direct type mapping to BIN. Users always call the following functions when they want to map tp BIN:

    o.pack_bin(v.size());
    o.pack_bin_body(v.data(), v.size());

I think that it is convenient providing some direct mapped type to BIN, and that is std::vector.

Any ideas?

If there is no strong against opinion, I will merge the PR.

Added the new mapping:
  std::vector<char> is mapped to BIN.

So, currently BIN, STR, and ARRAY mappings are as follows:
  std::vector<char> is mapped to BIN
  std::string       is mapped to STR
  std::vector<T>    is mapped to ARRAY // T is not char

redboltz added a commit that referenced this pull request Aug 10, 2014

@redboltz redboltz merged commit 9a1ccaf into msgpack:poc/0.6 Aug 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment