oxen-io / oxen-mq

Communications layer used for both the Oxen storage server and oxend
https://oxen.io
BSD 3-Clause "New" or "Revised" License
19 stars 35 forks source link

Make {to,from}_{hex/b64/b32} return output iterator #45

Closed jagerman closed 3 years ago

jagerman commented 3 years ago

Changes the 3-iterator versions of to_hex, from_b32z, etc. to return the final output iterator, which allows for much easier in-place "from" conversion without needing a new string by doing something like:

    std::string data = /* some hex */;
    auto end = oxenmq::from_hex(data.begin(), data.end(), data.begin();
    data.erase(end, data.end());

Returning from the "to" converters is a bit less useful but doing it anyway for consistency (and because it could still have some use, e.g. if output is into some fixed buffer it lets you determine how much was written).