javacommons/javastorage/inc/javastorageentry.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  JavaStorageEntry
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef JAVASTORAGEENTRY_H
       
    20 #define JAVASTORAGEENTRY_H
       
    21 
       
    22 #include <stdio.h>
       
    23 #include <string>
       
    24 #include "javaosheaders.h"
       
    25 
       
    26 namespace java
       
    27 {
       
    28 namespace storage
       
    29 {
       
    30 
       
    31 /**
       
    32  * JavaStorageEntry is object to hold JavaStorage data. One entry represents
       
    33  * one column data. These entries are passed and received from JavaStorage
       
    34  * to store and read data.<br>
       
    35  * Usage instructions:
       
    36  * @code
       
    37  *    #include "javastoragenames.h"
       
    38  *    ...
       
    39  *    JavaStorageApplicationEntry_t entries;
       
    40  *    JavaStorageEntry attribute;
       
    41  *
       
    42  *    attribute.setEntry(PACKAGE_NAME, L"MyApplicationName");
       
    43  *    entries.insert(attribute);
       
    44  *
       
    45  *    attribute.setEntry(VERSION, L"1.0.2");
       
    46  *    entries.insert(attribute);
       
    47  * @endcode
       
    48  */
       
    49 class JavaStorageEntry
       
    50 {
       
    51 public:
       
    52 
       
    53     /**
       
    54      * JavaStorageEntry column type. Type is used when new storage tables
       
    55      * or columns are created.
       
    56      */
       
    57     enum JavaEntryColumnType { NOT_DEFINED = 1, STRING, INT, NULL_TYPE };
       
    58 
       
    59     /**
       
    60      * Set JavaStorageEntry.
       
    61      *
       
    62      * @param aName Entry name.
       
    63      * @param aValue Entry value.
       
    64      * @param aType Entry type. Default type is
       
    65      *              JavaEntryColumnType::NOT_DEFINED.
       
    66      */
       
    67     OS_IMPORT void setEntry(const std::wstring& aName,
       
    68                             const std::wstring& aValue,
       
    69                             JavaEntryColumnType aType = NOT_DEFINED);
       
    70 
       
    71     /**
       
    72      * Get entry type.
       
    73      *
       
    74      * @return Entry name or empty string if not set.
       
    75      */
       
    76     OS_IMPORT std::wstring entryName() const;
       
    77 
       
    78     /**
       
    79      * Get entry value.
       
    80      *
       
    81      * @return Entry value or empty string if not set.
       
    82      */
       
    83     OS_IMPORT std::wstring entryValue() const;
       
    84 
       
    85     /**
       
    86      * Get entry type.
       
    87      *
       
    88      * @return Entry type or NOT_DEFINED if not used.
       
    89      */
       
    90     OS_IMPORT JavaEntryColumnType entryType() const;
       
    91 
       
    92     /**
       
    93      * Operator for inserting entries at correct order. Entries are ordered
       
    94      * by their name. If name equals then they are ordered also by value.
       
    95      * However if value is empty comparison is done only by name. This is
       
    96      * for the case value is not known.
       
    97      *
       
    98      * @param aJse Entry to be compared.
       
    99      * @return true if entry must be placed earlier.
       
   100      */
       
   101     OS_IMPORT bool operator< (const JavaStorageEntry& aJse) const;
       
   102 
       
   103 private:
       
   104     std::wstring mName;
       
   105     std::wstring mValue;
       
   106     JavaEntryColumnType mType;
       
   107 };
       
   108 
       
   109 }    // java
       
   110 }    // storage
       
   111 
       
   112 #endif // JAVASTORAGEENTRY_H
       
   113