2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 * @brief This is the header file for the %Registry class.
21 * This header file contains the declarations of the %Registry class.
24 #ifndef _FIO_REGISTRY_H_
25 #define _FIO_REGISTRY_H_
27 #include <FBaseObject.h>
28 #include <FBaseUuId.h>
29 #include <FBaseByteBuffer.h>
30 #include <FBaseColArrayList.h>
31 #include <FBaseResult.h>
32 #include <FBaseColIMap.h>
33 #include <FIoFileLock.h>
35 namespace Tizen {namespace Base
41 namespace Tizen { namespace Io
44 static const long REG_OPEN_READ_ONLY = 0x00000001L;
45 static const long REG_OPEN_READ_WRITE = 0x00000002L;
46 static const long REG_OPEN_CREATE = 0x00000004L;
50 * @brief This class provides a mechanism to access and manipulate registry files.
54 * @final This class is not intended for extension.
56 * The %Registry class provides a mechanism to access and manipulate registry files.
58 * For more information on the class features,
59 * see <a href="../org.tizen.native.appprogramming/html/guide/io/io_namespace.htm">Io Guide</a>.
61 * The following example demonstrates how to use the %Registry class.
68 using namespace Tizen::Base;
69 using namespace Tizen::Io;
70 using namespace Tizen::App;
76 String regPathName(L"regTest.ini");
79 String sect1(L"section1");
80 String sect2(L"section2");
81 String sect3(L"section3");
84 String entry1(L"entry1");
85 String entry2(L"entry2");
90 r = reg.Construct(App::GetInstance()->GetAppDataPath() + regPathName, "a+");
97 r = reg.AddSection(sect1);
98 r = reg.AddSection(sect2);
99 r = reg.AddSection(sect3);
101 // Add value: section1 { entry1 = 999 }
102 r = reg.AddValue(sect1, entry1, 999);
108 // Change value: section1 { entry1 = 3 }
109 r = reg.SetValue(sect1, entry1, 3);
115 // Add value: section2 { entry2 = 1.1234599 }
116 r = reg.AddValue(sect2, entry2, 1.1234599);
122 // Get value: section1 { entry1 = ? }
123 r = reg.GetValue(sect1, entry1, iVal);
139 // Do some error handling
145 class _OSP_EXPORT_ Registry
146 : public Tizen::Base::Object
151 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
158 * This destructor overrides Tizen::Base::Object::~Object().
162 virtual ~Registry(void);
166 * Initializes this instance of %Registry with the specified parameters. @n
167 * This method loads a registry file in the read-write mode.
170 * @brief <i> [Deprecated] [Compatibility] </i>
172 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
173 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
176 * @compatibility This method has compatibility issues with OSP compatible applications. @n
177 * For more information, see @ref CompIoPathPage "here".
180 * @return An error code
181 * @param[in] regPath The path of the registry file to open or create
182 * @param[in] createIfNotExist Set to @c true to create a registry file, @n
183 * else @c false to open an existing registry file
184 * @exception E_SUCCESS The method is successful.
185 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
186 * - The length of the specified string of a file path is less
187 * than or equal to @c 0. @n
188 * - The translated overall length of the specified path exceeds the
189 * system limitation. @n
190 * - The specified path is invalid. @n
191 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
192 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
193 * @exception E_END_OF_FILE The file pointer has reached end-of-file.
194 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
195 * @exception E_STORAGE_FULL The disk space is full.
196 * @exception E_IO Either of the following conditions has occurred: @n
197 * - An unexpected device failure has occurred as the media ejected suddenly. @n
198 * - %File corruption is detected.
199 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
200 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
201 * @remarks To load the registry in read-only mode, use the Registry::Construct(const Tizen::Base::String& regPath,
202 * long openMode, long option) method with REG_OPEN_READ_ONLY as a value for the open mode flag.
205 result Construct(const Tizen::Base::String& regPath, bool createIfNotExist);
209 * Initializes this instance of %Registry with the specified parameters. @n
210 * This method loads a registry file in the read-only or the read-write mode.
213 * @brief <i> [Deprecated] [Compatibility] </i>
215 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
216 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
219 * @compatibility This method has compatibility issues with OSP compatible applications. @n
220 * For more information, see @ref CompIoPathPage "here".
223 * @return An error code
224 * @param[in] regPath The path of the registry file to open or create
225 * @param[in] openMode An open mode flag @n
226 * Currently, the following flags can be used in combination with
227 * the logical OR operator: @n
228 * (1) REG_OPEN_READ_ONLY @n
229 * (2) REG_OPEN_READ_WRITE @n
230 * (3) REG_OPEN_READ_WRITE | REG_OPEN_CREATE
231 * @param[in] option This argument is reserved for further use @n It is recommended to use @c 0.
232 * @exception E_SUCCESS The method is successful.
233 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
234 * - The length of the specified string of a file path is less
235 * than or equal to @c 0. @n
236 * - The translated overall length of the specified path exceeds the
237 * system limitation. @n
238 * - The specified path is invalid. @n
239 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
240 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
241 * @exception E_END_OF_FILE The file pointer has reached end-of-file.
242 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
243 * @exception E_STORAGE_FULL The disk space is full.
244 * @exception E_IO Either of the following conditions has occurred: @n
245 * - An unexpected device failure has occurred as the media ejected suddenly. @n
246 * - %File corruption is detected.
247 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
248 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
251 result Construct(const Tizen::Base::String& regPath, long openMode, long option);
254 * Initializes this instance of %Registry with the specified parameters. @n
255 * This method opens an existing registry file or creates a new one according to the specified file opening mode.
256 * And this method loads data of the registry file to system memory and flushes the data to the storage when this instance
257 * is released or Registry::Flush() is called.
261 * @return An error code
262 * @param[in] regPath The path of the registry file to open or create
263 * @param[in] pOpenMode The file opening mode @n
264 * It can be one of the following:
265 * - r : Open for reading.
266 * - r+: Open for reading and writing.
267 * - w : Open for writing. The registry file is created if it does not exist,
268 * otherwise it is truncated to zero length.
269 * - w+: Open for writing and reading. The registry file is created if it does not exist,
270 * otherwise it is truncated to zero length.
271 * - a : Open for writing. The registry file is created if it does not exist.
272 * - a+: Open for writing and reading. The registry file is created if it does not exist.
273 * @exception E_SUCCESS The method is successful.
274 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
275 * - The overall length of the specified @c regPath is equal to @c 0 or
276 * exceeds system limitations. @n
277 * - The combination of the specified @c pOpenMode is not allowed. @n
278 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
279 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
280 * @exception E_INVALID_FORMAT Either of the following conditions has occurred: @n
281 * - The section or entry name of the registry file includes one of the following characters:
282 * '\0', '\n', '#' and '='.
283 * - The entry value of the registry file includes one of the following characters:
285 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
286 * @exception E_STORAGE_FULL The disk space is full.
287 * @exception E_IO Either of the following conditions has occurred: @n
288 * - An unexpected device failure has occurred as the media ejected suddenly. @n
289 * - %File corruption is detected.
290 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
292 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode);
295 * Initializes this instance of %Registry with the specified parameters. @n
296 * This method opens an existing secure registry file or creates a new one according to the specified file opening mode.
297 * And this method loads data of the secure registry file to system memory and flushes the data to the storage when this instance
298 * is released or Registry::Flush() is called.
299 * The contents written to the secure registry file is automatically encrypted and the contents read from the secure registry
300 * file is automatically decrypted by the platform. @n
301 * Applications using this method can access the same secure registry files that are created by other applications with the
302 * identical key value in same device. However, the secure registry files created by this method cannot be accessed in other devices.
306 * @return An error code
307 * @param[in] regPath The path of the registry file to open or create
308 * @param[in] pOpenMode The file opening mode @n
309 * It can be one of the following:
310 * - r : Open for reading.
311 * - r+: Open for reading and writing.
312 * - w : Open for writing. The registry file is created if it does not exist,
313 * otherwise it is truncated to zero length.
314 * - w+: Open for writing and reading. The registry file is created if it does not exist,
315 * otherwise it is truncated to zero length.
316 * - a : Open for writing. The registry file is created if it does not exist.
317 * - a+: Open for writing and reading. The registry file is created if it does not exist.
318 * @param[in] secretKey A key used to encrypt data of a registry file or decrypt a secure registry file @n
319 * If a secure registry file is created with a specific key value,
320 * other applications can access the same secure registry file with the identical key value.
321 * @exception E_SUCCESS The method is successful.
322 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
323 * - The overall length of the specified path is equal to @c 0 or
324 * exceeds system limitations.
325 * - The combination of the specified @c pOpenMode is not allowed. @n
326 * - The specified @c secretKey is incorrect or the secure registry file is corrupted.
327 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
328 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
329 * @exception E_INVALID_FORMAT Either of the following conditions has occurred: @n
330 * - The section or entry name of the registry file includes one of the following characters:
331 * '\0', '\n', '#' and '='.
332 * - The entry value of the registry file includes one of the following characters:
334 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
335 * @exception E_STORAGE_FULL The disk space is full.
336 * @exception E_IO Either of the following conditions has occurred: @n
337 * - An unexpected device failure has occurred as the media ejected suddenly. @n
338 * - %File corruption is detected. @n
339 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
341 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
344 * Flushes the current contents of a registry in memory. @n
345 * If the secure mode is set to be @c true, the contents of the registry are automatically encrypted
346 * and saved by the platform.
350 * @return An error code
351 * @exception E_SUCCESS The method is successful.
352 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
353 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
354 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
355 * @exception E_STORAGE_FULL The disk space is full.
356 * @exception E_IO Either of the following conditions has occurred: @n
357 * - An unexpected device failure has occurred as the media ejected suddenly. @n
358 * - %File corruption is detected. @n
363 * Creates the specified section then adds it into the registry.
367 * @return An error code
368 * @param[in] sectionName The section name
369 * @exception E_SUCCESS The method is successful.
370 * @exception E_INVALID_ARG The length of the specified string for a section name is less than
372 * @exception E_SECTION_ALREADY_EXIST A section with the specified name already exists.
374 result AddSection(const Tizen::Base::String& sectionName);
377 * Removes the section from %Registry.
381 * @return An error code
382 * @param[in] sectionName The section name to remove
383 * @exception E_SUCCESS The method is successful.
384 * @exception E_INVALID_ARG The length of the specified string for a section is less than
386 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
388 result RemoveSection(const Tizen::Base::String& sectionName);
391 * Gets all section names in the registry.
395 * @return A list of section names @n
396 * If this method fails, @c null value is returned. @n
397 * The specific error code can be accessed using the GetLastResult() method. @n
398 * When there are no sections at all, the method returns an empty list instance. @n
399 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of elements in the list.
400 * @exception E_SUCCESS The method is successful.
401 * @remarks Do not forget to delete not only the returned IList instance, but also its
402 * contents by invoking IList::RemoveAll(). @n
403 * The specific error code can be accessed using the GetLastResult() method.
405 Tizen::Base::Collection::IList* GetAllSectionNamesN(void) const;
408 * Gets all entry names in the specified section of the registry.
412 * @return A list of entry names @n
413 * If this method fails, @c null value is returned. @n
414 * When there are no entries at all, the method returns an empty list instance. @n
415 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of element in the list.
416 * @param[in] sectionName The section name
417 * @exception E_SUCCESS The method is successful.
418 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
419 * @exception E_IO A system error has occurred.
420 * @remarks Do not forget to delete not only the returned IList instance, but also its
421 * contents by invoking IList::RemoveAll(). @n
422 * The specific error code can be accessed using the GetLastResult() method.
424 Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName) const;
427 * Adds the name-value pair of type integer as an entry of the specific section.
431 * @return An error code
432 * @param[in] sectionName The section name
433 * @param[in] entryName The entry name
434 * @param[in] value The @c int value
435 * @exception E_SUCCESS The method is successful.
436 * @exception E_INVALID_ARG Either the length of the specified string for a section
437 * or an entry is less than or equal to @c 0,
438 * or a @c null value is passed. @n
439 * Note that, it is also possible that the data inside a registry instance is
440 * corrupted due to its usage in a multi-threaded environment without
442 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
443 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
445 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int value);
448 * Adds the name-value pair of type double as an entry of the specific section.
452 * @return An error code
453 * @param[in] sectionName The section name
454 * @param[in] entryName The entry name
455 * @param[in] value The @c double value
456 * @exception E_SUCCESS The method is successful.
457 * @exception E_INVALID_ARG Either the length of the specified string for a section
458 * or an entry is less than or equal to @c 0,
459 * or a @c null value is passed. @n
460 * Note that, it is also possible that the data inside a registry instance is
461 * corrupted due to its usage in a multi-threaded environment without
463 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
464 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
465 * @remarks This method converts the specified double type @c value to string value using "%lg" format specifier. @n
466 * Also, it does not depend on system locale.
468 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double value);
471 * Adds the name-value pair of type float as an entry of the specific section.
475 * @return An error code
476 * @param[in] sectionName The section name
477 * @param[in] entryName The entry name
478 * @param[in] value The @c float value
479 * @exception E_SUCCESS The method is successful.
480 * @exception E_INVALID_ARG Either the length of the specified string for a section
481 * or an entry is less than or equal to @c 0,
482 * or a @c null value is passed. @n
483 * Note that, it is also possible that the data inside a registry instance is
484 * corrupted due to its usage in a multi-threaded environment without
486 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
487 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
488 * @remarks This method converts the specified float type @c value to string value using "%g" format specifier. @n
489 * Also, it does not depend on system locale.
491 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float value);
494 * Adds the name-value pair of type String as an entry of the specific section.
498 * @return An error code
499 * @param[in] sectionName The section name
500 * @param[in] entryName The entry name
501 * @param[in] value The String value
502 * @exception E_SUCCESS The method is successful.
503 * @exception E_INVALID_ARG Either the length of the specified string for a section
504 * or an entry is less than or equal to @c 0.
505 * Note that, it is also possible that the data inside a registry instance is
506 * corrupted due to its usage in a multi-threaded environment without
508 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
509 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
511 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& value);
514 * Adds the name-value pair of type UuId as an entry for the specified section.
518 * @return An error code
519 * @param[in] sectionName The section name
520 * @param[in] entryName The entry name
521 * @param[in] value The UuId value
522 * @exception E_SUCCESS The method is successful.
523 * @exception E_INVALID_ARG Either the length of the specified string for a section
524 * or an entry is less than or equal to @c 0,
525 * or a @c null value is passed. @n
526 * Note that, it is also possible that the data inside a registry instance is
527 * corrupted due to its usage in a multi-threaded environment without
529 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
530 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
532 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& value);
535 * Adds the name-value pair of type ByteBuffer as an entry for the specified section.
539 * @return An error code
540 * @param[in] sectionName The section name
541 * @param[in] entryName The entry name
542 * @param[in] value The @c ByteBuffer value @n
543 * Note that, it should be constructed before being passed to the method.
544 * @exception E_SUCCESS The method is successful.
545 * @exception E_INVALID_ARG Either the length of the specified string for a section
546 * or an entry is less than or equal to @c 0,
547 * or a @c null value is passed. @n
548 * Note that, it is also possible that the data inside a registry instance is
549 * corrupted due to its usage in a multi-threaded environment without
551 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
552 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
553 * @remarks Note that all the contents of @c ByteBuffer are saved as an entry value.
554 * That is, byte data from @c 0 up to the buffer limit is saved.
555 * @see Tizen::Base::ByteBuffer
557 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& value);
560 * Gets the @c int value of the specified entry.
564 * @return An error code
565 * @param[in] sectionName The section name
566 * @param[in] entryName The name of entry where its value will be fetched
567 * @param[out] retVal The return value obtained from the registry
568 * @exception E_SUCCESS The method is successful.
569 * @exception E_INVALID_ARG Either the length of the specified string for a section
570 * or an entry is less than or equal to @c 0,
571 * or a @c null value is passed. @n
572 * Note that, it is also possible that the data inside a registry instance is
573 * corrupted due to its usage in a multi-threaded environment without
575 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
576 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
577 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
578 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
580 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int& retVal) const;
583 * Gets the @c double value of the specified entry.
587 * @return An error code
588 * @param[in] sectionName The section name
589 * @param[in] entryName The name of entry where its value will be fetched
590 * @param[out] retVal The return value obtained from the registry
591 * @exception E_SUCCESS The method is successful.
592 * @exception E_INVALID_ARG Either the length of the specified string for a section
593 * or an entry is less than or equal to @c 0,
594 * or a @c null value is passed. @n
595 * Note that, it is also possible that the data inside a registry instance is
596 * corrupted due to its usage in a multi-threaded environment without
598 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
599 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
600 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
601 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
602 * @remarks This method does not depend on system locale.
604 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double& retVal) const;
607 * Gets the @c float value of the specified entry.
611 * @return An error code
612 * @param[in] sectionName The section name
613 * @param[in] entryName The name of entry where its value will be fetched
614 * @param[out] retVal The return value obtained from the registry
615 * @exception E_SUCCESS The method is successful.
616 * @exception E_INVALID_ARG Either the length of the specified string for a section
617 * or an entry is less than or equal to @c 0,
618 * or a @c null value is passed. @n
619 * Note that, it is also possible that the data inside a registry instance is
620 * corrupted due to its usage in a multi-threaded environment without
622 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
623 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
624 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
625 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
626 * @remarks This method does not depend on system locale.
628 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float& retVal) const;
631 * Gets the String value of a specific entry.
635 * @return An error code
636 * @param[in] sectionName The section name
637 * @param[in] entryName The name of entry where its value will be fetched
638 * @param[out] retVal The return value obtained from the registry
639 * @exception E_SUCCESS The method is successful.
640 * @exception E_INVALID_ARG Either the length of the specified string for a section
641 * or an entry is less than or equal to @c 0,
642 * or a @c null value is passed. @n
643 * Note that, it is also possible that the data inside a registry instance is
644 * corrupted due to its usage in a multi-threaded environment without
646 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
647 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
648 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
649 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
651 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& retVal) const;
654 * Gets the UuId value of the specified entry.
658 * @return An error code
659 * @param[in] sectionName The section name
660 * @param[in] entryName The name of entry where its value will be fetched
661 * @param[out] retVal The return value obtained from the registry
662 * @exception E_SUCCESS The method is successful.
663 * @exception E_INVALID_ARG Either the length of the specified string for a section
664 * or an entry is less than or equal to @c 0,
665 * or a @c null value is passed. @n
666 * Note that, it is also possible that the data inside a registry instance is
667 * corrupted due to its usage in a multi-threaded environment without
669 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
670 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
671 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
672 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
674 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::UuId& retVal) const;
677 * Gets the ByteBuffer value of the specified entry.
681 * @return An error code
682 * @param[in] sectionName The section name
683 * @param[in] entryName The name of entry where its value will be fetched
684 * @param[out] retVal The return value obtained from the registry
685 * @exception E_SUCCESS The method is successful.
686 * @exception E_INVALID_ARG Either the length of the specified string for a section
687 * or an entry is less than or equal to @c 0,
688 * or a @c null value is passed. @n
689 * Note that, it is also possible that the data inside a registry instance is
690 * corrupted due to its usage in a multi-threaded environment without
692 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
693 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
694 * @exception E_PARSING_FAILED The method has failed to parse the encoded entry value string, or the value is retrieved by using an incorrect data type.
695 * @exception E_DATA_NOT_FOUND The name-value pair has no value assigned (if the value is retrieved using the REGTYPE_STRING type, an empty string is returned even if no value is assigned).
696 * @remarks The ByteBuffer should be constructed before passing it to the method.
697 * That is, the size of the binary data to be fetched should be decided beforehand.
698 * When the %ByteBuffer capacity is less than the actual binary data stored in the registry,
699 * this method reads the data as much as the %ByteBuffer capacity. The position of the %ByteBuffer and
700 * limit are not changed. When the %ByteBuffer capacity is greater than the actual data size,
701 * the method reads the whole data and adjusts the limit of the buffer accordingly.
702 * @see Tizen::Base::ByteBuffer
704 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::ByteBuffer& retVal) const;
707 * Modifies the value of the specified entry using the specified @c int value.
711 * @return An error code
712 * @param[in] sectionName The section name
713 * @param[in] entryName The entry name to modify
714 * @param[in] newValue The @c int value
715 * @exception E_SUCCESS The method is successful.
716 * @exception E_INVALID_ARG Either the length of the specified string for a section
717 * or an entry is less than or equal to @c 0,
718 * or a @c null value is passed. @n
719 * Note that, it is also possible that the data inside a registry instance is
720 * corrupted due to its usage in a multi-threaded environment without
722 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
723 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
724 * @remarks This method will not add a name-value pair as an entry of a specific section
725 * if no entry with the specified name exists.
726 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
729 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int newValue);
732 * Modifies the value of the specified entry using the specified @c double value.
736 * @return An error code
737 * @param[in] sectionName The section name
738 * @param[in] entryName The entry name to modify
739 * @param[in] newValue The @c double value
740 * @exception E_SUCCESS The method is successful.
741 * @exception E_INVALID_ARG Either the length of the specified string for a section
742 * or an entry is less than or equal to @c 0,
743 * or a @c null value is passed. @n
744 * Note that, it is also possible that the data inside a registry instance is
745 * corrupted due to its usage in a multi-threaded environment without
747 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
748 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
749 * @remarks This method will not add a name-value pair as an entry of a specific section
750 * if no entry with the specified name exists.
751 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
752 * @remarks This method converts the specified double type @c newValue to string value using "%lg" format specifier. @n
753 * Also, it does not depend on system locale.
756 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double newValue);
759 * Modifies the value of the specified entry using the specified @c float value.
763 * @return An error code
764 * @param[in] sectionName The section name
765 * @param[in] entryName The entry name to modify
766 * @param[in] newValue The @c float value
767 * @exception E_SUCCESS The method is successful.
768 * @exception E_INVALID_ARG Either the length of the specified string for a section
769 * or an entry is less than or equal to @c 0,
770 * or a @c null value is passed. @n
771 * Note that, it is also possible that the data inside a registry instance is
772 * corrupted due to its usage in a multi-threaded environment without
774 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
775 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
776 * @remarks This method will not add a name-value pair as an entry of a specific section
777 * if no entry with the specified name exists.
778 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
779 * @remarks This method converts the specified float type @c newValue to string value using "%g" format specifier. @n
780 * Also, it does not depend on system locale.
783 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float newValue);
786 * Modifies the value of the specified entry using the specified String value.
790 * @return An error code
791 * @param[in] sectionName The section name
792 * @param[in] entryName The entry name to modify
793 * @param[in] newValue The String value
794 * @exception E_SUCCESS The method is successful.
795 * @exception E_INVALID_ARG Either the length of the specified string for a section
796 * or an entry is less than or equal to @c 0.
797 * Note that, it is also possible that the data inside a registry instance is
798 * corrupted due to its usage in a multi-threaded environment without
800 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
801 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
802 * @remarks This method will not add a name-value pair as an entry of a specific section
803 * if no entry with the specified name exists.
804 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
807 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& newValue);
810 * Modifies the value of the specified entry using the specified UuID value.
814 * @return An error code
815 * @param[in] sectionName The section name
816 * @param[in] entryName The entry name to modify
817 * @param[in] newValue The UuId value
818 * @exception E_SUCCESS The method is successful.
819 * @exception E_INVALID_ARG Either the length of the specified string for a section
820 * or an entry is less than or equal to @c 0,
821 * or a @c null value is passed. @n
822 * Note that, it is also possible that the data inside a registry instance is
823 * corrupted due to its usage in a multi-threaded environment without
825 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
826 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
827 * @remarks This method will not add a name-value pair as an entry of a specific section if no
828 * entry with the specified name exists.
829 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
832 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& newValue);
835 * Modifies the value of the specified entry using the specified ByteBuffer value.
839 * @return An error code
840 * @param[in] sectionName The section name
841 * @param[in] entryName The entry name to modify
842 * @param[in] newValue The @c ByteBuffer value
843 * @exception E_SUCCESS The method is successful.
844 * @exception E_INVALID_ARG Either the length of the specified string for a section
845 * or an entry is less than or equal to @c 0,
846 * or a @c null value is passed. @n
847 * Note that, it is also possible that the data inside a registry instance is
848 * corrupted due to its usage in a multi-threaded environment without
850 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
851 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
852 * @remarks This method will not add a name-value pair as an entry of a specific section
853 * if no entry with the specified name exists.
854 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
857 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& newValue);
860 * Removes the name-value pair entry from specific section.
864 * @return An error code
865 * @param[in] sectionName The section name
866 * @param[in] entryName The entry name to remove
867 * @exception E_SUCCESS The method is successful.
868 * @exception E_INVALID_ARG The length of the specified string for a section or entry is less
869 * than or equal to @c 0.
870 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
871 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
873 result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
876 * Acquires the file lock on the current opened whole file if it is not acquired.
877 * If the file lock is already acquired by another process, the current process is blocked until the file lock is
882 * @return The pointer to %FileLock instance, @n
883 * else @c null pointer in case of failure
884 * @param[in] lockType The type of file lock to be created
885 * @exception E_SUCCESS The method is successful.
886 * @exception E_INVALID_ARG The specified @c lockType is invalid.
887 * @exception E_INVALID_OPERATION Either of the following conditions has occurred: @n
888 * - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
889 * file is not open for reading. @n
890 * - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
891 * file is not open for writing. @n
892 * @exception E_WOULD_DEADLOCK The method would cause a deadlock. @n
893 * The lock is blocked by a lock from another process, and putting the
894 * calling process to sleep to wait for that lock to become free would
896 * @exception E_MAX_EXCEEDED The number of file lock exceeds system limitations.
897 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
898 * @remarks The %FileLock instance is invalid if the associated %File instance is deleted. @n
899 * The specific error code can be accessed using the GetLastResult() method.
900 * @see Tizen::Io::File::FileLockType
902 FileLock* LockN(FileLockType lockType);
905 * Tries to acquire the file lock on the current opened whole file.
906 * If the file lock is already acquired by another process, E_OBJECT_LOCKED is returned.
910 * @return The pointer to %FileLock instance, @n
911 * else @c null pointer in case of failure
912 * @param[in] lockType The type of file lock to be created
913 * @exception E_SUCCESS The method is successful.
914 * @exception E_INVALID_ARG The specified @c lockType is invalid.
915 * @exception E_INVALID_OPERATION Either of the following conditions has occurred: @n
916 * - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
917 * file is not open for reading. @n
918 * - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
919 * file is not open for writing. @n
920 * @exception E_OBJECT_LOCKED Either of the following conditions has occurred: @n
921 * - The file lock is already held by another process. @n
922 * - The file to be locked has been memory-mapped by another process.
923 * @exception E_MAX_EXCEEDED The number of file lock exceeds system limitations.
924 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
925 * @remarks The %FileLock instance is invalid if the associated %File instance is deleted. @n
926 * The specific error code can be accessed using the GetLastResult() method.
927 * @see Tizen::Io::File::FileLockType
929 FileLock* TryToLockN(FileLockType lockType);
932 * Removes the specified registry file.
935 * @brief <i> [Compatibility] </i>
939 * @compatibility This method has compatibility issues with OSP compatible applications. @n
940 * For more information, see @ref CompIoPathPage "here".
943 * @return An error code
944 * @param[in] regPath The path of the registry file to remove
945 * @exception E_SUCCESS The method is successful.
946 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
947 * - The length of the specified string of a file path is less
948 * than or equal to @c 0. @n
949 * - The translated overall length of the specified path exceeds the
950 * system limitation. @n
951 * - The specified path is invalid. @n
952 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
953 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
954 * @exception E_IO Either of the following conditions has occurred: @n
955 * - An unexpected device failure has occurred as the media ejected suddenly. @n
956 * - %File corruption is detected.
958 static result Remove(const Tizen::Base::String& regPath);
961 * Converts a normal registry file to a secure registry file. @n
962 * A secure registry file that is converted by this method can be shared among applications with the same key value.
965 * @brief <i> [Compatibility] </i>
969 * @compatibility This method has compatibility issues with OSP compatible applications. @n
970 * For more information, see @ref CompIoPathPage "here".
973 * @return An error code
974 * @param[in] plainRegPath The normal (non-encrypted) registry file path
975 * @param[in] secureRegPath The secure (encrypted) registry file path to create
976 * @param[in] key A key that encrypts a secure registry file @n
977 * If the secure registry file is converted with a specific key value,
978 * applications can access the same secure registry file with the identical key value.
979 * @exception E_SUCCESS The method is successful.
980 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
981 * - The length of the specified string of a file path is less
982 * than or equal to @c 0. @n
983 * - The translated overall length of the specified path exceeds the
984 * system limitation. @n
985 * - The specified path is invalid. @n
986 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
987 * @exception E_FILE_ALREADY_EXIST The specified file already exists.
988 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
989 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
990 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
991 * @exception E_STORAGE_FULL The disk space is full.
992 * @exception E_IO Either of the following conditions has occurred: @n
993 * - An unexpected device failure has occurred as the media ejected suddenly. @n
994 * - %File corruption is detected. @n
995 * - The number of opened files has exceeded the maximum limit.
997 static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer& key);
1001 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
1005 Registry(const Registry& source);
1008 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1012 Registry& operator =(const Registry& source);
1014 class _RegistryImpl* __pRegistryImpl;
1016 friend class _RegistryImpl;
1022 #endif //_FIO_REGISTRY_H_