Path: blob/master/thirdparty/metal-cpp/Foundation/NSDictionary.hpp
21066 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Foundation/NSDictionary.hpp3//4// Copyright 2020-2024 Apple Inc.5//6// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.17//18//-------------------------------------------------------------------------------------------------------------------------------------------------------------1920#pragma once2122//-------------------------------------------------------------------------------------------------------------------------------------------------------------2324#include "NSEnumerator.hpp"25#include "NSObject.hpp"26#include "NSTypes.hpp"2728//-------------------------------------------------------------------------------------------------------------------------------------------------------------2930namespace NS31{32class Dictionary : public NS::Copying<Dictionary>33{34public:35static Dictionary* dictionary();36static Dictionary* dictionary(const Object* pObject, const Object* pKey);37static Dictionary* dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count);3839static Dictionary* alloc();4041Dictionary* init();42Dictionary* init(const Object* const* pObjects, const Object* const* pKeys, UInteger count);43Dictionary* init(const class Coder* pCoder);4445template <class _KeyType = Object>46Enumerator<_KeyType>* keyEnumerator() const;4748template <class _Object = Object>49_Object* object(const Object* pKey) const;50UInteger count() const;51};52}5354//-------------------------------------------------------------------------------------------------------------------------------------------------------------5556_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary()57{58return Object::sendMessage<Dictionary*>(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionary));59}6061//-------------------------------------------------------------------------------------------------------------------------------------------------------------6263_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* pObject, const Object* pKey)64{65return Object::sendMessage<Dictionary*>(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObject_forKey_), pObject, pKey);66}6768//-------------------------------------------------------------------------------------------------------------------------------------------------------------6970_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count)71{72return Object::sendMessage<Dictionary*>(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObjects_forKeys_count_),73pObjects, pKeys, count);74}7576//-------------------------------------------------------------------------------------------------------------------------------------------------------------7778_NS_INLINE NS::Dictionary* NS::Dictionary::alloc()79{80return NS::Object::alloc<Dictionary>(_NS_PRIVATE_CLS(NSDictionary));81}8283//-------------------------------------------------------------------------------------------------------------------------------------------------------------8485_NS_INLINE NS::Dictionary* NS::Dictionary::init()86{87return NS::Object::init<Dictionary>();88}8990//-------------------------------------------------------------------------------------------------------------------------------------------------------------9192_NS_INLINE NS::Dictionary* NS::Dictionary::init(const Object* const* pObjects, const Object* const* pKeys, UInteger count)93{94return Object::sendMessage<Dictionary*>(this, _NS_PRIVATE_SEL(initWithObjects_forKeys_count_), pObjects, pKeys, count);95}9697//-------------------------------------------------------------------------------------------------------------------------------------------------------------9899_NS_INLINE NS::Dictionary* NS::Dictionary::init(const class Coder* pCoder)100{101return Object::sendMessage<Dictionary*>(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder);102}103104//-------------------------------------------------------------------------------------------------------------------------------------------------------------105106template <class _KeyType>107_NS_INLINE NS::Enumerator<_KeyType>* NS::Dictionary::keyEnumerator() const108{109return Object::sendMessage<Enumerator<_KeyType>*>(this, _NS_PRIVATE_SEL(keyEnumerator));110}111112//-------------------------------------------------------------------------------------------------------------------------------------------------------------113114template <class _Object>115_NS_INLINE _Object* NS::Dictionary::object(const Object* pKey) const116{117return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectForKey_), pKey);118}119120//-------------------------------------------------------------------------------------------------------------------------------------------------------------121122_NS_INLINE NS::UInteger NS::Dictionary::count() const123{124return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(count));125}126127//-------------------------------------------------------------------------------------------------------------------------------------------------------------128129130