×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    34

    Save the setting list value in a stream

    Hi everyone,
    I am the newer of the symbian C++.
    After I create a setting list in the UI, I hope to create a "stream" to store and get the data.
    I have already seen a lot of thread and wiki talking about this. However, most of the thread only show a part of their code. Actually, I want to know:

    1. Should I need to create a new class for the stream like SaveData.h and SaveData.cpp ??

    2. Where can I insert the code in the project?
    For example:
    void CSettingsList::SaveSettingValuesL()
    {
    RFs fileSession;
    RFile myFile;
    fileSession.Connect ();
    myFile.Create (fileSession, _L("C:\\Test\\test.txt"), EFileWrite);
    ....
    ....
    fileSession.close ();
    }
    Are they correct? How about the location? Will the mobile phone create a txt file in its C driver?

    3. What lib and .h file could be included in the application?

    4. Anyone can show a more detailed coding for me?

    Thank you for you help.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,675

    Re: Save the setting list value in a stream

    0. You can find related streaming-related examples in Examples\SysLibs (Streaming, Streams, but you may want to check Stores, perhaps FileStores too)

    1+2. It is also an option to simply create a T-class (or struct) for your settings:
    Code:
    class TMySettings
    {
    public:
        TBuf<32> iMyString;
        TBool    iMyBool;
        TInt     iMyNumber;
    };
    Then if you have a variable of TMySettings "settings", you can write it to "myFile" as
    Code:
    TPckg<TMySettings> settingspackage;
    myFile.Write(settingspackage);
    and read it back
    Code:
    TPckg<TMySettings> settingspackage;
    myFile.Read(settingspackage);
    3. If you already know the name of a class - which is quite probable, otherwise you could not use it -, you can simply search for it in the SDK Help. For example RFile:
    Quote Originally Posted by SDK Help
    » Symbian OS v9.2 » Symbian OS reference » C++ component reference » Base F32 » RFile


    --------------------------------------------------------------------------------

    Location: f32file.h
    Link against: efsrv.lib

    Class RFile
    class RFile : public RSubSessionBase;
    Description
    Creates and opens a file, and performs all operations on a single open file.

    These include:
    ...
    So you will find the necessary headers and libraries in the documentation.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    34

    Re: Save the setting list value in a stream

    HI wizard_hu_,
    Thank you of you quick reply. However, in your answer, you create a T-class and include some of the variable. I think the variable will be stored to the file, right? And why you don't need to include the function in the class?

    2. How to create a variable of TMySettings "settings" and "myFile"??

    3. I saw the book. It shows a lot of functions in stream like RWriteStream, ExternalizeL(), RReadStream, InternalizeL(). Should I include it in my application and create a new class to include them?

    4. Can you tell me the full Link of the Examples\SysLibs?

    As I am not understand about Rfile, stream and stores, sorry for many stupid questions.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,675

    Re: Save the setting list value in a stream

    Quote Originally Posted by hin0607 View Post
    Thank you of you quick reply. However, in your answer, you create a T-class and include some of the variable. I think the variable will be stored to the file, right? And why you don't need to include the function in the class?
    Because in the example I use a so called packaging descriptor (TPckg): it simply wraps the given T-type into a 8-bit descriptor, and RFile can directly work with 8-bit descriptors. So no extra functionality is needed.
    2. How to create a variable of TMySettings "settings" and "myFile"??
    That is a strange question, since your original post already contains a variable called "myFile", that is why I have re-used it.
    3. I saw the book. It shows a lot of functions in stream like RWriteStream, ExternalizeL(), RReadStream, InternalizeL(). Should I include it in my application and create a new class to include them?
    Streaming is an other thing, and yes, in case of streaming, the class itself knows how to serialize/deserialize itself (practically it has to write/read its variables one-by-one), so you have to write some code for that.
    For example externalizing in case of TMySettings could be something like this:
    Code:
    void TMySettings::ExternalizeL(RWriteStream& aStream) const
    {
        aStream << iMyString;
        aStream.WriteInt8L(iMyBool?1:0);
        aStream.WriteInt32L(static_cast<TInt32>(iMyNumber));
    }
    The small magics are required because there is no direct method for storing TBool or TInt, just for TInt8 or TInt32.
    4. Can you tell me the full Link of the Examples\SysLibs?
    It is in the SDK, check its installation directory:
    S60 3rd FP1: C:\Symbian\9.2\S60_3rd_FP1\Examples\SysLibs
    S60 3rd FP2: C:\S60\devices\S60_3rd_FP2_SDK_v1.1\Examples\SysLibs
    S60 5th: C:\S60\devices\S60_5th_Edition_SDK_v0.9\Examples\SysLibs
    As I am not understand about Rfile, stream and stores, sorry for many stupid questions.
    That is not a problem, check the examples, and always read the documentation when you see some class/method which you do not know. Also note the existence of the Wiki, you can effectively search for simple sentences or pure class names in it, and find useful articles in return.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    34

    Re: Save the setting list value in a stream

    Thank you again. I think I can get more information from your answer and it is useful for me.

Similar Threads

  1. Problem with Skin enabling - disabling and Setting List in S60
    By sauvikds in forum Series 40 & S60 Platform Feedback Archive
    Replies: 6
    Last Post: 2008-08-23, 14:29
  2. Problem with Skin enabling - disabling and Setting List in S60
    By sauvikds in forum General Development Questions
    Replies: 1
    Last Post: 2008-08-21, 12:44
  3. Setting List and CONE 14
    By yazwas in forum Symbian
    Replies: 6
    Last Post: 2006-05-15, 09:43
  4. setting list in dialog
    By wapawapa in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-08-07, 05:34
  5. setting list problem
    By ddhungry in forum Symbian User Interface
    Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×