Serialization storage and reading methods of tTime

Source: Internet
Author: User
For the serialization storage and reading methods of tTime, find the answer:

WhenProgramThere are many configuration file data items, and most data types are usually saved in binary format. rreadstream and rwritestream provide multiple input and output methods for numeric and descriptor types, however, you have to deal with other basic types. For example, tTime and Symbian systems use a 64-bit integer to save the date and time, in this way, when the serialized ttimer object is used, the 64-bit value can be taken out and saved. However, we will find that rreadstream and rwritestream do not provide a 64-bit integer input/output method at all, in this case, we need to split the 64-bit integer into two 32-bit integer values and save them.CodeDemonstrate how to serialize A tTime object and demonstrate different processing methods on series 2nd and 3rd platforms:

Void externalizel (rwritestream & astream)
{
TTime time;
Time. hometime ();
// Decomposes tTime object into two tuint32 objects.
Tuint32 low (0), high (0 );
# If defined _ series60_3x __
Low = i64low (time. int64 ());
High = i64high (time. int64 ());
# Else
Low = time. int64 (). Low ();
High = time. int64 (). High ();
# Endif
Astream. writeuint32l (low );
Astream. writeuint32l (high );
}

Void internalizel (rreadstream & astream)
{
// Two tuint32 objects combine to a tint64 object for constructing a tTime object.
Tuint32 low (0), high (0 );
Low = astream. readuint32l ();
High = astream. readuint32l ();
Tint64 timeval (0 );
# If defined _ series60_3x __
Timeval = make_tint64 (high, low );
# Else
Timeval = tint64 (high, low );
# Endif
TTime time = timeval;
}

Http://wiki.forum.nokia.com/index.ph...AF%B9%E8%B1%A1 Original: http://www.forum.nokia.com/forum/showthread.php? T = 139168

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.