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 methods to access and manipulate registry files.
54 * @final This class is not intended for extension.
56 * The %Registry class provides methods 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. @n
152 * 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);
167 * Initializes this instance of %Registry with the specified parameters. @n
168 * This method loads a registry file in the read-write mode.
171 * @brief <i> [Deprecated] [Compatibility] </i>
173 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
174 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
177 * @compatibility This method has compatibility issues with OSP compatible applications. @n
178 * For more information, see @ref CompIoPathPage "here".
181 * @return An error code
182 * @param[in] regPath The path of the registry file to open or create
183 * @param[in] createIfNotExist Set to @c true to create a registry file, @n
184 * else @c false to open an existing registry file
185 * @exception E_SUCCESS The method is successful.
186 * @exception E_INVALID_ARG Either of the following conditions has occurred:
187 * - The length of the specified file path string is less
188 * than or equal to @c 0.
189 * - The overall length of the specified file path exceeds the
191 * - The specified file path is invalid.
192 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
193 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
194 * @exception E_END_OF_FILE The file pointer has reached the end of file.
195 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
196 * @exception E_STORAGE_FULL The disk space is full.
197 * @exception E_IO Either of the following conditions has occurred:
198 * - An unexpected device failure has occurred as the media ejected suddenly.
199 * - %File corruption is detected.
200 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
201 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
202 * @remarks To load the registry in read-only mode, use the Registry::Construct(const Tizen::Base::String& regPath,
203 * long openMode, long option) method with ::REG_OPEN_READ_ONLY as value for the open mode flag.
206 result Construct(const Tizen::Base::String& regPath, bool createIfNotExist);
210 * Initializes this instance of %Registry with the specified parameters. @n
211 * This method loads a registry file in the read-only or the read-write mode.
214 * @brief <i> [Deprecated] [Compatibility] </i>
216 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
217 * bool createParentDirectories=false) and Registry::Construct(const Tizen::Base::String& regPath, const Tizen::Base::String& openMode).
220 * @compatibility This method has compatibility issues with OSP compatible applications. @n
221 * For more information, see @ref CompIoPathPage "here".
224 * @return An error code
225 * @param[in] regPath The path of the registry file to open or create
226 * @param[in] openMode The flag specifying the file opening mode @n
227 * Currently, the following flags can be used in combination with
228 * the logical OR operator: @n
229 * (1) REG_OPEN_READ_ONLY @n
230 * (2) REG_OPEN_READ_WRITE @n
231 * (3) REG_OPEN_READ_WRITE | REG_OPEN_CREATE
232 * @param[in] option This argument is reserved for future use. @n It is recommended to use @c 0.
233 * @exception E_SUCCESS The method is successful.
234 * @exception E_INVALID_ARG Either of the following conditions has occurred:
235 * - The length of the specified file path string is less
236 * than or equal to @c 0.
237 * - The overall length of the specified file path exceeds the
239 * - The specified file path is invalid.
240 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
241 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
242 * @exception E_END_OF_FILE The file pointer has reached the end of file.
243 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
244 * @exception E_STORAGE_FULL The disk space is full.
245 * @exception E_IO Either of the following conditions has occurred:
246 * - An unexpected device failure has occurred as the media ejected suddenly.
247 * - %File corruption is detected.
248 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
249 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
252 result Construct(const Tizen::Base::String& regPath, long openMode, long option);
255 * Initializes this instance of %Registry with the specified parameters. @n
256 * This method opens an existing registry file or creates a new one according to the specified file opening mode,
257 * loads the data of the registry file to system memory, and flushes the data to the storage when this instance
258 * is released or Registry::Flush() is called.
262 * @return An error code
263 * @param[in] regPath The path of the registry file to open or create
264 * @param[in] pOpenMode The file opening mode @n
265 * It can be one of the following:
266 * - r : Open for reading.
267 * - r+: Open for reading and writing.
268 * - w : Open for writing. The registry file is created if it does not exist,
269 * otherwise it is truncated to zero length.
270 * - w+: Open for writing and reading. The registry file is created if it does not exist,
271 * otherwise it is truncated to zero length.
272 * - a : Open for writing. The registry file is created if it does not exist.
273 * - a+: Open for writing and reading. The registry file is created if it does not exist.
274 * @exception E_SUCCESS The method is successful.
275 * @exception E_INVALID_ARG Either of the following conditions has occurred:
276 * - The length of the specified file path string is less than or equal to @c 0.
277 * - The overall length of the specified file path exceeds the system limitation.
278 * - The combination of the specified @c pOpenMode is not allowed. @n
279 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
280 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
281 * @exception E_INVALID_FORMAT Either of the following conditions has occurred:
282 * - The section or entry name of the registry file includes one of the following characters:
283 * '\0', '\\n', '#' and '='.
284 * - The entry value of the registry file includes one of the following characters:
286 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
287 * @exception E_STORAGE_FULL The disk space is full.
288 * @exception E_IO Either of the following conditions has occurred:
289 * - An unexpected device failure has occurred as the media ejected suddenly.
290 * - %File corruption is detected.
291 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
293 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode);
296 * Initializes this instance of %Registry with the specified parameters. @n
297 * This method opens an existing secure registry file or creates a new one according to the specified file opening mode,
298 * loads the data of the secure registry file to system memory and flushes the data to the storage when this instance
299 * is released or Registry::Flush() is called.
300 * The contents written to the secure registry file is automatically encrypted and the contents read from the secure registry
301 * file is automatically decrypted by the platform. @n
302 * Applications that use this method can access the secure registry files that are created by other applications with
303 * an identical key value in the same device. However, the secure registry files created by this method cannot be accessed in other devices.
307 * @return An error code
308 * @param[in] regPath The path of the registry file to open or create
309 * @param[in] pOpenMode The file opening mode @n
310 * It can be one of the following:
311 * - r : Open for reading.
312 * - r+: Open for reading and writing.
313 * - w : Open for writing. The registry file is created if it does not exist,
314 * otherwise it is truncated to zero length.
315 * - w+: Open for writing and reading. The registry file is created if it does not exist,
316 * otherwise it is truncated to zero length.
317 * - a : Open for writing. The registry file is created if it does not exist.
318 * - a+: Open for writing and reading. The registry file is created if it does not exist.
319 * @param[in] secretKey The key to encrypt the data of the registry file or to decrypt the secure registry file @n
320 * If the secure registry file is created with a specific key value,
321 * other applications can access the secure registry file with an identical key value.
322 * @exception E_SUCCESS The method is successful.
323 * @exception E_INVALID_ARG Either of the following conditions has occurred:
324 * - The overall length of the specified path is equal to @c 0 or
325 * exceeds system limitations.
326 * - The combination of the specified @c pOpenMode is not allowed.
327 * - The specified @c secretKey is incorrect or the secure registry file is corrupted.
328 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
329 * @exception E_FILE_NOT_FOUND The specified @c regPath cannot be found.
330 * @exception E_INVALID_FORMAT Either of the following conditions has occurred:
331 * - The section or entry name of the registry file includes one of the following characters:
332 * '\0', '\\n', '#' and '='.
333 * - The entry value of the registry file includes one of the following characters:
335 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
336 * @exception E_STORAGE_FULL The disk space is full.
337 * @exception E_IO Either of the following conditions has occurred:
338 * - An unexpected device failure has occurred as the media ejected suddenly.
339 * - %File corruption is detected.
340 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
342 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
345 * Flushes the current contents of the registry in memory. @n
346 * If the secure mode is set, the contents of the registry are automatically encrypted
347 * and saved by the platform.
351 * @return An error code
352 * @exception E_SUCCESS The method is successful.
353 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
354 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
355 * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
356 * @exception E_STORAGE_FULL The disk space is full.
357 * @exception E_IO Either of the following conditions has occurred:
358 * - An unexpected device failure has occurred as the media ejected suddenly.
359 * - %File corruption is detected.
364 * Creates the specified section and adds it to the registry.
368 * @return An error code
369 * @param[in] sectionName The section name
370 * @exception E_SUCCESS The method is successful.
371 * @exception E_INVALID_ARG The length of the specified string for a section name is less than or equal to @c 0.
372 * @exception E_SECTION_ALREADY_EXIST The section with the specified name already exists.
374 result AddSection(const Tizen::Base::String& sectionName);
377 * Removes the section from the registry.
381 * @return An error code
382 * @param[in] sectionName The name of the section 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 or equal to @c 0.
385 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found within the registry.
387 result RemoveSection(const Tizen::Base::String& sectionName);
390 * Gets all the section names in the registry.
394 * @return The list of all section names in the registry @n
395 * If this method fails, @c null value is returned. @n
396 * When there are no sections, the method returns an empty list instance. @n
397 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of elements in the list.
398 * @exception E_SUCCESS The method is successful.
400 * - Do not forget to delete not only the returned Tizen::Base::Collection::IList instance, but also its contents by invoking IList::RemoveAll().
401 * - The specific error code can be accessed using the GetLastResult() method.
403 Tizen::Base::Collection::IList* GetAllSectionNamesN(void) const;
406 * Gets all the entry names in the specified section of the registry.
410 * @return The list of entry names @n
411 * If this method fails, @c null value is returned. @n
412 * When there are no entries, the method returns an empty list instance. @n
413 * Use the Tizen::Base::Collection::ICollection::GetCount() method to check the number of element in the list.
414 * @param[in] sectionName The section name
415 * @exception E_SUCCESS The method is successful.
416 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
417 * @exception E_IO A system error has occurred.
419 * - Do not forget to delete not only the returned Tizen::Base::Collection::IList instance, but also its contents by invoking IList::RemoveAll().
420 * - The specific error code can be accessed using the GetLastResult() method.
422 Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName) const;
425 * Adds the name and integer value as an entry of the specific section.
429 * @return An error code
430 * @param[in] sectionName The section name
431 * @param[in] entryName The entry name
432 * @param[in] value The @c int value
433 * @exception E_SUCCESS The method is successful.
434 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
435 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
436 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
438 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int value);
441 * Adds the name and double value as an entry of the specific section.
445 * @return An error code
446 * @param[in] sectionName The section name
447 * @param[in] entryName The entry name
448 * @param[in] value The @c double value
449 * @exception E_SUCCESS The method is successful.
450 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
451 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
452 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
453 * @remarks This method converts the specified double type @c value to string value using the "%lg" format specifier. @n
454 * It does not depend on the system locale.
456 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double value);
459 * Adds the name and float value as an entry of the specific section.
463 * @return An error code
464 * @param[in] sectionName The section name
465 * @param[in] entryName The entry name
466 * @param[in] value The @c float value
467 * @exception E_SUCCESS The method is successful.
468 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
469 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
470 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
471 * @remarks This method converts the specified float type @c value to string value using the "%g" format specifier. @n
472 * It does not depend on the system locale.
474 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float value);
477 * Adds the name and String value as an entry of the specific section.
481 * @return An error code
482 * @param[in] sectionName The section name
483 * @param[in] entryName The entry name
484 * @param[in] value The String value
485 * @exception E_SUCCESS The method is successful.
486 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
487 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
488 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
490 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& value);
493 * Adds the name and UuId value as an entry for the specified section.
497 * @return An error code
498 * @param[in] sectionName The section name
499 * @param[in] entryName The entry name
500 * @param[in] value The UuId value
501 * @exception E_SUCCESS The method is successful.
502 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
503 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
504 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
506 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& value);
509 * Adds the name and ByteBuffer value as an entry for the specified section.
513 * @return An error code
514 * @param[in] sectionName The section name
515 * @param[in] entryName The entry name
516 * @param[in] value The ByteBuffer value @n
517 * Note that, it should be constructed before being passed to the method.
518 * @exception E_SUCCESS The method is successful.
519 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
520 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
521 * @exception E_KEY_ALREADY_EXIST The specified @c entryName already exists in this section.
522 * @remarks All the contents of @c ByteBuffer are saved as an entry value. That is, byte data from @c 0 up to the buffer limit is saved.
523 * @see Tizen::Base::ByteBuffer
525 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& value);
528 * Gets the @c int value of the specified entry.
532 * @return An error code
533 * @param[in] sectionName The section name
534 * @param[in] entryName The entry name to get the value
535 * @param[out] retVal The return value obtained from the registry
536 * @exception E_SUCCESS The method is successful.
537 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
538 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
539 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
540 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
541 * - The method has failed to parse the encoded entry value string.
542 * - The specified data type of the value and the data type of the retrieved value are different.
543 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
544 * If the value is retrieved using the REGTYPE_STRING type,
545 * an empty string is returned even if no value is assigned.
547 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int& retVal) const;
550 * Gets the @c double value of the specified entry.
554 * @return An error code
555 * @param[in] sectionName The section name
556 * @param[in] entryName The entry name to get the value
557 * @param[out] retVal The return value obtained from the registry
558 * @exception E_SUCCESS The method is successful.
559 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
560 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
561 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
562 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
563 * - The method has failed to parse the encoded entry value string.
564 * - The specified data type of the value and the data type of the retrieved value are different.
565 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
566 * If the value is retrieved using the REGTYPE_STRING type,
567 * an empty string is returned even if no value is assigned.
568 * @remarks This method does not depend on the system locale.
570 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double& retVal) const;
573 * Gets the @c float value of the specified entry.
577 * @return An error code
578 * @param[in] sectionName The section name
579 * @param[in] entryName The entry name to get the value
580 * @param[out] retVal The return value obtained from the registry
581 * @exception E_SUCCESS The method is successful.
582 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
583 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
584 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
585 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
586 * - The method has failed to parse the encoded entry value string.
587 * - The specified data type of the value and the data type of the retrieved value are different.
588 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
589 * If the value is retrieved using the REGTYPE_STRING type,
590 * an empty string is returned even if no value is assigned.
591 * @remarks This method does not depend on the system locale.
593 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float& retVal) const;
596 * Gets the String value of a specific entry.
600 * @return An error code
601 * @param[in] sectionName The section name
602 * @param[in] entryName The entry name to get the value
603 * @param[out] retVal The return value obtained from the registry
604 * @exception E_SUCCESS The method is successful.
605 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
606 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
607 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
608 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
609 * - The method has failed to parse the encoded entry value string.
610 * - The specified data type of the value and the data type of the retrieved value are different.
611 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
612 * If the value is retrieved using the REGTYPE_STRING type,
613 * an empty string is returned even if no value is assigned.
615 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& retVal) const;
618 * Gets the UuId value of the specified entry.
622 * @return An error code
623 * @param[in] sectionName The section name
624 * @param[in] entryName The entry name to get the value
625 * @param[out] retVal The return value obtained from the registry
626 * @exception E_SUCCESS The method is successful.
627 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
628 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
629 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
630 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
631 * - The method has failed to parse the encoded entry value string.
632 * - The specified data type of the value and the data type of the retrieved value are different.
633 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
634 * If the value is retrieved using the REGTYPE_STRING type,
635 * an empty string is returned even if no value is assigned.
637 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::UuId& retVal) const;
640 * Gets the ByteBuffer value of the specified entry.
644 * @return An error code
645 * @param[in] sectionName The section name
646 * @param[in] entryName The entry name to get
647 * @param[out] retVal The return value obtained from the registry
648 * @exception E_SUCCESS The method is successful.
649 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
650 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
651 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
652 * @exception E_PARSING_FAILED Either of the following conditions has occurred:
653 * - The method has failed to parse the encoded entry value string.
654 * - The specified data type of the value and the data type of the retrieved value are different.
655 * @exception E_DATA_NOT_FOUND There is no value assigned for the specified entry name. @n
656 * If the value is retrieved using the REGTYPE_STRING type,
657 * an empty string is returned even if no value is assigned.
658 * @remarks Decide the size of the byte data to be fecthed and construct the Tizen::Base::ByteBuffer before passing it to the method. @n
659 * When the %Tizen::Base::ByteBuffer capacity is less than the actual binary data stored in the registry,
660 * this method reads data that fits the %Tizen::Base::ByteBuffer capacity. The position of the %Tizen::Base::ByteBuffer and
661 * limit are not changed. @n
662 * When the %Tizen::Base::ByteBuffer capacity is greater than the actual data size,
663 * the method reads the whole data and adjusts the limit of the buffer accordingly.
664 * @see Tizen::Base::ByteBuffer
666 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::ByteBuffer& retVal) const;
669 * Sets the @c int value for the specified entry.
673 * @return An error code
674 * @param[in] sectionName The section name
675 * @param[in] entryName The entry name to set the value
676 * @param[in] newValue The @c int value
677 * @exception E_SUCCESS The method is successful.
678 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
679 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
680 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
681 * @remarks This method will not set the specified value as an entry of the specific section
682 * if no entry with the specified name exists. @n
683 * In such a case, it returns @c E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
686 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, int newValue);
689 * Sets the @c double value for the specified entry.
693 * @return An error code
694 * @param[in] sectionName The section name
695 * @param[in] entryName The entry name to set the value
696 * @param[in] newValue The @c double value
697 * @exception E_SUCCESS The method is successful.
698 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
699 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
700 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
702 * - This method will not set the specified value as an entry of the specific section
703 * if no entry with the specified name exists. @n
704 * In such a case, it returns @c E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
705 * - This method converts the specified double type @c newValue to string value using the "%lg" format specifier. @n
706 * It does not depend on the system locale.
709 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double newValue);
712 * Sets the @c float value for the specified entry.
716 * @return An error code
717 * @param[in] sectionName The section name
718 * @param[in] entryName The entry name to set the value
719 * @param[in] newValue The @c float value
720 * @exception E_SUCCESS The method is successful.
721 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
722 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
723 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
725 * - This method will not set the specified value as an entry of the specific section
726 * if no entry with the specified name exists. @n
727 * In such a case, it returns @c E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
728 * - This method converts the specified float type @c newValue to string value using the "%g" format specifier. @n
729 * It does not depend on the system locale.
732 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float newValue);
735 * Sets the String value for the specified entry.
739 * @return An error code
740 * @param[in] sectionName The section name
741 * @param[in] entryName The entry name to set the value
742 * @param[in] newValue The String value
743 * @exception E_SUCCESS The method is successful.
744 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
745 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
746 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
747 * @remarks This method will not set the specified value as an entry of the specific section
748 * if no entry with the specified name exists. @n
749 * In such a case, it returns @c E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
752 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& newValue);
755 * Sets the UuId value for the specified entry.
759 * @return An error code
760 * @param[in] sectionName The section name
761 * @param[in] entryName The entry name to set the value
762 * @param[in] newValue The UuId value
763 * @exception E_SUCCESS The method is successful.
764 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
765 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
766 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
767 * @remarks This method will not set the specified value as an entry of the specific section
768 * if no entry with the specified name exists. @n
769 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
772 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::UuId& newValue);
775 * Sets the ByteBuffer value for the specified entry.
779 * @return An error code
780 * @param[in] sectionName The section name
781 * @param[in] entryName The entry name to set the value
782 * @param[in] newValue The @c ByteBuffer value
783 * @exception E_SUCCESS The method is successful.
784 * @exception E_INVALID_ARG The length of the specified section name or entry name is less than or equal to @c 0.
785 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
786 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
787 * @remarks This method will not set the specified value as an entry of the specific section
788 * if no entry with the specified name exists. @n
789 * In such a case, it returns E_KEY_NOT_FOUND. Use AddValue() to insert a new entry.
792 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::ByteBuffer& newValue);
795 * Removes the name-value pair entry from specified section.
799 * @return An error code
800 * @param[in] sectionName The section name
801 * @param[in] entryName The entry name to remove
802 * @exception E_SUCCESS The method is successful.
803 * @exception E_INVALID_ARG The length of the specified string for a section or entry is less
804 * than or equal to @c 0.
805 * @exception E_SECTION_NOT_FOUND The specified @c sectionName is not found in the registry.
806 * @exception E_KEY_NOT_FOUND The specified @c entryName is not found in the registry.
808 result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
811 * Acquires the file lock on the current opened whole file if it is not acquired.
812 * If the file lock is already acquired by another process, the current process is blocked until the file lock is
817 * @return The pointer to the FileLock instance, @n
818 * else @c null pointer in case of failure
819 * @param[in] lockType The file lock type to be created
820 * @exception E_SUCCESS The method is successful.
821 * @exception E_INVALID_ARG The specified @c lockType is invalid.
822 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
823 * - The specified @c lockType cannot be @c FILE_LOCK_SHARED if the current
824 * file is not open for reading.
825 * - The specified @c lockType cannot be @c FILE_LOCK_EXCLUSIVE if the current
826 * file is not open for writing.
827 * @exception E_WOULD_DEADLOCK The method would cause a deadlock. @n
828 * The lock is blocked by a lock from another process, and putting the
829 * calling process to sleep to wait for that lock to become free would
831 * @exception E_MAX_EXCEEDED The number of file locks has exceeded system limitations.
832 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
834 * - The FileLock instance is invalid if the associated %File instance is deleted.
835 * - The specific error code can be accessed using the GetLastResult() method.
837 FileLock* LockN(FileLockType lockType);
840 * Tries to acquire the file lock on the current opened whole file.
841 * If the file lock is already acquired by another process, @c E_OBJECT_LOCKED is returned.
845 * @return The pointer to the FileLock instance, @n
846 * else @c null pointer in case of failure
847 * @param[in] lockType The type of file lock to be created
848 * @exception E_SUCCESS The method is successful.
849 * @exception E_INVALID_ARG The specified @c lockType is invalid.
850 * @exception E_INVALID_OPERATION Either of the following conditions has occurred:
851 * - The specified @c lockType cannot be @c FILE_LOCK_SHARED if the current
852 * file is not open for reading.
853 * - The specified @c lockType cannot be @c FILE_LOCK_EXCLUSIVE if the current
854 * file is not open for writing.
855 * @exception E_OBJECT_LOCKED Either of the following conditions has occurred:
856 * - The file lock is already held by another process.
857 * - The file to be locked has been memory-mapped by another process.
858 * @exception E_MAX_EXCEEDED The number of file locks has exceeded system limitations.
859 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
861 * - The FileLock instance is invalid if the associated %File instance is deleted.
862 * - The specific error code can be accessed using the GetLastResult() method.
864 FileLock* TryToLockN(FileLockType lockType);
867 * Removes the specified registry file.
870 * @brief <i> [Compatibility] </i>
874 * @compatibility This method has compatibility issues with OSP compatible applications. @n
875 * For more information, see @ref CompIoPathPage "here".
878 * @return An error code
879 * @param[in] regPath The path of the registry file to remove
880 * @exception E_SUCCESS The method is successful.
881 * @exception E_INVALID_ARG Either of the following conditions has occurred:
882 * - The length of the specified string of a file path is less
883 * than or equal to @c 0.
884 * - The overall length of the specified path exceeds the
886 * - The specified path is invalid.
887 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
888 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
889 * @exception E_IO Either of the following conditions has occurred:
890 * - An unexpected device failure has occurred as the media ejected suddenly.
891 * - %File corruption is detected.
893 static result Remove(const Tizen::Base::String& regPath);
896 * Converts a normal registry file to a secure registry file. @n
897 * A secure registry file that is converted by this method can be shared among applications with the same key value.
900 * @brief <i> [Compatibility] </i>
904 * @compatibility This method has compatibility issues with OSP compatible applications. @n
905 * For more information, see @ref CompIoPathPage "here".
908 * @return An error code
909 * @param[in] plainRegPath The normal (non-encrypted) registry file path
910 * @param[in] secureRegPath The secure (encrypted) registry file path to create
911 * @param[in] key The key that encrypts the secure registry file @n
912 * If the secure registry file is converted with the specific key value,
913 * applications can access the same secure registry file with an identical key value.
914 * @exception E_SUCCESS The method is successful.
915 * @exception E_INVALID_ARG Either of the following conditions has occurred:
916 * - The length of the specified string of a file path is less
917 * than or equal to @c 0.
918 * - The overall length of the specified path exceeds the
920 * - The specified path is invalid.
921 * @exception E_ILLEGAL_ACCESS The access is denied due to insufficient permission.
922 * @exception E_FILE_ALREADY_EXIST The specified file already exists.
923 * @exception E_FILE_NOT_FOUND An entry for the specified file or path cannot be found.
924 * @exception E_INVALID_FORMAT The input registry file contains '0x00' in the middle of the file.
925 * @exception E_PARSING_FAILED The method has failed to parse the registry file.
926 * @exception E_STORAGE_FULL The disk space is full.
927 * @exception E_IO Either of the following conditions has occurred:
928 * - An unexpected device failure has occurred as the media ejected suddenly.
929 * - %File corruption is detected.
930 * - The number of opened files has exceeded the maximum limit.
932 static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer& key);
936 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
940 Registry(const Registry& source);
943 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
947 Registry& operator =(const Registry& source);
949 class _RegistryImpl* __pRegistryImpl;
951 friend class _RegistryImpl;
957 #endif //_FIO_REGISTRY_H_