Menu

#73 Issue: String building

1.0
accepted
SGrottel
None
2014-04-04
2014-04-04
SGrottel
No

In the vislib we often used this pattern:

some_function(str.AllocateBuffer(size), size);

In the vislib.legacy project I currently replaced that code using a const_cast which is not nice at all!

str = string(size, ' ');
some_function(const_cast<char*>(str.c_str()), size);

It works most of the time, but creates situations with the issue of ticket [#72].

I am currently not sure how to resolve this issue nicely. I am thinking, maybe we could do something with a new shallow_string_buffer class, to at least hide the const_cast. Or maybe we could do something with the string_builder.

Related

Tickets: #72

Discussion

  • SGrottel

    SGrottel - 2014-04-04

    Implemented the::text::string_buffer and function the::text::string_buffer_allocate solve this issue (for most cases).

    Currently not tested on Linux.

    I will do that on Monday, and if it works I will close this ticket.

     
  • SGrottel

    SGrottel - 2014-04-04
    • status: open --> accepted
    • assigned_to: SGrottel
     

Log in to post a comment.

MongoDB Logo MongoDB