2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FNetNfcNdefRecord.h
19 * @brief This is the header file for the %NdefRecord class.
21 * This header file contains the declarations of the %NdefRecord class.
24 #ifndef _FNET_NFC_NDEF_RECORD_H_
25 #define _FNET_NFC_NDEF_RECORD_H_
27 #include <FBaseObject.h>
28 #include <FBaseResult.h>
30 namespace Tizen { namespace Base
36 namespace Tizen { namespace Net { namespace Nfc
39 class _NdefRecordImpl;
45 * @brief This class represents an NDEF record.
49 * The %NdefRecord class represents an NDEF record, including certain attributes such as the type, the payload, and the
50 * payload identifier. It provides the operations to manipulate them. However, this class does not expose all the
51 * attributes of an NDEF record. Some attributes defined in the NDEF specification are hidden because they are not
52 * important for applications. @n
53 * The NDEF record may contain an NDEF message in the payload. It can be converted from a Tizen::Base::ByteBuffer
54 * instance to an NdefMessage instance through the NdefMessage::GetInstanceN() method.
56 * For more information on the class features, see
57 * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
59 class _OSP_EXPORT_ NdefRecord
60 : public Tizen::Base::Object
64 * Initializes this instance of %NdefRecord with the specified parameter.
68 * @param[in] recordType A specified NDEF record type
70 NdefRecord(const NdefRecordType& recordType);
73 * Copying of objects using this copy constructor is allowed.
77 * @param[in] value An instance of %NdefRecord
78 * @remarks It performs a deep copy.
80 NdefRecord(const NdefRecord& value);
83 * This destructor overrides Tizen::Base::Object::~Object().
87 virtual ~NdefRecord(void);
90 * Compares the calling instance with the specified instance.
94 * @return @c true if the specified instance of %Object is equal to the calling %NdefRecord instance, @n
96 * @param[in] obj The object to compare
97 * @remark Two %NdefRecord instances are equal only if they contain the same %NdefRecordType instances,
98 * payload ID, and payload.
100 virtual bool Equals(const Tizen::Base::Object& obj) const;
103 * Gets the hash value of the current instance.
107 * @return The hash value of the current instance
109 virtual int GetHashCode(void) const;
112 * Gets the payload identifier for this NDEF record.
116 * @return The identifier of the payload, @n
117 * else an empty string if the identifier does not exist in the NDEF record
119 Tizen::Base::String GetPayloadId(void) const;
122 * Gets the payload in this record as Tizen::Base::ByteBuffer.
126 * @return The payload, @n
127 * else @c null if the NDEF record does not have the payload
128 * @remarks If the payload is modified after it is fetched, the payload of this record also changes.
130 Tizen::Base::ByteBuffer* GetPayload(void) const;
133 * Gets the record type of the NDEF record.
137 * @return The record type of the NDEF record
139 NdefRecordType GetRecordType(void) const;
142 * Sets the record type of the NDEF record.
146 * @return An error code
147 * @param[in] type The record type to set
148 * @exception E_SUCCESS The method is successful.
149 * @exception E_INVALID_ARG The input argument is invalid. @n
150 * For example, NDEF_TNF_EMPTY is not allowed as the input value if the identifier
151 * is not an empty string or the payload is not @c null.
153 result SetRecordType(NdefRecordType& type);
156 * Sets the identifier of the payload.
160 * @return An error code
161 * @param[in] id The identifier of the payload
162 * @exception E_SUCCESS The method is successful.
163 * @exception E_INVALID_OPERATION This operation is not allowed if the type name format of this record is
165 * @exception E_INVALID_ARG The specified identifier is not unique compared to the other records in
166 * the same NDEF message.
167 * @exception E_INVALID_ENCODING_RANGE The specified input string contains code points that are outside the
168 * bounds specified by the US_ASCII encoding scheme.
169 * @exception E_MAX_EXCEEDED The length of @c id exceeds @c 256 characters.
170 * @remarks The identifier is compared with other records only if this NDEF record is already included in an
173 result SetPayloadId(const Tizen::Base::String& id);
176 * Sets the specified data in the payload of this NDEF record.
180 * @return An error code
181 * @param[in] payload The specified payload data
182 * @exception E_SUCCESS The method is successful.
183 * @exception E_INVALID_OPERATION This operation is not allowed if the type name format of this record is
185 * @exception E_OUT_OF_MEMORY The memory is insufficient.
186 * @exception E_INVALID_ARG The @c payload is invalid. @n
187 * For example, @c payload is not constructed.
188 * @remarks The view of the specified @c payload parameter is copied and the data is shared. Therefore, if the
189 * data of @c payload is modified after setting, the data of the payload in this record also changes.
191 result SetPayload(const Tizen::Base::ByteBuffer& payload);
194 * Assigns the value of the specified instance to the current instance of %NdefRecord.
198 * @return A reference to the %NdefRecord instance
199 * @param[in] rhs A reference to the %NdefRecord instance to copy
201 NdefRecord& operator =(const NdefRecord& rhs);
205 // This default constructor is intentionally declared as private so that only the platform can create an instance.
210 _NdefRecordImpl* __pImpl;
212 friend class _NdefRecordImpl;
216 } } } // Tizen::Net::Nfc
218 #endif // _FNET_NFC_NDEF_RECORD_H_