2 // Open Service Platform
3 // Copyright (c) 2012 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.
20 * @brief This is the header file for the %Registry class.
22 * This header file contains the declarations of the %Registry class.
25 #ifndef _FIO_REGISTRY_H_
26 #define _FIO_REGISTRY_H_
28 #include <FBaseObject.h>
29 #include <FBaseUuId.h>
30 #include <FBaseByteBuffer.h>
31 #include <FBaseColArrayList.h>
32 #include <FBaseResult.h>
33 #include <FBaseColIMap.h>
34 #include <FIoFileLock.h>
36 namespace Tizen {namespace Base
42 namespace Tizen { namespace Io
45 static const long REG_OPEN_READ_ONLY = 0x00000001L;
46 static const long REG_OPEN_READ_WRITE = 0x00000002L;
47 static const long REG_OPEN_CREATE = 0x00000004L;
51 * @brief This class provides a mechanism to access and manipulate registry files.
55 * @final This class is not intended for extension.
57 * The %Registry class provides a mechanism to access and manipulate registry files.
59 * For more information on the class features,
60 * see <a href="../org.tizen.native.appprogramming/html/guide/io/io_namespace.htm">Io Guide</a>.
62 * The following example demonstrates how to use the %Registry class.
69 using namespace Tizen::Base;
70 using namespace Tizen::Io;
71 using namespace Tizen::App;
77 String regPathName(L"regTest.ini");
80 String sect1(L"section1");
81 String sect2(L"section2");
82 String sect3(L"section3");
85 String entry1(L"entry1");
86 String entry2(L"entry2");
91 r = reg.Construct(App::GetInstance()->GetAppDataPath() + regPathName, "a+");
98 r = reg.AddSection(sect1);
99 r = reg.AddSection(sect2);
100 r = reg.AddSection(sect3);
102 // Add value: section1 { entry1 = 999 }
103 r = reg.AddValue(sect1, entry1, 999);
109 // Change value: section1 { entry1 = 3 }
110 r = reg.SetValue(sect1, entry1, 3);
116 // Add value: section2 { entry2 = 1.1234599 }
117 r = reg.AddValue(sect2, entry2, 1.1234599);
123 // Get value: section1 { entry1 = ? }
124 r = reg.GetValue(sect1, entry1, iVal);
140 // Do some error handling
146 class _OSP_EXPORT_ Registry
147 : public Tizen::Base::Object
152 * 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.
159 * This destructor overrides Tizen::Base::Object::~Object().
163 virtual ~Registry(void);
168 * Initializes this instance of %Registry with the specified parameters. @n
169 * This method loads a registry file in the read-write mode.
172 * @brief <i> [Deprecated] [Compatibility] </i>
174 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
175 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
178 * @compatibility This method has compatibility issues with OSP compatible applications. @n
179 * For more information, see @ref CompIoPathPage "here".
182 * @return An error code
183 * @param[in] regPath The path of the registry file to open or create
184 * @param[in] createIfNotExist Set to @c true to create a registry file, @n
185 * else @c false to open an existing registry file
186 * @exception E_SUCCESS The method is successful.
187 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
188 * - The length of the specified string of a file path is less
189 * than or equal to @c 0. @n
190 * - The translated overall length of the specified path exceeds the
191 * system limitation. @n
192 * - The specified path is invalid. @n
193 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
194 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
195 * @exception E_END_OF_FILE The file pointer has reached end-of-file.
196 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
197 * @exception E_STORAGE_FULL The disk space is full.
198 * @exception E_IO Either of the following conditions has occurred: @n
199 * - An unexpected device failure has occurred as the media ejected suddenly. @n
200 * - %File corruption is detected.
201 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
202 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
203 * @remarks To load the registry in read-only mode, use the Registry::Construct(const Tizen::Base::String& regPath,
204 * long openMode, long option) method with REG_OPEN_READ_ONLY as a value for the open mode flag.
208 result Construct(const Tizen::Base::String& regPath, bool createIfNotExist);
213 * Initializes this instance of %Registry with the specified parameters. @n
214 * This method loads a registry file in the read-only or the read-write mode.
217 * @brief <i> [Deprecated] [Compatibility] </i>
219 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
220 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
223 * @compatibility This method has compatibility issues with OSP compatible applications. @n
224 * For more information, see @ref CompIoPathPage "here".
227 * @return An error code
228 * @param[in] regPath The path of the registry file to open or create
229 * @param[in] openMode An open mode flag @n
230 * Currently, the following flags can be used in combination with
231 * the logical OR operator: @n
232 * (1) REG_OPEN_READ_ONLY @n
233 * (2) REG_OPEN_READ_WRITE @n
234 * (3) REG_OPEN_READ_WRITE | REG_OPEN_CREATE
235 * @param[in] option This argument is reserved for further use @n It is recommended to use @c 0.
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
238 * - The length of the specified string of a file path is less
239 * than or equal to @c 0. @n
240 * - The translated overall length of the specified path exceeds the
241 * system limitation. @n
242 * - The specified path is invalid. @n
243 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
244 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
245 * @exception E_END_OF_FILE The file pointer has reached end-of-file.
246 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
247 * @exception E_STORAGE_FULL The disk space is full.
248 * @exception E_IO Either of the following conditions has occurred: @n
249 * - An unexpected device failure has occurred as the media ejected suddenly. @n
250 * - %File corruption is detected.
251 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
252 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
256 result Construct(const Tizen::Base::String& regPath, long openMode, long option);
259 * Initializes this instance of %Registry with the specified parameters. @n
260 * This method opens an existing registry file or creates a new one according to the specified file opening mode.
261 * And this method loads data of the registry file to system memory and flushes the data to the storage when this instance
262 * is released or Registry::Flush() is called.
266 * @return An error code
267 * @param[in] regPath The path of the registry file to open or create
268 * @param[in] pOpenMode The file opening mode @n
269 * It can be one of the following:
270 * - r : Open for reading.
271 * - r+: Open for reading and writing.
272 * - w : Open for writing. The registry file is created if it does not exist,
273 * otherwise it is truncated to zero length.
274 * - w+: Open for writing and reading. The registry file is created if it does not exist,
275 * otherwise it is truncated to zero length.
276 * - a : Open for writing. The registry file is created if it does not exist.
277 * - a+: Open for writing and reading. The registry file is created if it does not exist.
278 * @exception E_SUCCESS The method is successful.
279 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
280 * - The overall length of the specified @c regPath is equal to @c 0 or
281 * exceeds system limitations. @n
282 * - The combination of the specified @c pOpenMode is not allowed. @n
283 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
284 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
285 * @exception E_INVALID_FORMAT Either of the following conditions has occurred: @n
286 * - The section or entry name of the registry file includes one of the following characters:
287 * '\0', '\n', '#' and '='.
288 * - The entry value of the registry file includes one of the following characters:
290 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
291 * @exception E_STORAGE_FULL The disk space is full.
292 * @exception E_IO Either of the following conditions has occurred: @n
293 * - An unexpected device failure has occurred as the media ejected suddenly. @n
294 * - %File corruption is detected.
295 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
297 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode);
300 * Initializes this instance of %Registry with the specified parameters. @n
301 * This method opens an existing secure registry file or creates a new one according to the specified file opening mode.
302 * And this method loads data of the secure registry file to system memory and flushes the data to the storage when this instance
303 * is released or Registry::Flush() is called.
304 * The contents written to the secure registry file is automatically encrypted and the contents read from the secure registry
305 * file is automatically decrypted by the platform. @n
306 * Applications using this method can access the same secure registry files that are created by other applications with the
307 * identical key value in same device. However, the secure registry files created by this method cannot be accessed in other devices.
311 * @return An error code
312 * @param[in] regPath The path of the registry file to open or create
313 * @param[in] pOpenMode The file opening mode @n
314 * It can be one of the following:
315 * - r : Open for reading.
316 * - r+: Open for reading and writing.
317 * - w : Open for writing. The registry file is created if it does not exist,
318 * otherwise it is truncated to zero length.
319 * - w+: Open for writing and reading. The registry file is created if it does not exist,
320 * otherwise it is truncated to zero length.
321 * - a : Open for writing. The registry file is created if it does not exist.
322 * - a+: Open for writing and reading. The registry file is created if it does not exist.
323 * @param[in] secretKey A key used to encrypt data of a registry file or decrypt a secure registry file @n
324 * If a secure registry file is created with a specific key value,
325 * other applications can access the same secure registry file with the identical key value.
326 * @exception E_SUCCESS The method is successful.
327 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
328 * - The overall length of the specified path is equal to @c 0 or
329 * exceeds system limitations.
330 * - The combination of the specified @c pOpenMode is not allowed. @n
331 * - The specified @c secretKey is incorrect or the secure registry file is corrupted.
332 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
333 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
334 * @exception E_INVALID_FORMAT Either of the following conditions has occurred: @n
335 * - The section or entry name of the registry file includes one of the following characters:
336 * '\0', '\n', '#' and '='.
337 * - The entry value of the registry file includes one of the following characters:
339 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
340 * @exception E_STORAGE_FULL The disk space is full.
341 * @exception E_IO Either of the following conditions has occurred: @n
342 * - An unexpected device failure has occurred as the media ejected suddenly. @n
343 * - %File corruption is detected. @n
344 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
346 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
349 * Flushes the current contents of a registry in memory. @n
350 * If the secure mode is set to be @c true, the contents of the registry are automatically encrypted
351 * and saved by the platform.
355 * @return An error code
356 * @exception E_SUCCESS The method is successful.
357 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
358 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
359 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
360 * @exception E_STORAGE_FULL The disk space is full.
361 * @exception E_IO Either of the following conditions has occurred: @n
362 * - An unexpected device failure has occurred as the media ejected suddenly. @n
363 * - %File corruption is detected. @n
368 * Creates the specified section then adds it into the registry.
372 * @return An error code
373 * @param[in] sectionName The section name
374 * @exception E_SUCCESS The method is successful.
375 * @exception E_INVALID_ARG The length of the specified string for a section name is less than
377 * @exception E_SECTION_ALREADY_EXIST A section with the specified name already exists.
379 result AddSection(const Tizen::Base::String& sectionName);
382 * Removes the section from %Registry.
386 * @return An error code
387 * @param[in] sectionName The section name to remove
388 * @exception E_SUCCESS The method is successful.
389 * @exception E_INVALID_ARG The length of the specified string for a section is less than
391 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
393 result RemoveSection(const Tizen::Base::String& sectionName);
396 * Gets all section names in the registry.
400 * @return A list of section names @n
401 * If this method fails, @c null value is returned. @n
402 * The specific error code can be accessed using the GetLastResult() method. @n
403 * When there are no sections at all, the method returns an empty list instance. @n
404 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of elements in the list.
405 * @exception E_SUCCESS The method is successful.
406 * @remarks Do not forget to delete not only the returned IList instance, but also its
407 * contents by invoking IList::RemoveAll(). @n
408 * The specific error code can be accessed using the GetLastResult() method.
410 Tizen::Base::Collection::IList* GetAllSectionNamesN(void) const;
413 * Gets all entry names in the specified section of the registry.
417 * @return A list of entry names @n
418 * If this method fails, @c null value is returned. @n
419 * When there are no entries at all, the method returns an empty list instance. @n
420 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of element in the list.
421 * @param[in] sectionName The section name
422 * @exception E_SUCCESS The method is successful.
423 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
424 * @exception E_IO A system error has occurred.
425 * @remarks Do not forget to delete not only the returned IList instance, but also its
426 * contents by invoking IList::RemoveAll(). @n
427 * The specific error code can be accessed using the GetLastResult() method.
429 Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName) const;
432 * Adds the name-value pair of type integer as an entry of the specific section.
436 * @return An error code
437 * @param[in] sectionName The section name
438 * @param[in] entryName The entry name
439 * @param[in] value The @c int value
440 * @exception E_SUCCESS The method is successful.
441 * @exception E_INVALID_ARG Either the length of the specified string for a section
442 * or an entry is less than or equal to @c 0,
443 * or a @c null value is passed. @n
444 * Note that, it is also possible that the data inside a registry instance is
445 * corrupted due to its usage in a multi-threaded environment without
447 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
448 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
450 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int value);
453 * Adds the name-value pair of type double as an entry of the specific section.
457 * @return An error code
458 * @param[in] sectionName The section name
459 * @param[in] entryName The entry name
460 * @param[in] value The @c double value
461 * @exception E_SUCCESS The method is successful.
462 * @exception E_INVALID_ARG Either the length of the specified string for a section
463 * or an entry is less than or equal to @c 0,
464 * or a @c null value is passed. @n
465 * Note that, it is also possible that the data inside a registry instance is
466 * corrupted due to its usage in a multi-threaded environment without
468 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
469 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
471 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double value);
474 * Adds the name-value pair of type float as an entry of the specific section.
478 * @return An error code
479 * @param[in] sectionName The section name
480 * @param[in] entryName The entry name
481 * @param[in] value The @c float value
482 * @exception E_SUCCESS The method is successful.
483 * @exception E_INVALID_ARG Either the length of the specified string for a section
484 * or an entry is less than or equal to @c 0,
485 * or a @c null value is passed. @n
486 * Note that, it is also possible that the data inside a registry instance is
487 * corrupted due to its usage in a multi-threaded environment without
489 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
490 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
492 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float value);
495 * Adds the name-value pair of type String as an entry of the specific section.
499 * @return An error code
500 * @param[in] sectionName The section name
501 * @param[in] entryName The entry name
502 * @param[in] value The String value
503 * @exception E_SUCCESS The method is successful.
504 * @exception E_INVALID_ARG Either the length of the specified string for a section
505 * or an entry is less than or equal to @c 0.
506 * Note that, it is also possible that the data inside a registry instance is
507 * corrupted due to its usage in a multi-threaded environment without
509 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
510 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
512 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& value);
515 * Adds the name-value pair of type UuId as an entry for the specified section.
519 * @return An error code
520 * @param[in] sectionName The section name
521 * @param[in] entryName The entry name
522 * @param[in] value The UuId value
523 * @exception E_SUCCESS The method is successful.
524 * @exception E_INVALID_ARG Either the length of the specified string for a section
525 * or an entry is less than or equal to @c 0,
526 * or a @c null value is passed. @n
527 * Note that, it is also possible that the data inside a registry instance is
528 * corrupted due to its usage in a multi-threaded environment without
530 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
531 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
533 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& value);
536 * Adds the name-value pair of type ByteBuffer as an entry for the specified section.
540 * @return An error code
541 * @param[in] sectionName The section name
542 * @param[in] entryName The entry name
543 * @param[in] value The @c ByteBuffer value @n
544 * Note that, it should be constructed before being passed to the method.
545 * @exception E_SUCCESS The method is successful.
546 * @exception E_INVALID_ARG Either the length of the specified string for a section
547 * or an entry is less than or equal to @c 0,
548 * or a @c null value is passed. @n
549 * Note that, it is also possible that the data inside a registry instance is
550 * corrupted due to its usage in a multi-threaded environment without
552 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
553 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
554 * @remarks Note that all the contents of @c ByteBuffer are saved as an entry value.
555 * That is, byte data from @c 0 up to the buffer limit is saved.
556 * @see Tizen::Base::ByteBuffer
558 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& value);
561 * Gets the @c int value of the specified entry.
565 * @return An error code
566 * @param[in] sectionName The section name
567 * @param[in] entryName The name of entry where its value will be fetched
568 * @param[out] retVal The return value obtained from the registry
569 * @exception E_SUCCESS The method is successful.
570 * @exception E_INVALID_ARG Either the length of the specified string for a section
571 * or an entry is less than or equal to @c 0,
572 * or a @c null value is passed. @n
573 * Note that, it is also possible that the data inside a registry instance is
574 * corrupted due to its usage in a multi-threaded environment without
576 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
577 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
578 * @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.
579 * @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).
581 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int& retVal) const;
584 * Gets the @c double value of the specified entry.
588 * @return An error code
589 * @param[in] sectionName The section name
590 * @param[in] entryName The name of entry where its value will be fetched
591 * @param[out] retVal The return value obtained from the registry
592 * @exception E_SUCCESS The method is successful.
593 * @exception E_INVALID_ARG Either the length of the specified string for a section
594 * or an entry is less than or equal to @c 0,
595 * or a @c null value is passed. @n
596 * Note that, it is also possible that the data inside a registry instance is
597 * corrupted due to its usage in a multi-threaded environment without
599 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
600 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
601 * @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.
602 * @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).
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).
627 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float& retVal) const;
630 * Gets the String value of a specific entry.
634 * @return An error code
635 * @param[in] sectionName The section name
636 * @param[in] entryName The name of entry where its value will be fetched
637 * @param[out] retVal The return value obtained from the registry
638 * @exception E_SUCCESS The method is successful.
639 * @exception E_INVALID_ARG Either the length of the specified string for a section
640 * or an entry is less than or equal to @c 0,
641 * or a @c null value is passed. @n
642 * Note that, it is also possible that the data inside a registry instance is
643 * corrupted due to its usage in a multi-threaded environment without
645 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
646 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
647 * @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.
648 * @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).
650 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& retVal) const;
653 * Gets the UuId value of the specified entry.
657 * @return An error code
658 * @param[in] sectionName The section name
659 * @param[in] entryName The name of entry where its value will be fetched
660 * @param[out] retVal The return value obtained from the registry
661 * @exception E_SUCCESS The method is successful.
662 * @exception E_INVALID_ARG Either the length of the specified string for a section
663 * or an entry is less than or equal to @c 0,
664 * or a @c null value is passed. @n
665 * Note that, it is also possible that the data inside a registry instance is
666 * corrupted due to its usage in a multi-threaded environment without
668 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
669 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
670 * @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.
671 * @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).
673 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::UuId& retVal) const;
676 * Gets the ByteBuffer value of the specified entry.
680 * @return An error code
681 * @param[in] sectionName The section name
682 * @param[in] entryName The name of entry where its value will be fetched
683 * @param[out] retVal The return value obtained from the registry
684 * @exception E_SUCCESS The method is successful.
685 * @exception E_INVALID_ARG Either the length of the specified string for a section
686 * or an entry is less than or equal to @c 0,
687 * or a @c null value is passed. @n
688 * Note that, it is also possible that the data inside a registry instance is
689 * corrupted due to its usage in a multi-threaded environment without
691 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
692 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
693 * @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.
694 * @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).
695 * @remarks The ByteBuffer should be constructed before passing it to the method.
696 * That is, the size of the binary data to be fetched should be decided beforehand.
697 * When the %ByteBuffer capacity is less than the actual binary data stored in the registry,
698 * this method reads the data as much as the %ByteBuffer capacity. The position of the %ByteBuffer and
699 * limit are not changed. When the %ByteBuffer capacity is greater than the actual data size,
700 * the method reads the whole data and adjusts the limit of the buffer accordingly.
701 * @see Tizen::Base::ByteBuffer
703 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::ByteBuffer& retVal) const;
706 * Modifies the value of the specified entry using the specified @c int value.
710 * @return An error code
711 * @param[in] sectionName The section name
712 * @param[in] entryName The entry name to modify
713 * @param[in] newValue The @c int value
714 * @exception E_SUCCESS The method is successful.
715 * @exception E_INVALID_ARG Either the length of the specified string for a section
716 * or an entry is less than or equal to @c 0,
717 * or a @c null value is passed. @n
718 * Note that, it is also possible that the data inside a registry instance is
719 * corrupted due to its usage in a multi-threaded environment without
721 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
722 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
723 * @remarks This method will not add a name-value pair as an entry of a specific section
724 * if no entry with the specified name exists.
725 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
728 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int newValue);
731 * Modifies the value of the specified entry using the specified @c double value.
735 * @return An error code
736 * @param[in] sectionName The section name
737 * @param[in] entryName The entry name to modify
738 * @param[in] newValue The @c double value
739 * @exception E_SUCCESS The method is successful.
740 * @exception E_INVALID_ARG Either the length of the specified string for a section
741 * or an entry is less than or equal to @c 0,
742 * or a @c null value is passed. @n
743 * Note that, it is also possible that the data inside a registry instance is
744 * corrupted due to its usage in a multi-threaded environment without
746 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
747 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
748 * @remarks This method will not add a name-value pair as an entry of a specific section
749 * if no entry with the specified name exists.
750 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
753 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double newValue);
756 * Modifies the value of the specified entry using the specified @c float value.
760 * @return An error code
761 * @param[in] sectionName The section name
762 * @param[in] entryName The entry name to modify
763 * @param[in] newValue The @c float value
764 * @exception E_SUCCESS The method is successful.
765 * @exception E_INVALID_ARG Either the length of the specified string for a section
766 * or an entry is less than or equal to @c 0,
767 * or a @c null value is passed. @n
768 * Note that, it is also possible that the data inside a registry instance is
769 * corrupted due to its usage in a multi-threaded environment without
771 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
772 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
773 * @remarks This method will not add a name-value pair as an entry of a specific section
774 * if no entry with the specified name exists.
775 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
778 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float newValue);
781 * Modifies the value of the specified entry using the specified String value.
785 * @return An error code
786 * @param[in] sectionName The section name
787 * @param[in] entryName The entry name to modify
788 * @param[in] newValue The String value
789 * @exception E_SUCCESS The method is successful.
790 * @exception E_INVALID_ARG Either the length of the specified string for a section
791 * or an entry is less than or equal to @c 0.
792 * Note that, it is also possible that the data inside a registry instance is
793 * corrupted due to its usage in a multi-threaded environment without
795 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
796 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
797 * @remarks This method will not add a name-value pair as an entry of a specific section
798 * if no entry with the specified name exists.
799 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
802 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& newValue);
805 * Modifies the value of the specified entry using the specified UuID value.
809 * @return An error code
810 * @param[in] sectionName The section name
811 * @param[in] entryName The entry name to modify
812 * @param[in] newValue The UuId value
813 * @exception E_SUCCESS The method is successful.
814 * @exception E_INVALID_ARG Either the length of the specified string for a section
815 * or an entry is less than or equal to @c 0,
816 * or a @c null value is passed. @n
817 * Note that, it is also possible that the data inside a registry instance is
818 * corrupted due to its usage in a multi-threaded environment without
820 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
821 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
822 * @remarks This method will not add a name-value pair as an entry of a specific section if no
823 * entry with the specified name exists.
824 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
827 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& newValue);
830 * Modifies the value of the specified entry using the specified ByteBuffer value.
834 * @return An error code
835 * @param[in] sectionName The section name
836 * @param[in] entryName The entry name to modify
837 * @param[in] newValue The @c ByteBuffer value
838 * @exception E_SUCCESS The method is successful.
839 * @exception E_INVALID_ARG Either the length of the specified string for a section
840 * or an entry is less than or equal to @c 0,
841 * or a @c null value is passed. @n
842 * Note that, it is also possible that the data inside a registry instance is
843 * corrupted due to its usage in a multi-threaded environment without
845 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
846 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
847 * @remarks This method will not add a name-value pair as an entry of a specific section
848 * if no entry with the specified name exists.
849 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
852 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& newValue);
855 * Removes the name-value pair entry from specific section.
859 * @return An error code
860 * @param[in] sectionName The section name
861 * @param[in] entryName The entry name to remove
862 * @exception E_SUCCESS The method is successful.
863 * @exception E_INVALID_ARG The length of the specified string for a section or entry is less
864 * than or equal to @c 0.
865 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
866 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found within the registry.
868 result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
871 * Acquires the file lock on the current opened whole file if it is not acquired.
872 * If the file lock is already acquired by another process, the current process is blocked until the file lock is
877 * @return The pointer to %FileLock instance, @n
878 * else @c null pointer in case of failure
879 * @param[in] lockType The type of file lock to be created
880 * @exception E_SUCCESS The method is successful.
881 * @exception E_INVALID_ARG The specified @c lockType is invalid.
882 * @exception E_INVALID_OPERATION Either of the following conditions has occurred: @n
883 * - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
884 * file is not open for reading. @n
885 * - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
886 * file is not open for writing. @n
887 * @exception E_WOULD_DEADLOCK The method would cause a deadlock. @n
888 * The lock is blocked by a lock from another process, and putting the
889 * calling process to sleep to wait for that lock to become free would
891 * @exception E_MAX_EXCEEDED The number of file lock exceeds system limitations.
892 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
893 * @remarks The %FileLock instance is invalid if the associated %File instance is deleted. @n
894 * The specific error code can be accessed using the GetLastResult() method.
895 * @see Tizen::Io::File::FileLockType
897 FileLock* LockN(FileLockType lockType);
900 * Tries to acquire the file lock on the current opened whole file.
901 * If the file lock is already acquired by another process, E_OBJECT_LOCKED is returned.
905 * @return The pointer to %FileLock instance, @n
906 * else @c null pointer in case of failure
907 * @param[in] lockType The type of file lock to be created
908 * @exception E_SUCCESS The method is successful.
909 * @exception E_INVALID_ARG The specified @c lockType is invalid.
910 * @exception E_INVALID_OPERATION Either of the following conditions has occurred: @n
911 * - The specified @c lockType cannot be FILE_LOCK_SHARED if the current
912 * file is not open for reading. @n
913 * - The specified @c lockType cannot be FILE_LOCK_EXCLUSIVE if the current
914 * file is not open for writing. @n
915 * @exception E_OBJECT_LOCKED Either of the following conditions has occurred: @n
916 * - The file lock is already held by another process. @n
917 * - The file to be locked has been memory-mapped by another process.
918 * @exception E_MAX_EXCEEDED The number of file lock exceeds system limitations.
919 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
920 * @remarks The %FileLock instance is invalid if the associated %File instance is deleted. @n
921 * The specific error code can be accessed using the GetLastResult() method.
922 * @see Tizen::Io::File::FileLockType
924 FileLock* TryToLockN(FileLockType lockType);
927 * Removes the specified registry file.
930 * @brief <i> [Compatibility] </i>
934 * @compatibility This method has compatibility issues with OSP compatible applications. @n
935 * For more information, see @ref CompIoPathPage "here".
938 * @return An error code
939 * @param[in] regPath The path of the registry file to remove
940 * @exception E_SUCCESS The method is successful.
941 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
942 * - The length of the specified string of a file path is less
943 * than or equal to @c 0. @n
944 * - The translated overall length of the specified path exceeds the
945 * system limitation. @n
946 * - The specified path is invalid. @n
947 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
948 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
949 * @exception E_IO Either of the following conditions has occurred: @n
950 * - An unexpected device failure has occurred as the media ejected suddenly. @n
951 * - %File corruption is detected.
953 static result Remove(const Tizen::Base::String& regPath);
956 * Converts a normal registry file to a secure registry file. @n
957 * A secure registry file that is converted by this method can be shared among applications with the same key value.
960 * @brief <i> [Compatibility] </i>
964 * @compatibility This method has compatibility issues with OSP compatible applications. @n
965 * For more information, see @ref CompIoPathPage "here".
968 * @return An error code
969 * @param[in] plainRegPath The normal (non-encrypted) registry file path
970 * @param[in] secureRegPath The secure (encrypted) registry file path to create
971 * @param[in] key A key that encrypts a secure registry file @n
972 * If the secure registry file is converted with a specific key value,
973 * applications can access the same secure registry file with the identical key value.
974 * @exception E_SUCCESS The method is successful.
975 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
976 * - The length of the specified string of a file path is less
977 * than or equal to @c 0. @n
978 * - The translated overall length of the specified path exceeds the
979 * system limitation. @n
980 * - The specified path is invalid. @n
981 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
982 * @exception E_FILE_ALREADY_EXIST The specified file already exists.
983 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
984 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
985 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
986 * @exception E_STORAGE_FULL The disk space is full.
987 * @exception E_IO Either of the following conditions has occurred: @n
988 * - An unexpected device failure has occurred as the media ejected suddenly. @n
989 * - %File corruption is detected. @n
990 * - The number of opened files has exceeded the maximum limit.
992 static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer& key);
996 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
1000 Registry(const Registry& source);
1003 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1007 Registry& operator =(const Registry& source);
1009 class _RegistryImpl* __pRegistryImpl;
1011 friend class _RegistryImpl;
1017 #endif //_FIO_REGISTRY_H_