/usr/include/glibmm-2.4/glibmm/keyfile.h is in libglibmm-2.4-dev 2.50.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | // Generated by gmmproc 2.50.0 -- DO NOT MODIFY!
#ifndef _GLIBMM_KEYFILE_H
#define _GLIBMM_KEYFILE_H
/* Copyright(C) 2006 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <glibmmconfig.h>
#include <glibmm/ustring.h>
#include <glibmm/arrayhandle.h>
#include <glibmm/error.h>
#include <glibmm/utility.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef struct _GKeyFile GKeyFile; }
#endif
namespace Glib
{
/** @addtogroup glibmmEnums glibmm Enums and Flags */
/**
* @var KeyFileFlags KEY_FILE_NONE
* No flags, default behaviour.
*
* @var KeyFileFlags KEY_FILE_KEEP_COMMENTS
* Use this flag if you plan to write the
* (possibly modified) contents of the key file back to a file;
* otherwise all comments will be lost when the key file is
* written back.
*
* @var KeyFileFlags KEY_FILE_KEEP_TRANSLATIONS
* Use this flag if you plan to write the
* (possibly modified) contents of the key file back to a file;
* otherwise only the translations for the current language will be
* written back.
*
* @enum KeyFileFlags
*
* Flags which influence the parsing.
*
* @ingroup glibmmEnums
* @par Bitwise operators:
* <tt>%KeyFileFlags operator|(KeyFileFlags, KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags operator&(KeyFileFlags, KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags operator^(KeyFileFlags, KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags operator~(KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags& operator|=(KeyFileFlags&, KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags& operator&=(KeyFileFlags&, KeyFileFlags)</tt><br>
* <tt>%KeyFileFlags& operator^=(KeyFileFlags&, KeyFileFlags)</tt><br>
*/
enum KeyFileFlags
{
KEY_FILE_NONE = 0x0,
KEY_FILE_KEEP_COMMENTS = 1 << 0,
KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
};
/** @ingroup glibmmEnums */
inline KeyFileFlags operator|(KeyFileFlags lhs, KeyFileFlags rhs)
{ return static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
/** @ingroup glibmmEnums */
inline KeyFileFlags operator&(KeyFileFlags lhs, KeyFileFlags rhs)
{ return static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
/** @ingroup glibmmEnums */
inline KeyFileFlags operator^(KeyFileFlags lhs, KeyFileFlags rhs)
{ return static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
/** @ingroup glibmmEnums */
inline KeyFileFlags operator~(KeyFileFlags flags)
{ return static_cast<KeyFileFlags>(~static_cast<unsigned>(flags)); }
/** @ingroup glibmmEnums */
inline KeyFileFlags& operator|=(KeyFileFlags& lhs, KeyFileFlags rhs)
{ return (lhs = static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
/** @ingroup glibmmEnums */
inline KeyFileFlags& operator&=(KeyFileFlags& lhs, KeyFileFlags rhs)
{ return (lhs = static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
/** @ingroup glibmmEnums */
inline KeyFileFlags& operator^=(KeyFileFlags& lhs, KeyFileFlags rhs)
{ return (lhs = static_cast<KeyFileFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
/** %Exception class for KeyFile errors.
*/
class KeyFileError : public Glib::Error
{
public:
/** @var Code UNKNOWN_ENCODING
* The text being parsed was in
* an unknown encoding.
*
* @var Code PARSE
* Document was ill-formed.
*
* @var Code NOT_FOUND
* The file was not found.
*
* @var Code KEY_NOT_FOUND
* A requested key was not found.
*
* @var Code GROUP_NOT_FOUND
* A requested group was not found.
*
* @var Code INVALID_VALUE
* A value could not be parsed.
*
* @enum Code
*
* %Error codes returned by key file parsing.
*/
enum Code
{
UNKNOWN_ENCODING,
PARSE,
NOT_FOUND,
KEY_NOT_FOUND,
GROUP_NOT_FOUND,
INVALID_VALUE
};
KeyFileError(Code error_code, const Glib::ustring& error_message);
explicit KeyFileError(GError* gobject);
Code code() const;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
private:
static void throw_func(GError* gobject);
friend void wrap_init(); // uses throw_func()
#endif //DOXYGEN_SHOULD_SKIP_THIS
};
/** This class lets you parse, edit or create files containing groups of key-value pairs, which we call key files
* for lack of a better name. Several freedesktop.org specifications use key files now, e.g the Desktop Entry
* Specification and the Icon Theme Specification.
*
* The syntax of key files is described in detail in the Desktop Entry Specification, here is a quick summary: Key
* files consists of groups of key-value pairs, interspersed with comments.
*
* @code
* # this is just an example
* # there can be comments before the first group
*
* [First Group]
*
* Name=Key File Example\tthis value shows\nescaping
*
* # localized strings are stored in multiple key-value pairs
* Welcome=Hello
* Welcome[de]=Hallo
* Welcome[fr]=Bonjour
* Welcome[it]=Ciao
*
* [Another Group]
*
* Numbers=2;20;-200;0
*
* Booleans=true;false;true;true
* @endcode
*
* Lines beginning with a '#' and blank lines are considered comments.
*
* Groups are started by a header line containing the group name enclosed in '[' and ']', and ended implicitly by
* the start of the next group or the end of the file. Each key-value pair must be contained in a group.
*
* Key-value pairs generally have the form key=value, with the exception of localized strings, which have the form
* key[locale]=value. Space before and after the '=' character are ignored. Newline, tab, carriage return and
* backslash characters in value are escaped as \\n, \\t, \\r, and \\\\, respectively. To preserve leading spaces in
* values, these can also be escaped as \\s.
*
* Key files can store strings (possibly with localized variants), integers, booleans and lists of these. Lists are
* separated by a separator character, typically ';' or ','. To use the list separator character in a value in a
* list, it has to be escaped by prefixing it with a backslash.
*
* This syntax is obviously inspired by the .ini files commonly met on Windows, but there are some important
* differences:
* - .ini files use the ';' character to begin comments, key files use the '#' character.
* - Key files allow only comments before the first group.
* - Key files are always encoded in UTF-8.
* - Key and Group names are case-sensitive, for example a group called [GROUP] is a different group from [group].
*
* Note that in contrast to the Desktop Entry Specification, groups in key files may contain the same key multiple
* times; the last entry wins. Key files may also contain multiple groups with the same name; they are merged
* together. Another difference is that keys and group names in key files are not restricted to ASCII characters.
*
* @newin{2,14}
*/
class KeyFile
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = KeyFile;
using BaseObjectType = GKeyFile;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
private:
public:
//TODO: GKeyFile now seems to be a reference-counted type.
//TODO: Maybe replace all the get_*/set_* methods with some generic get/set
//methods when it is possible.
/** Creates a new, empty KeyFile object.
*/
KeyFile();
KeyFile(const KeyFile&) = delete;
KeyFile& operator=(const KeyFile&) = delete;
KeyFile(KeyFile&& other) noexcept;
KeyFile& operator=(KeyFile&& other) noexcept;
/** Destructor
*/
~KeyFile();
/** Creates a glibmm KeyFile wrapper for a GKeyFile object.
* Note, when using this that when the wrapper is deleted,
* it will not automatically delete the GKeyFile unless you
* set the @a takes_ownership boolean to <tt>true</tt>.
* @param castitem The C instance to wrap.
* @param takes_ownership If the C instance should be deleted when
* the wrapper is deleted.
*/
KeyFile(GKeyFile* castitem, bool takes_ownership = false);
public:
/** Loads a key file into an empty KeyFile instance.
* If the file could not be loaded then a FileError or KeyFileError exception is thrown.
*
* @newin{2,6}
*
* \throw Glib::FileError
* \throw Glib::KeyFileError
*
* @param file The path of a filename to load, in the GLib filename encoding.
* @param flags Flags from KeyFileFlags.
* @return <tt>true</tt> if a key file could be loaded, <tt>false</tt> otherwise.
*/
bool load_from_file(const std::string& file, KeyFileFlags flags = Glib::KEY_FILE_NONE);
/** Loads a KeyFile from memory
* @param data The data to use as a KeyFile
* @param flags Bitwise combination of the flags to use for the KeyFile
* @return true if the KeyFile was successfully loaded, false otherwise
* @throw Glib::KeyFileError
*/
bool load_from_data(const Glib::ustring& data, KeyFileFlags flags = Glib::KEY_FILE_NONE);
#ifndef GLIBMM_DISABLE_DEPRECATED
/** This function looks for a key file named @a file in the paths
* specified in @a search_dirs, loads the file into @a key_file and
* returns the file's full path in @a full_path. If the file could not
* be loaded then an %error is set to either a FileError or
* KeyFileError.
*
* @newin{2,14}
*
* @deprecated Use the load_from_dirs() method that takes a std::string& full_path.
*
* @param file A relative path to a filename to open and parse.
* @param search_dirs <tt>nullptr</tt>-terminated array of directories to search.
* @param full_path Return location for a string containing the full path
* of the file, or <tt>nullptr</tt>.
* @param flags Flags from KeyFileFlags.
* @return <tt>true</tt> if a key file could be loaded, <tt>false</tt> otherwise.
*/
bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, Glib::ArrayHandle<std::string>& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE);
#endif // GLIBMM_DISABLE_DEPRECATED
/** This function looks for a key file named @a file in the paths
* specified in @a search_dirs, loads the file into @a key_file and
* returns the file's full path in @a full_path. If the file could not
* be loaded then an %error is set to either a FileError or
* KeyFileError.
*
* @newin{2,14}
*
* @param file A relative path to a filename to open and parse.
* @param search_dirs <tt>nullptr</tt>-terminated array of directories to search.
* @param full_path Return location for a string containing the full path
* of the file, or <tt>nullptr</tt>.
* @param flags Flags from KeyFileFlags.
* @return <tt>true</tt> if a key file could be loaded, <tt>false</tt> otherwise.
*/
bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, std::string& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE);
/** Looks for a KeyFile named @a file in the paths returned from
* g_get_user_data_dir() and g_get_system_data_dirs() and loads them
* into the keyfile object, placing the full path to the file in
* @a full_path.
* @param file The file to search for
* @param full_path Return location for a string containing the full path of the file
* @param flags Bitwise combination of the flags to use for the KeyFile
* @return true if the KeyFile was successfully loaded, false otherwise
* @throw Glib::KeyFileError
* @throw Glib::FileError
*/
bool load_from_data_dirs(const std::string& file, std::string& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE);
/** Outputs the KeyFile as a string
* @return A string object holding the contents of KeyFile
* @throw Glib::KeyFileError
*/
Glib::ustring to_data();
/** Writes the contents of @a key_file to @a filename using
* g_file_set_contents().
*
* This function can fail for any of the reasons that
* g_file_set_contents() may fail.
*
* @newin{2,40}
*
* @param filename The name of the file to write to.
* @return <tt>true</tt> if successful, else <tt>false</tt> with @a error set.
*/
bool save_to_file(const std::string& filename);
/** Returns the name of the start group of the file.
*
* @newin{2,6}
*
* @return The start group of the key file.
*/
Glib::ustring get_start_group() const;
/** Gets a list of all groups in the KeyFile
* @returns A list containing the names of the groups
*/
Glib::ArrayHandle<Glib::ustring> get_groups() const;
/** Gets a list of all keys from the group @a group_name.
* @param group_name The name of a group
* @returns A list containing the names of the keys in @a group_name
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<Glib::ustring> get_keys(const Glib::ustring& group_name) const;
/** Looks whether the key file has the group @a group_name.
*
* @newin{2,6}
*
* @param group_name A group name.
* @return <tt>true</tt> if @a group_name is a part of @a key_file, <tt>false</tt>
* otherwise.
*/
bool has_group(const Glib::ustring& group_name) const;
/** Looks whether the key file has the key @a key in the group
* @a group_name.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key name.
* @return <tt>true</tt> if @a key is a part of @a group_name, <tt>false</tt> otherwise.
*/
bool has_key(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Returns the value associated with @a key under @a group_name.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError in the event the key cannot be found (with the Glib::KeyFileError::KEY_NOT_FOUND code).
* \throw Glib::KeyFileError in the event that the @a group_name cannot be found (with the Glib::KeyFileError::GROUP_NOT_FOUND code).
*
* @param group_name A group name.
* @param key A key.
* @return The value as a string.
*/
Glib::ustring get_value(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Return value: a newly allocated string or <tt>nullptr</tt>.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @return A newly allocated string or <tt>nullptr</tt> if the specified
* key cannot be found.
*/
Glib::ustring get_string(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Gets the value associated with @a key under @a group_name translated
* into the current locale.
* @return the value as a Glib::ustring
* @throw Glib::KeyFileError
*/
Glib::ustring get_locale_string(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Return value: a newly allocated string or <tt>nullptr</tt>.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @param locale A locale identifier or <tt>nullptr</tt>.
* @return A newly allocated string or <tt>nullptr</tt> if the specified
* key cannot be found.
*/
Glib::ustring get_locale_string(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale) const;
/** Gets the value in the first group, under @a key, interpreting it as
* a boolean.
* @param key The name of the key.
* @return The value of @a key as a boolean.
* @throw Glib::KeyFileError.
* @newin{2,6}
*/
bool get_boolean(const Glib::ustring& key) const;
/** Return value: the value associated with the key as a boolean.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @return The value associated with the key as a boolean,
* or <tt>false</tt> if the key was not found or could not be parsed.
*/
bool get_boolean(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Gets the value in the first group, under @a key, interpreting it as
* an integer.
* @param key The name of the key
* @return The value of @a key as an integer
* @throw Glib::KeyFileError
* @newin{2,6}
*/
int get_integer(const Glib::ustring& key) const;
/** Return value: the value associated with the key as an integer.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @return The value associated with the key as an integer, or
* 0 if the key was not found or could not be parsed.
*/
int get_integer(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Gets the value in the first group, under @a key, interpreting it as
* a signed 64-bit integer. This is similar to get_integer() but can return
* 64-bit results without truncation.
* @param key The name of the key.
* @return The value of @a key as a signed 64-bit integer, or <tt>0</tt> if
* the key was not found or could not be parsed.
* @throw Glib::KeyFileError.
* @newin{2,28}
*/
gint64 get_int64(const Glib::ustring& key) const;
/** Returns the value associated with @a key under @a group_name as a signed
* 64-bit integer. This is similar to g_key_file_get_integer() but can return
* 64-bit results without truncation.
*
* @newin{2,26}
*
* @param group_name A non-<tt>nullptr</tt> group name.
* @param key A non-<tt>nullptr</tt> key.
* @return The value associated with the key as a signed 64-bit integer, or
* 0 if the key was not found or could not be parsed.
*/
gint64 get_int64(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Gets the value in the first group, under @a key, interpreting it as
* an unsigned 64-bit integer. This is similar to get_integer() but can
* return large positive results without truncation.
* @param key The name of the key.
* @return The value of @a key as an unsigned 64-bit integer, or <tt>0</tt>
* if the key was not found or could not be parsed.
* @throw Glib::KeyFileError.
* @newin{2,28}
*/
guint64 get_uint64(const Glib::ustring& key) const;
/** Returns the value associated with @a key under @a group_name as an unsigned
* 64-bit integer. This is similar to g_key_file_get_integer() but can return
* large positive results without truncation.
*
* @newin{2,26}
*
* @param group_name A non-<tt>nullptr</tt> group name.
* @param key A non-<tt>nullptr</tt> key.
* @return The value associated with the key as an unsigned 64-bit integer,
* or 0 if the key was not found or could not be parsed.
*/
guint64 get_uint64(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Gets the value in the first group, under @a key, interpreting it as
* a double.
* @param key The name of the key
* @return The value of @a key as an double
* @throw Glib::KeyFileError
*
* @newin{2,14}
*/
double get_double(const Glib::ustring& key) const;
/** Return value: the value associated with the key as a double.
*
* @newin{2,14}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @return The value associated with the key as a double, or
* 0.0 if the key was not found or could not be parsed.
*/
double get_double(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Associates a new double value with @a key under @a group_name.
* If @a key cannot be found then it is created.
*
* @newin{2,12}
*
* @param group_name A group name.
* @param key A key.
* @param value An double value.
*/
void set_double(const Glib::ustring& group_name, const Glib::ustring& key, double value);
/** Associates a new double value with @a key under the start group.
* If @a key cannot be found then it is created.
*
* @newin{2,12}
*
* @param key A key.
* @param value An double value.
*/
void set_double(const Glib::ustring& key, double value);
/** Returns the values associated with @a key under @a group_name
* @param group_name The name of a group
* @param key The name of a key
* @return A list containing the values requested
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<Glib::ustring> get_string_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Returns the values associated with @a key under @a group_name
* translated into the current locale, if available.
* @param group_name The name of a group
* @param key The name of a key
* @return A list containing the values requested
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Returns the values associated with @a key under @a group_name
* translated into @a locale, if available.
* @param group_name The name of a group
* @param key The name of a key
* @param locale The name of a locale
* @return A list containing the values requested
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale) const;
/** Returns the values associated with @a key under @a group_name
* @param group_name The name of a group
* @param key The name of a key
* @return A list of booleans
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<bool> get_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Returns the values associated with @a key under @a group_name
* @param group_name The name of a group
* @param key The name of a key
* @return A list of integers
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<int> get_integer_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Returns the values associated with @a key under @a group_name
* @param group_name The name of a group
* @param key The name of a key
* @return A list of doubles
* @throw Glib::KeyFileError
*/
Glib::ArrayHandle<double> get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Get comment from top of file
* @return The comment
* @throw Glib::KeyFileError
*/
Glib::ustring get_comment() const;
/** Get comment from above a group
* @param group_name The group
* @return The comment
* @throw Glib::KeyFileError
*/
Glib::ustring get_comment(const Glib::ustring& group_name) const;
/** Retrieves a comment above @a key from @a group_name.
* If @a key is <tt>nullptr</tt> then @a comment will be read from above
* @a group_name. If both @a key and @a group_name are <tt>nullptr</tt>, then
* @a comment will be read from above the first group in the file.
* Use the overrides for a <tt>nullptr</tt> @a key or @a group.
*
* @newin{2,6}
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key.
* @return The comment.
*/
Glib::ustring get_comment(const Glib::ustring& group_name, const Glib::ustring& key) const;
/** Sets the character which is used to separate
* values in lists. Typically ';' or ',' are used
* as separators. The default list separator is ';'.
*
* @newin{2,6}
*
* @param separator The separator.
*/
void set_list_separator(gchar separator);
/** Associates a new value with @a key under @a group_name.
*
* If @a key cannot be found then it is created. If @a group_name cannot
* be found then it is created. To set an UTF-8 string which may contain
* characters that need escaping (such as newlines or spaces), use
* g_key_file_set_string().
*
* @newin{2,6}
*
* @param group_name A group name.
* @param key A key.
* @param value A string.
*/
void set_value(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& value);
/** Associates a new string value with @a key under @a group_name.
* If @a key cannot be found then it is created.
* If @a group_name cannot be found then it is created.
* Unlike g_key_file_set_value(), this function handles characters
* that need escaping, such as newlines.
*
* @newin{2,6}
*
* @param group_name A group name.
* @param key A key.
* @param string A string.
*/
void set_string(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& string);
/** Associates a string value for @a key and @a locale under @a group_name.
* If the translation for @a key cannot be found then it is created.
*
* @newin{2,6}
*
* @param group_name A group name.
* @param key A key.
* @param locale A locale identifier.
* @param string A string.
*/
void set_locale_string(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale, const Glib::ustring& string);
/** Associates a new boolean value with @a key under @a group_name.
* If @a key cannot be found then it is created.
*
* @newin{2,6}
*
* @param group_name A group name.
* @param key A key.
* @param value <tt>true</tt> or <tt>false</tt>.
*/
void set_boolean(const Glib::ustring& group_name, const Glib::ustring& key, bool value);
/** Associates a new integer value with @a key under @a group_name.
* If @a key cannot be found then it is created.
*
* @newin{2,6}
*
* @param group_name A group name.
* @param key A key.
* @param value An integer value.
*/
void set_integer(const Glib::ustring& group_name, const Glib::ustring& key, int value);
/** Associates a new integer value with @a key under @a group_name.
* If @a key cannot be found then it is created.
*
* @newin{2,26}
*
* @param group_name A group name.
* @param key A key.
* @param value An integer value.
*/
void set_int64(const Glib::ustring& group_name, const Glib::ustring& key, gint64 value);
/** Associates a new integer value with @a key under @a group_name.
* If @a key cannot be found then it is created.
*
* @newin{2,26}
*
* @param group_name A group name.
* @param key A key.
* @param value An integer value.
*/
void set_uint64(const Glib::ustring& group_name, const Glib::ustring& key, guint64 value);
/** Sets a list of string values for @a key under @a group_name. If
* key cannot be found it is created. If @a group_name cannot be found
* it is created.
* @param group_name The name of a group
* @param key The name of a key
* @param list A list holding objects of type Glib::ustring
*/
void set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<Glib::ustring>& list);
/** Sets a list of string values for the @a key under @a group_name and marks
* them as being for @a locale. If the @a key or @a group_name cannot be
* found, they are created.
* @param group_name The name of a group
* @param key The name of a key
* @param locale A locale
* @param list A list holding objects of type Glib::ustring
*/
void set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale, const Glib::ArrayHandle<Glib::ustring>& list);
/** Sets a list of booleans for the @a key under @a group_name.
* If either the @a key or @a group_name cannot be found they are created.
* @param group_name The name of a group
* @param key The name of a key
* @param list A list holding object of type bool
*/
void set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<bool>& list);
/** Sets a list of integers for the @a key under @a group_name.
* If either the @a key or @a group_name cannot be found they are created.
* @param group_name The name of a group
* @param key The name of a key
* @param list A list holding object of type int
*/
void set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<int>& list);
/** Sets a list of doubles for the @a key under @a group_name.
* If either the @a key or @a group_name cannot be found they are created.
* @param group_name The name of a group
* @param key The name of a key
* @param list A list holding object of type int
*
* @newin{2,14}
*/
void set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<double>& list);
/** Places @a comment at the start of the file, before the first group.
* @param comment The Comment
* @throw Glib::KeyFileError
*/
void set_comment(const Glib::ustring& comment);
/** Places @a comment above @a group_name.
* @param group_name The Group the comment should be above
* @param comment The comment
* @throw Glib::KeyFileError
*/
void set_comment(const Glib::ustring& group_name, const Glib::ustring& comment);
/** Places a comment above @a key from @a group_name.
* If @a key is <tt>nullptr</tt> then @a comment will be written above @a group_name.
* If both @a key and @a group_name are <tt>nullptr</tt>, then @a comment will be
* written above the first group in the file.
*
* \throw Glib::KeyFileError
*
* @param group_name A group name, or <tt>nullptr</tt>.
* @param key A key.
* @param comment A comment.
*/
void set_comment(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& comment);
/** Removes a comment above @a key from @a group_name.
* If @a key is <tt>nullptr</tt> then @a comment will be removed above @a group_name.
* If both @a key and @a group_name are <tt>nullptr</tt>, then @a comment will
* be removed above the first group in the file.
*
* \throw Glib::KeyFileError
*
* @param group_name A group name, or <tt>nullptr</tt>.
* @param key A key.
*/
void remove_comment(const Glib::ustring& group_name, const Glib::ustring& key);
/** Removes @a key in @a group_name from the key file.
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
* @param key A key name to remove.
*/
void remove_key(const Glib::ustring& group_name, const Glib::ustring& key);
/** Removes the specified group, @a group_name,
* from the key file.
*
* \throw Glib::KeyFileError
*
* @param group_name A group name.
*/
void remove_group(const Glib::ustring& group_name);
GKeyFile* gobj() { return gobject_; }
const GKeyFile* gobj() const { return gobject_; }
protected:
GKeyFile* gobject_;
bool owns_gobject_;
};
} // namespace Glib
#endif /* _GLIBMM_KEYFILE_H */
|