File: DesktopEntryKeyPath.h

package info (click to toggle)
xdg-utils-cxx 1.0.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 456 kB
  • sloc: cpp: 2,461; ansic: 10; makefile: 6
file content (91 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (2)
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
#pragma once

// system
#include <string>
#include <memory>

// local
#include <XdgUtils/DesktopEntry/Exceptions.h>
#include <ostream>

namespace XdgUtils {
    namespace DesktopEntry {
        /**
         * Utility class to parse, validate and extract Key Paths sections.
         *
         * A KeyPath has the following format:
         * <group>/<key>[<locale>]
         */
        class DesktopEntryKeyPath {
        public:
            explicit DesktopEntryKeyPath(const std::string& path);

            DesktopEntryKeyPath(const std::string& group, const std::string& key, const std::string& locale);

            DesktopEntryKeyPath(const DesktopEntryKeyPath& other);

            DesktopEntryKeyPath& operator=(const DesktopEntryKeyPath& other);

            DesktopEntryKeyPath& operator=(const std::string& path);

            virtual ~DesktopEntryKeyPath();

            bool operator==(const DesktopEntryKeyPath& rhs) const;

            bool operator!=(const DesktopEntryKeyPath& rhs) const;

            bool operator==(const std::string& path) const;

            bool operator!=(const std::string& path) const;

            friend std::ostream& operator<<(std::ostream& os, const DesktopEntryKeyPath& path);

            /**
             * @return group section of the KeyPath
             */
            std::string group() const;

            /**
             * Set group section of the path
             * @param group
             */
            void setGroup(const std::string& group);

            /**
             * @return key section of the KeyPath or empty string if none
             */
            std::string key() const;

            /**
             * Set the key section of the path
             * @param key
             */
            void setKey(const std::string& key);

            /**
             * @return locale section of the KeyPath or empty string if none
             */
            std::string locale() const;

            /**
             * Set the locale section of the path
             * @param locale
             */
            void setLocale(const std::string& locale);

            /**
             * @return key and locale sections
             */
            std::string fullKey() const;

            /**
             * @return string representation of the KeyPath
             */
            std::string string() const;

        private:
            struct Priv;
            std::unique_ptr<Priv> priv;
        };
    }
}