summaryrefslogtreecommitdiffhomepage
path: root/public/frameworks/CoreFoundation.fwrk/headers/Property.h
blob: c49b7660deb429de46b55939ad80d19f59136feb (plain)
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
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/ne-foss-org/nekernel

#ifndef HEADERS_PROPERTY_H
#define HEADERS_PROPERTY_H

#include <CoreFoundation.fwrk/headers/Foundation.h>
#include <CoreFoundation.fwrk/headers/Ref.h>
#include <libSystem/SystemKit/System.h>

#define kCFMaxPropLen (256U)

namespace CF {
class CFString;
class CFProperty;

template <class Cls, SizeT N>
class CFArray;

/// ================================================================================
/// @brief handle to anything (number, ptr, string...)
/// ================================================================================
using CFPropertyId = UIntPtr;

/// ================================================================================
/// @brief User property class.
/// @note /prop/foo or /prop/bar are properties.
/// ================================================================================
class CFProperty final CF_OBJECT {
 public:
  CFProperty(CFRef<CFGuid> guid, CFString& name, CFPropertyId value);
  ~CFProperty() override = default;

 public:
  CFProperty& operator=(const CFProperty&) = default;
  CFProperty(const CFProperty&)            = default;

  Bool          StringEquals(CFString& name);
  CFPropertyId& GetValue();
  CFString&     GetKey();

 private:
  CFString*     fName{nullptr};
  CFPropertyId  fValue{0UL};
  CFRef<CFGuid> fGUID{};
};

template <SizeT N>
using CFPropertyArray = CFArray<CFProperty, N>;
}  // namespace CF

#endif