[Interest] QFile::size() and QTextStream::pos()

Igor Mironchik igor.mironchik at gmail.com
Wed Oct 28 21:56:19 CET 2015


Hi,

On 28.10.2015 23:45, Elvis Stansvik wrote:
> 2015-10-28 20:57 GMT+01:00 Igor Mironchik <igor.mironchik at gmail.com>:
>> Hi,
>>
>> On 28.10.2015 22:50, Thiago Macieira wrote:
>>> On Wednesday 28 October 2015 22:37:06 Igor Mironchik wrote:
>>>> Hi,
>>>>
>>>> Can I expect that values returned by QFile::size() and
>>>> QTextStream::pos() are equal when stream at end?
>>> It should be, but...
>>>
>>>> Or pos() of text stream can be smaller then size of file because, for
>>>> example, text stream uses 2 bytes for each character?
>>> The documentation says "Returns the device position corresponding to the
>>> current position of the stream", so it should account for the codec
>>> transformations.
>>>
>>> But since it's doing conversions along the way, there may be trouble.
>>>
>>> Why do you want to know this? Your question screams of the X-Y problem to
>>> me.
>>
>> I want to calculate progress of file reading/parsing...
>>
>>>> Do I understand right that QTextStream::skipWhiteSpace() skips '_' and
>>>> '*' too?
>>> You can easily test this...
>>>
>>>> "bool QChar::isSpace() const
>>>> Returns true if the character is a separator character (Separator_*
>>>> categories or certain code points from Other_Control category);
>>>> otherwise returns false."
>>> 002A;ASTERISK;Po;0;ON;;;;;N;;;;;
>>> 002D;HYPHEN-MINUS;Pd;0;ES;;;;;N;;;;;
>>>
>>> Both have categories starting with P (Punctuation), so they're not
>>> Separator
>>> and they're not Other_Control.
>>>
>>> Why do you think '*' and '_' should be considered whitespace? They're not
>>> even
>>> blank...
>>
>> Because of this sentence:
>>
>> Separator_* categories or certain code points from Other_Control category
>>
>> And I don't know how to understand this, especially _* in the sentence...
> The * is just a wildcard, so it means all categories that starts with
> "Separator_".

Thank you, Elvis. So stupid misunderstood...

-- 
Best Regards,
Igor Mironchik.




More information about the Interest mailing list