Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 30, 2012 Fastformat::fmt_slices | ||||
---|---|---|---|---|
| ||||
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 |
June 04, 2012 Re: Fastformat::fmt_slices | ||||
---|---|---|---|---|
| ||||
Posted in reply to Claudio 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 |
July 11, 2012 Re: Fastformat::fmt_slices | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Wilson | 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
>
>
|
July 16, 2012 Re: Fastformat::fmt_slices | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cláudio | 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 >> >> > |
Copyright © 1999-2021 by the D Language Foundation