www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - Fastformat::fmt_slices

reply Claudio Albuquerque <claudio.albuquerque gmail.com> writes:
Hi Mathew,


I've been on the process of including the fastformat to the project framework
and replacing "manual" formating an other string formating code by it.

But I've encountered an issue.

I've a class that maps it self onto a string array, providing some standard
functionality  that makes sense to a wchar_t[] or char[].

Now my size() method is returning the full capacity of the array.

So in method fmt_slices, the following code:
 ...
 sink.reserve(sink.size() + cchTotal + 2);  // Ask for two more, in case need
CR (&LF)
 ...

will cause the reserve method to be called with a capacity that exceeds the
current array string and it will cause an exception, since there is no
possibility for reallocation.

So, do you any recommendation to get around this issue?

Thanks
ClŠudio Albuquerque
May 29 2012
parent reply "Matt Wilson" <matthewwilson acm.org> writes:
Hi ClŠudio

From your description, I assume that you've not overridden the fmt_slices 
action shim for your own type. That's what you need to do, otherwise, by 
default, it goes to the one that assumes conformance with the 
std::(w)string.

Have a look at any of the overloads of the shim for different sink types in 
the include/fastformat/sinks directory: all you have to do is follow suit 
for your own type.

I'll be happy to help - offline if you wish (as I assume it's proprietary 
code) - after you've had a stab at it.

Let me know

Matt

"Claudio Albuquerque" <claudio.albuquerque gmail.com> wrote in message 
news:jq40ss$pu1$1 digitalmars.com...
 Hi Mathew,


 I've been on the process of including the fastformat to the project 
 framework and replacing "manual" formating an other string formating code 
 by it.

 But I've encountered an issue.

 I've a class that maps it self onto a string array, providing some 
 standard functionality  that makes sense to a wchar_t[] or char[].

 Now my size() method is returning the full capacity of the array.

 So in method fmt_slices, the following code:
 ...
 sink.reserve(sink.size() + cchTotal + 2);  // Ask for two more, in case 
 need CR (&LF)
 ...

 will cause the reserve method to be called with a capacity that exceeds 
 the current array string and it will cause an exception, since there is no 
 possibility for reallocation.

 So, do you any recommendation to get around this issue?

 Thanks
 ClŠudio Albuquerque 

Jun 04 2012
parent reply =?ISO-8859-1?Q?Cl=e1udio?= <claudio.albuquerque gmail.com> writes:
Hi Matt,

Yes you're correct I haven't overridden the fmt_slices action shim.
I expect to have time this month to re-iterate over this issue again, I follow
your advice and lets see how it goes.

Thanks for the feedback
ClŠudio Albuquerque

 Hi ClŠudio
 
 From your description, I assume that you've not overridden the fmt_slices 
 action shim for your own type. That's what you need to do, otherwise, by 
 default, it goes to the one that assumes conformance with the 
 std::(w)string.
 
 Have a look at any of the overloads of the shim for different sink types in 
 the include/fastformat/sinks directory: all you have to do is follow suit 
 for your own type.
 
 I'll be happy to help - offline if you wish (as I assume it's proprietary 
 code) - after you've had a stab at it.
 
 Let me know
 
 Matt
 
 "Claudio Albuquerque" <claudio.albuquerque gmail.com> wrote in message 
 news:jq40ss$pu1$1 digitalmars.com...
 Hi Mathew,


 I've been on the process of including the fastformat to the project 
 framework and replacing "manual" formating an other string formating code 
 by it.

 But I've encountered an issue.

 I've a class that maps it self onto a string array, providing some 
 standard functionality  that makes sense to a wchar_t[] or char[].

 Now my size() method is returning the full capacity of the array.

 So in method fmt_slices, the following code:
 ...
 sink.reserve(sink.size() + cchTotal + 2);  // Ask for two more, in case 
 need CR (&LF)
 ...

 will cause the reserve method to be called with a capacity that exceeds 
 the current array string and it will cause an exception, since there is no 
 possibility for reallocation.

 So, do you any recommendation to get around this issue?

 Thanks
 ClŠudio Albuquerque 


Jul 10 2012
parent "Matt Wilson" <matthewwilson acm.org> writes:
Cool. Let me know how it goes.

Matt

"ClŠudio" <claudio.albuquerque gmail.com> wrote in message 
news:jtil06$1m9m$1 digitalmars.com...
 Hi Matt,

 Yes you're correct I haven't overridden the fmt_slices action shim.
 I expect to have time this month to re-iterate over this issue again, I 
 follow your advice and lets see how it goes.

 Thanks for the feedback
 ClŠudio Albuquerque

 Hi ClŠudio

 From your description, I assume that you've not overridden the fmt_slices
 action shim for your own type. That's what you need to do, otherwise, by
 default, it goes to the one that assumes conformance with the
 std::(w)string.

 Have a look at any of the overloads of the shim for different sink types 
 in
 the include/fastformat/sinks directory: all you have to do is follow suit
 for your own type.

 I'll be happy to help - offline if you wish (as I assume it's proprietary
 code) - after you've had a stab at it.

 Let me know

 Matt

 "Claudio Albuquerque" <claudio.albuquerque gmail.com> wrote in message
 news:jq40ss$pu1$1 digitalmars.com...
 Hi Mathew,


 I've been on the process of including the fastformat to the project
 framework and replacing "manual" formating an other string formating 
 code
 by it.

 But I've encountered an issue.

 I've a class that maps it self onto a string array, providing some
 standard functionality  that makes sense to a wchar_t[] or char[].

 Now my size() method is returning the full capacity of the array.

 So in method fmt_slices, the following code:
 ...
 sink.reserve(sink.size() + cchTotal + 2);  // Ask for two more, in case
 need CR (&LF)
 ...

 will cause the reserve method to be called with a capacity that exceeds
 the current array string and it will cause an exception, since there is 
 no
 possibility for reallocation.

 So, do you any recommendation to get around this issue?

 Thanks
 ClŠudio Albuquerque



Jul 16 2012