GPBDictionary.h 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #import <Foundation/Foundation.h>
  31. #import "GPBRuntimeTypes.h"
  32. // These classes are used for map fields of basic data types. They are used because
  33. // they perform better than boxing into NSNumbers in NSDictionaries.
  34. // Note: These are not meant to be subclassed.
  35. NS_ASSUME_NONNULL_BEGIN
  36. //%PDDM-EXPAND DECLARE_DICTIONARIES()
  37. // This block of code is generated, do not edit it directly.
  38. #pragma mark - UInt32 -> UInt32
  39. @interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
  40. @property(nonatomic, readonly) NSUInteger count;
  41. + (instancetype)dictionary;
  42. + (instancetype)dictionaryWithValue:(uint32_t)value
  43. forKey:(uint32_t)key;
  44. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  45. forKeys:(const uint32_t [])keys
  46. count:(NSUInteger)count;
  47. + (instancetype)dictionaryWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
  48. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  49. - (instancetype)initWithValues:(const uint32_t [])values
  50. forKeys:(const uint32_t [])keys
  51. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  52. - (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
  53. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  54. - (BOOL)valueForKey:(uint32_t)key value:(nullable uint32_t *)value;
  55. - (void)enumerateKeysAndValuesUsingBlock:
  56. (void (^)(uint32_t key, uint32_t value, BOOL *stop))block;
  57. - (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;
  58. - (void)setValue:(uint32_t)value forKey:(uint32_t)key;
  59. - (void)removeValueForKey:(uint32_t)aKey;
  60. - (void)removeAll;
  61. @end
  62. #pragma mark - UInt32 -> Int32
  63. @interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
  64. @property(nonatomic, readonly) NSUInteger count;
  65. + (instancetype)dictionary;
  66. + (instancetype)dictionaryWithValue:(int32_t)value
  67. forKey:(uint32_t)key;
  68. + (instancetype)dictionaryWithValues:(const int32_t [])values
  69. forKeys:(const uint32_t [])keys
  70. count:(NSUInteger)count;
  71. + (instancetype)dictionaryWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
  72. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  73. - (instancetype)initWithValues:(const int32_t [])values
  74. forKeys:(const uint32_t [])keys
  75. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  76. - (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
  77. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  78. - (BOOL)valueForKey:(uint32_t)key value:(nullable int32_t *)value;
  79. - (void)enumerateKeysAndValuesUsingBlock:
  80. (void (^)(uint32_t key, int32_t value, BOOL *stop))block;
  81. - (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;
  82. - (void)setValue:(int32_t)value forKey:(uint32_t)key;
  83. - (void)removeValueForKey:(uint32_t)aKey;
  84. - (void)removeAll;
  85. @end
  86. #pragma mark - UInt32 -> UInt64
  87. @interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
  88. @property(nonatomic, readonly) NSUInteger count;
  89. + (instancetype)dictionary;
  90. + (instancetype)dictionaryWithValue:(uint64_t)value
  91. forKey:(uint32_t)key;
  92. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  93. forKeys:(const uint32_t [])keys
  94. count:(NSUInteger)count;
  95. + (instancetype)dictionaryWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
  96. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  97. - (instancetype)initWithValues:(const uint64_t [])values
  98. forKeys:(const uint32_t [])keys
  99. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  100. - (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
  101. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  102. - (BOOL)valueForKey:(uint32_t)key value:(nullable uint64_t *)value;
  103. - (void)enumerateKeysAndValuesUsingBlock:
  104. (void (^)(uint32_t key, uint64_t value, BOOL *stop))block;
  105. - (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;
  106. - (void)setValue:(uint64_t)value forKey:(uint32_t)key;
  107. - (void)removeValueForKey:(uint32_t)aKey;
  108. - (void)removeAll;
  109. @end
  110. #pragma mark - UInt32 -> Int64
  111. @interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
  112. @property(nonatomic, readonly) NSUInteger count;
  113. + (instancetype)dictionary;
  114. + (instancetype)dictionaryWithValue:(int64_t)value
  115. forKey:(uint32_t)key;
  116. + (instancetype)dictionaryWithValues:(const int64_t [])values
  117. forKeys:(const uint32_t [])keys
  118. count:(NSUInteger)count;
  119. + (instancetype)dictionaryWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
  120. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  121. - (instancetype)initWithValues:(const int64_t [])values
  122. forKeys:(const uint32_t [])keys
  123. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  124. - (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
  125. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  126. - (BOOL)valueForKey:(uint32_t)key value:(nullable int64_t *)value;
  127. - (void)enumerateKeysAndValuesUsingBlock:
  128. (void (^)(uint32_t key, int64_t value, BOOL *stop))block;
  129. - (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;
  130. - (void)setValue:(int64_t)value forKey:(uint32_t)key;
  131. - (void)removeValueForKey:(uint32_t)aKey;
  132. - (void)removeAll;
  133. @end
  134. #pragma mark - UInt32 -> Bool
  135. @interface GPBUInt32BoolDictionary : NSObject <NSCopying>
  136. @property(nonatomic, readonly) NSUInteger count;
  137. + (instancetype)dictionary;
  138. + (instancetype)dictionaryWithValue:(BOOL)value
  139. forKey:(uint32_t)key;
  140. + (instancetype)dictionaryWithValues:(const BOOL [])values
  141. forKeys:(const uint32_t [])keys
  142. count:(NSUInteger)count;
  143. + (instancetype)dictionaryWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
  144. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  145. - (instancetype)initWithValues:(const BOOL [])values
  146. forKeys:(const uint32_t [])keys
  147. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  148. - (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
  149. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  150. - (BOOL)valueForKey:(uint32_t)key value:(nullable BOOL *)value;
  151. - (void)enumerateKeysAndValuesUsingBlock:
  152. (void (^)(uint32_t key, BOOL value, BOOL *stop))block;
  153. - (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;
  154. - (void)setValue:(BOOL)value forKey:(uint32_t)key;
  155. - (void)removeValueForKey:(uint32_t)aKey;
  156. - (void)removeAll;
  157. @end
  158. #pragma mark - UInt32 -> Float
  159. @interface GPBUInt32FloatDictionary : NSObject <NSCopying>
  160. @property(nonatomic, readonly) NSUInteger count;
  161. + (instancetype)dictionary;
  162. + (instancetype)dictionaryWithValue:(float)value
  163. forKey:(uint32_t)key;
  164. + (instancetype)dictionaryWithValues:(const float [])values
  165. forKeys:(const uint32_t [])keys
  166. count:(NSUInteger)count;
  167. + (instancetype)dictionaryWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
  168. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  169. - (instancetype)initWithValues:(const float [])values
  170. forKeys:(const uint32_t [])keys
  171. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  172. - (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
  173. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  174. - (BOOL)valueForKey:(uint32_t)key value:(nullable float *)value;
  175. - (void)enumerateKeysAndValuesUsingBlock:
  176. (void (^)(uint32_t key, float value, BOOL *stop))block;
  177. - (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;
  178. - (void)setValue:(float)value forKey:(uint32_t)key;
  179. - (void)removeValueForKey:(uint32_t)aKey;
  180. - (void)removeAll;
  181. @end
  182. #pragma mark - UInt32 -> Double
  183. @interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
  184. @property(nonatomic, readonly) NSUInteger count;
  185. + (instancetype)dictionary;
  186. + (instancetype)dictionaryWithValue:(double)value
  187. forKey:(uint32_t)key;
  188. + (instancetype)dictionaryWithValues:(const double [])values
  189. forKeys:(const uint32_t [])keys
  190. count:(NSUInteger)count;
  191. + (instancetype)dictionaryWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
  192. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  193. - (instancetype)initWithValues:(const double [])values
  194. forKeys:(const uint32_t [])keys
  195. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  196. - (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
  197. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  198. - (BOOL)valueForKey:(uint32_t)key value:(nullable double *)value;
  199. - (void)enumerateKeysAndValuesUsingBlock:
  200. (void (^)(uint32_t key, double value, BOOL *stop))block;
  201. - (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;
  202. - (void)setValue:(double)value forKey:(uint32_t)key;
  203. - (void)removeValueForKey:(uint32_t)aKey;
  204. - (void)removeAll;
  205. @end
  206. #pragma mark - UInt32 -> Enum
  207. @interface GPBUInt32EnumDictionary : NSObject <NSCopying>
  208. @property(nonatomic, readonly) NSUInteger count;
  209. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  210. + (instancetype)dictionary;
  211. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  212. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  213. rawValue:(int32_t)rawValue
  214. forKey:(uint32_t)key;
  215. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  216. rawValues:(const int32_t [])values
  217. forKeys:(const uint32_t [])keys
  218. count:(NSUInteger)count;
  219. + (instancetype)dictionaryWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
  220. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  221. capacity:(NSUInteger)numItems;
  222. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  223. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  224. rawValues:(const int32_t [])values
  225. forKeys:(const uint32_t [])keys
  226. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  227. - (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
  228. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  229. capacity:(NSUInteger)numItems;
  230. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  231. // is not a valid enumerator as defined by validationFunc. If the actual value is
  232. // desired, use "raw" version of the method.
  233. - (BOOL)valueForKey:(uint32_t)key value:(nullable int32_t *)value;
  234. - (void)enumerateKeysAndValuesUsingBlock:
  235. (void (^)(uint32_t key, int32_t value, BOOL *stop))block;
  236. // These methods bypass the validationFunc to provide access to values that were not
  237. // known at the time the binary was compiled.
  238. - (BOOL)valueForKey:(uint32_t)key rawValue:(nullable int32_t *)rawValue;
  239. - (void)enumerateKeysAndRawValuesUsingBlock:
  240. (void (^)(uint32_t key, int32_t rawValue, BOOL *stop))block;
  241. - (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;
  242. // If value is not a valid enumerator as defined by validationFunc, these
  243. // methods will assert in debug, and will log in release and assign the value
  244. // to the default value. Use the rawValue methods below to assign non enumerator
  245. // values.
  246. - (void)setValue:(int32_t)value forKey:(uint32_t)key;
  247. // This method bypass the validationFunc to provide setting of values that were not
  248. // known at the time the binary was compiled.
  249. - (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;
  250. // No validation applies to these methods.
  251. - (void)removeValueForKey:(uint32_t)aKey;
  252. - (void)removeAll;
  253. @end
  254. #pragma mark - UInt32 -> Object
  255. @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  256. @property(nonatomic, readonly) NSUInteger count;
  257. + (instancetype)dictionary;
  258. + (instancetype)dictionaryWithObject:(ObjectType)object
  259. forKey:(uint32_t)key;
  260. + (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  261. forKeys:(const uint32_t [])keys
  262. count:(NSUInteger)count;
  263. + (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
  264. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  265. - (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  266. forKeys:(const uint32_t [])keys
  267. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  268. - (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
  269. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  270. - (ObjectType)objectForKey:(uint32_t)key;
  271. - (void)enumerateKeysAndObjectsUsingBlock:
  272. (void (^)(uint32_t key, ObjectType object, BOOL *stop))block;
  273. - (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
  274. - (void)setObject:(ObjectType)object forKey:(uint32_t)key;
  275. - (void)removeObjectForKey:(uint32_t)aKey;
  276. - (void)removeAll;
  277. @end
  278. #pragma mark - Int32 -> UInt32
  279. @interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
  280. @property(nonatomic, readonly) NSUInteger count;
  281. + (instancetype)dictionary;
  282. + (instancetype)dictionaryWithValue:(uint32_t)value
  283. forKey:(int32_t)key;
  284. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  285. forKeys:(const int32_t [])keys
  286. count:(NSUInteger)count;
  287. + (instancetype)dictionaryWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
  288. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  289. - (instancetype)initWithValues:(const uint32_t [])values
  290. forKeys:(const int32_t [])keys
  291. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  292. - (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
  293. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  294. - (BOOL)valueForKey:(int32_t)key value:(nullable uint32_t *)value;
  295. - (void)enumerateKeysAndValuesUsingBlock:
  296. (void (^)(int32_t key, uint32_t value, BOOL *stop))block;
  297. - (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;
  298. - (void)setValue:(uint32_t)value forKey:(int32_t)key;
  299. - (void)removeValueForKey:(int32_t)aKey;
  300. - (void)removeAll;
  301. @end
  302. #pragma mark - Int32 -> Int32
  303. @interface GPBInt32Int32Dictionary : NSObject <NSCopying>
  304. @property(nonatomic, readonly) NSUInteger count;
  305. + (instancetype)dictionary;
  306. + (instancetype)dictionaryWithValue:(int32_t)value
  307. forKey:(int32_t)key;
  308. + (instancetype)dictionaryWithValues:(const int32_t [])values
  309. forKeys:(const int32_t [])keys
  310. count:(NSUInteger)count;
  311. + (instancetype)dictionaryWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
  312. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  313. - (instancetype)initWithValues:(const int32_t [])values
  314. forKeys:(const int32_t [])keys
  315. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  316. - (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
  317. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  318. - (BOOL)valueForKey:(int32_t)key value:(nullable int32_t *)value;
  319. - (void)enumerateKeysAndValuesUsingBlock:
  320. (void (^)(int32_t key, int32_t value, BOOL *stop))block;
  321. - (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;
  322. - (void)setValue:(int32_t)value forKey:(int32_t)key;
  323. - (void)removeValueForKey:(int32_t)aKey;
  324. - (void)removeAll;
  325. @end
  326. #pragma mark - Int32 -> UInt64
  327. @interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
  328. @property(nonatomic, readonly) NSUInteger count;
  329. + (instancetype)dictionary;
  330. + (instancetype)dictionaryWithValue:(uint64_t)value
  331. forKey:(int32_t)key;
  332. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  333. forKeys:(const int32_t [])keys
  334. count:(NSUInteger)count;
  335. + (instancetype)dictionaryWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
  336. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  337. - (instancetype)initWithValues:(const uint64_t [])values
  338. forKeys:(const int32_t [])keys
  339. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  340. - (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
  341. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  342. - (BOOL)valueForKey:(int32_t)key value:(nullable uint64_t *)value;
  343. - (void)enumerateKeysAndValuesUsingBlock:
  344. (void (^)(int32_t key, uint64_t value, BOOL *stop))block;
  345. - (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;
  346. - (void)setValue:(uint64_t)value forKey:(int32_t)key;
  347. - (void)removeValueForKey:(int32_t)aKey;
  348. - (void)removeAll;
  349. @end
  350. #pragma mark - Int32 -> Int64
  351. @interface GPBInt32Int64Dictionary : NSObject <NSCopying>
  352. @property(nonatomic, readonly) NSUInteger count;
  353. + (instancetype)dictionary;
  354. + (instancetype)dictionaryWithValue:(int64_t)value
  355. forKey:(int32_t)key;
  356. + (instancetype)dictionaryWithValues:(const int64_t [])values
  357. forKeys:(const int32_t [])keys
  358. count:(NSUInteger)count;
  359. + (instancetype)dictionaryWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
  360. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  361. - (instancetype)initWithValues:(const int64_t [])values
  362. forKeys:(const int32_t [])keys
  363. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  364. - (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
  365. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  366. - (BOOL)valueForKey:(int32_t)key value:(nullable int64_t *)value;
  367. - (void)enumerateKeysAndValuesUsingBlock:
  368. (void (^)(int32_t key, int64_t value, BOOL *stop))block;
  369. - (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;
  370. - (void)setValue:(int64_t)value forKey:(int32_t)key;
  371. - (void)removeValueForKey:(int32_t)aKey;
  372. - (void)removeAll;
  373. @end
  374. #pragma mark - Int32 -> Bool
  375. @interface GPBInt32BoolDictionary : NSObject <NSCopying>
  376. @property(nonatomic, readonly) NSUInteger count;
  377. + (instancetype)dictionary;
  378. + (instancetype)dictionaryWithValue:(BOOL)value
  379. forKey:(int32_t)key;
  380. + (instancetype)dictionaryWithValues:(const BOOL [])values
  381. forKeys:(const int32_t [])keys
  382. count:(NSUInteger)count;
  383. + (instancetype)dictionaryWithDictionary:(GPBInt32BoolDictionary *)dictionary;
  384. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  385. - (instancetype)initWithValues:(const BOOL [])values
  386. forKeys:(const int32_t [])keys
  387. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  388. - (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
  389. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  390. - (BOOL)valueForKey:(int32_t)key value:(nullable BOOL *)value;
  391. - (void)enumerateKeysAndValuesUsingBlock:
  392. (void (^)(int32_t key, BOOL value, BOOL *stop))block;
  393. - (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;
  394. - (void)setValue:(BOOL)value forKey:(int32_t)key;
  395. - (void)removeValueForKey:(int32_t)aKey;
  396. - (void)removeAll;
  397. @end
  398. #pragma mark - Int32 -> Float
  399. @interface GPBInt32FloatDictionary : NSObject <NSCopying>
  400. @property(nonatomic, readonly) NSUInteger count;
  401. + (instancetype)dictionary;
  402. + (instancetype)dictionaryWithValue:(float)value
  403. forKey:(int32_t)key;
  404. + (instancetype)dictionaryWithValues:(const float [])values
  405. forKeys:(const int32_t [])keys
  406. count:(NSUInteger)count;
  407. + (instancetype)dictionaryWithDictionary:(GPBInt32FloatDictionary *)dictionary;
  408. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  409. - (instancetype)initWithValues:(const float [])values
  410. forKeys:(const int32_t [])keys
  411. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  412. - (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
  413. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  414. - (BOOL)valueForKey:(int32_t)key value:(nullable float *)value;
  415. - (void)enumerateKeysAndValuesUsingBlock:
  416. (void (^)(int32_t key, float value, BOOL *stop))block;
  417. - (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;
  418. - (void)setValue:(float)value forKey:(int32_t)key;
  419. - (void)removeValueForKey:(int32_t)aKey;
  420. - (void)removeAll;
  421. @end
  422. #pragma mark - Int32 -> Double
  423. @interface GPBInt32DoubleDictionary : NSObject <NSCopying>
  424. @property(nonatomic, readonly) NSUInteger count;
  425. + (instancetype)dictionary;
  426. + (instancetype)dictionaryWithValue:(double)value
  427. forKey:(int32_t)key;
  428. + (instancetype)dictionaryWithValues:(const double [])values
  429. forKeys:(const int32_t [])keys
  430. count:(NSUInteger)count;
  431. + (instancetype)dictionaryWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
  432. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  433. - (instancetype)initWithValues:(const double [])values
  434. forKeys:(const int32_t [])keys
  435. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  436. - (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
  437. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  438. - (BOOL)valueForKey:(int32_t)key value:(nullable double *)value;
  439. - (void)enumerateKeysAndValuesUsingBlock:
  440. (void (^)(int32_t key, double value, BOOL *stop))block;
  441. - (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;
  442. - (void)setValue:(double)value forKey:(int32_t)key;
  443. - (void)removeValueForKey:(int32_t)aKey;
  444. - (void)removeAll;
  445. @end
  446. #pragma mark - Int32 -> Enum
  447. @interface GPBInt32EnumDictionary : NSObject <NSCopying>
  448. @property(nonatomic, readonly) NSUInteger count;
  449. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  450. + (instancetype)dictionary;
  451. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  452. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  453. rawValue:(int32_t)rawValue
  454. forKey:(int32_t)key;
  455. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  456. rawValues:(const int32_t [])values
  457. forKeys:(const int32_t [])keys
  458. count:(NSUInteger)count;
  459. + (instancetype)dictionaryWithDictionary:(GPBInt32EnumDictionary *)dictionary;
  460. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  461. capacity:(NSUInteger)numItems;
  462. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  463. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  464. rawValues:(const int32_t [])values
  465. forKeys:(const int32_t [])keys
  466. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  467. - (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
  468. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  469. capacity:(NSUInteger)numItems;
  470. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  471. // is not a valid enumerator as defined by validationFunc. If the actual value is
  472. // desired, use "raw" version of the method.
  473. - (BOOL)valueForKey:(int32_t)key value:(nullable int32_t *)value;
  474. - (void)enumerateKeysAndValuesUsingBlock:
  475. (void (^)(int32_t key, int32_t value, BOOL *stop))block;
  476. // These methods bypass the validationFunc to provide access to values that were not
  477. // known at the time the binary was compiled.
  478. - (BOOL)valueForKey:(int32_t)key rawValue:(nullable int32_t *)rawValue;
  479. - (void)enumerateKeysAndRawValuesUsingBlock:
  480. (void (^)(int32_t key, int32_t rawValue, BOOL *stop))block;
  481. - (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;
  482. // If value is not a valid enumerator as defined by validationFunc, these
  483. // methods will assert in debug, and will log in release and assign the value
  484. // to the default value. Use the rawValue methods below to assign non enumerator
  485. // values.
  486. - (void)setValue:(int32_t)value forKey:(int32_t)key;
  487. // This method bypass the validationFunc to provide setting of values that were not
  488. // known at the time the binary was compiled.
  489. - (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;
  490. // No validation applies to these methods.
  491. - (void)removeValueForKey:(int32_t)aKey;
  492. - (void)removeAll;
  493. @end
  494. #pragma mark - Int32 -> Object
  495. @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  496. @property(nonatomic, readonly) NSUInteger count;
  497. + (instancetype)dictionary;
  498. + (instancetype)dictionaryWithObject:(ObjectType)object
  499. forKey:(int32_t)key;
  500. + (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  501. forKeys:(const int32_t [])keys
  502. count:(NSUInteger)count;
  503. + (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
  504. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  505. - (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  506. forKeys:(const int32_t [])keys
  507. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  508. - (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
  509. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  510. - (ObjectType)objectForKey:(int32_t)key;
  511. - (void)enumerateKeysAndObjectsUsingBlock:
  512. (void (^)(int32_t key, ObjectType object, BOOL *stop))block;
  513. - (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
  514. - (void)setObject:(ObjectType)object forKey:(int32_t)key;
  515. - (void)removeObjectForKey:(int32_t)aKey;
  516. - (void)removeAll;
  517. @end
  518. #pragma mark - UInt64 -> UInt32
  519. @interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
  520. @property(nonatomic, readonly) NSUInteger count;
  521. + (instancetype)dictionary;
  522. + (instancetype)dictionaryWithValue:(uint32_t)value
  523. forKey:(uint64_t)key;
  524. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  525. forKeys:(const uint64_t [])keys
  526. count:(NSUInteger)count;
  527. + (instancetype)dictionaryWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
  528. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  529. - (instancetype)initWithValues:(const uint32_t [])values
  530. forKeys:(const uint64_t [])keys
  531. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  532. - (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
  533. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  534. - (BOOL)valueForKey:(uint64_t)key value:(nullable uint32_t *)value;
  535. - (void)enumerateKeysAndValuesUsingBlock:
  536. (void (^)(uint64_t key, uint32_t value, BOOL *stop))block;
  537. - (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;
  538. - (void)setValue:(uint32_t)value forKey:(uint64_t)key;
  539. - (void)removeValueForKey:(uint64_t)aKey;
  540. - (void)removeAll;
  541. @end
  542. #pragma mark - UInt64 -> Int32
  543. @interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
  544. @property(nonatomic, readonly) NSUInteger count;
  545. + (instancetype)dictionary;
  546. + (instancetype)dictionaryWithValue:(int32_t)value
  547. forKey:(uint64_t)key;
  548. + (instancetype)dictionaryWithValues:(const int32_t [])values
  549. forKeys:(const uint64_t [])keys
  550. count:(NSUInteger)count;
  551. + (instancetype)dictionaryWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
  552. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  553. - (instancetype)initWithValues:(const int32_t [])values
  554. forKeys:(const uint64_t [])keys
  555. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  556. - (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
  557. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  558. - (BOOL)valueForKey:(uint64_t)key value:(nullable int32_t *)value;
  559. - (void)enumerateKeysAndValuesUsingBlock:
  560. (void (^)(uint64_t key, int32_t value, BOOL *stop))block;
  561. - (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;
  562. - (void)setValue:(int32_t)value forKey:(uint64_t)key;
  563. - (void)removeValueForKey:(uint64_t)aKey;
  564. - (void)removeAll;
  565. @end
  566. #pragma mark - UInt64 -> UInt64
  567. @interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
  568. @property(nonatomic, readonly) NSUInteger count;
  569. + (instancetype)dictionary;
  570. + (instancetype)dictionaryWithValue:(uint64_t)value
  571. forKey:(uint64_t)key;
  572. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  573. forKeys:(const uint64_t [])keys
  574. count:(NSUInteger)count;
  575. + (instancetype)dictionaryWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
  576. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  577. - (instancetype)initWithValues:(const uint64_t [])values
  578. forKeys:(const uint64_t [])keys
  579. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  580. - (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
  581. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  582. - (BOOL)valueForKey:(uint64_t)key value:(nullable uint64_t *)value;
  583. - (void)enumerateKeysAndValuesUsingBlock:
  584. (void (^)(uint64_t key, uint64_t value, BOOL *stop))block;
  585. - (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;
  586. - (void)setValue:(uint64_t)value forKey:(uint64_t)key;
  587. - (void)removeValueForKey:(uint64_t)aKey;
  588. - (void)removeAll;
  589. @end
  590. #pragma mark - UInt64 -> Int64
  591. @interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
  592. @property(nonatomic, readonly) NSUInteger count;
  593. + (instancetype)dictionary;
  594. + (instancetype)dictionaryWithValue:(int64_t)value
  595. forKey:(uint64_t)key;
  596. + (instancetype)dictionaryWithValues:(const int64_t [])values
  597. forKeys:(const uint64_t [])keys
  598. count:(NSUInteger)count;
  599. + (instancetype)dictionaryWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
  600. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  601. - (instancetype)initWithValues:(const int64_t [])values
  602. forKeys:(const uint64_t [])keys
  603. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  604. - (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
  605. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  606. - (BOOL)valueForKey:(uint64_t)key value:(nullable int64_t *)value;
  607. - (void)enumerateKeysAndValuesUsingBlock:
  608. (void (^)(uint64_t key, int64_t value, BOOL *stop))block;
  609. - (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;
  610. - (void)setValue:(int64_t)value forKey:(uint64_t)key;
  611. - (void)removeValueForKey:(uint64_t)aKey;
  612. - (void)removeAll;
  613. @end
  614. #pragma mark - UInt64 -> Bool
  615. @interface GPBUInt64BoolDictionary : NSObject <NSCopying>
  616. @property(nonatomic, readonly) NSUInteger count;
  617. + (instancetype)dictionary;
  618. + (instancetype)dictionaryWithValue:(BOOL)value
  619. forKey:(uint64_t)key;
  620. + (instancetype)dictionaryWithValues:(const BOOL [])values
  621. forKeys:(const uint64_t [])keys
  622. count:(NSUInteger)count;
  623. + (instancetype)dictionaryWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
  624. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  625. - (instancetype)initWithValues:(const BOOL [])values
  626. forKeys:(const uint64_t [])keys
  627. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  628. - (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
  629. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  630. - (BOOL)valueForKey:(uint64_t)key value:(nullable BOOL *)value;
  631. - (void)enumerateKeysAndValuesUsingBlock:
  632. (void (^)(uint64_t key, BOOL value, BOOL *stop))block;
  633. - (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;
  634. - (void)setValue:(BOOL)value forKey:(uint64_t)key;
  635. - (void)removeValueForKey:(uint64_t)aKey;
  636. - (void)removeAll;
  637. @end
  638. #pragma mark - UInt64 -> Float
  639. @interface GPBUInt64FloatDictionary : NSObject <NSCopying>
  640. @property(nonatomic, readonly) NSUInteger count;
  641. + (instancetype)dictionary;
  642. + (instancetype)dictionaryWithValue:(float)value
  643. forKey:(uint64_t)key;
  644. + (instancetype)dictionaryWithValues:(const float [])values
  645. forKeys:(const uint64_t [])keys
  646. count:(NSUInteger)count;
  647. + (instancetype)dictionaryWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
  648. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  649. - (instancetype)initWithValues:(const float [])values
  650. forKeys:(const uint64_t [])keys
  651. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  652. - (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
  653. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  654. - (BOOL)valueForKey:(uint64_t)key value:(nullable float *)value;
  655. - (void)enumerateKeysAndValuesUsingBlock:
  656. (void (^)(uint64_t key, float value, BOOL *stop))block;
  657. - (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;
  658. - (void)setValue:(float)value forKey:(uint64_t)key;
  659. - (void)removeValueForKey:(uint64_t)aKey;
  660. - (void)removeAll;
  661. @end
  662. #pragma mark - UInt64 -> Double
  663. @interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
  664. @property(nonatomic, readonly) NSUInteger count;
  665. + (instancetype)dictionary;
  666. + (instancetype)dictionaryWithValue:(double)value
  667. forKey:(uint64_t)key;
  668. + (instancetype)dictionaryWithValues:(const double [])values
  669. forKeys:(const uint64_t [])keys
  670. count:(NSUInteger)count;
  671. + (instancetype)dictionaryWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
  672. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  673. - (instancetype)initWithValues:(const double [])values
  674. forKeys:(const uint64_t [])keys
  675. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  676. - (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
  677. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  678. - (BOOL)valueForKey:(uint64_t)key value:(nullable double *)value;
  679. - (void)enumerateKeysAndValuesUsingBlock:
  680. (void (^)(uint64_t key, double value, BOOL *stop))block;
  681. - (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;
  682. - (void)setValue:(double)value forKey:(uint64_t)key;
  683. - (void)removeValueForKey:(uint64_t)aKey;
  684. - (void)removeAll;
  685. @end
  686. #pragma mark - UInt64 -> Enum
  687. @interface GPBUInt64EnumDictionary : NSObject <NSCopying>
  688. @property(nonatomic, readonly) NSUInteger count;
  689. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  690. + (instancetype)dictionary;
  691. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  692. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  693. rawValue:(int32_t)rawValue
  694. forKey:(uint64_t)key;
  695. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  696. rawValues:(const int32_t [])values
  697. forKeys:(const uint64_t [])keys
  698. count:(NSUInteger)count;
  699. + (instancetype)dictionaryWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
  700. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  701. capacity:(NSUInteger)numItems;
  702. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  703. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  704. rawValues:(const int32_t [])values
  705. forKeys:(const uint64_t [])keys
  706. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  707. - (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
  708. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  709. capacity:(NSUInteger)numItems;
  710. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  711. // is not a valid enumerator as defined by validationFunc. If the actual value is
  712. // desired, use "raw" version of the method.
  713. - (BOOL)valueForKey:(uint64_t)key value:(nullable int32_t *)value;
  714. - (void)enumerateKeysAndValuesUsingBlock:
  715. (void (^)(uint64_t key, int32_t value, BOOL *stop))block;
  716. // These methods bypass the validationFunc to provide access to values that were not
  717. // known at the time the binary was compiled.
  718. - (BOOL)valueForKey:(uint64_t)key rawValue:(nullable int32_t *)rawValue;
  719. - (void)enumerateKeysAndRawValuesUsingBlock:
  720. (void (^)(uint64_t key, int32_t rawValue, BOOL *stop))block;
  721. - (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;
  722. // If value is not a valid enumerator as defined by validationFunc, these
  723. // methods will assert in debug, and will log in release and assign the value
  724. // to the default value. Use the rawValue methods below to assign non enumerator
  725. // values.
  726. - (void)setValue:(int32_t)value forKey:(uint64_t)key;
  727. // This method bypass the validationFunc to provide setting of values that were not
  728. // known at the time the binary was compiled.
  729. - (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;
  730. // No validation applies to these methods.
  731. - (void)removeValueForKey:(uint64_t)aKey;
  732. - (void)removeAll;
  733. @end
  734. #pragma mark - UInt64 -> Object
  735. @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  736. @property(nonatomic, readonly) NSUInteger count;
  737. + (instancetype)dictionary;
  738. + (instancetype)dictionaryWithObject:(ObjectType)object
  739. forKey:(uint64_t)key;
  740. + (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  741. forKeys:(const uint64_t [])keys
  742. count:(NSUInteger)count;
  743. + (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
  744. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  745. - (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  746. forKeys:(const uint64_t [])keys
  747. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  748. - (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
  749. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  750. - (ObjectType)objectForKey:(uint64_t)key;
  751. - (void)enumerateKeysAndObjectsUsingBlock:
  752. (void (^)(uint64_t key, ObjectType object, BOOL *stop))block;
  753. - (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
  754. - (void)setObject:(ObjectType)object forKey:(uint64_t)key;
  755. - (void)removeObjectForKey:(uint64_t)aKey;
  756. - (void)removeAll;
  757. @end
  758. #pragma mark - Int64 -> UInt32
  759. @interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
  760. @property(nonatomic, readonly) NSUInteger count;
  761. + (instancetype)dictionary;
  762. + (instancetype)dictionaryWithValue:(uint32_t)value
  763. forKey:(int64_t)key;
  764. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  765. forKeys:(const int64_t [])keys
  766. count:(NSUInteger)count;
  767. + (instancetype)dictionaryWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
  768. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  769. - (instancetype)initWithValues:(const uint32_t [])values
  770. forKeys:(const int64_t [])keys
  771. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  772. - (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
  773. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  774. - (BOOL)valueForKey:(int64_t)key value:(nullable uint32_t *)value;
  775. - (void)enumerateKeysAndValuesUsingBlock:
  776. (void (^)(int64_t key, uint32_t value, BOOL *stop))block;
  777. - (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;
  778. - (void)setValue:(uint32_t)value forKey:(int64_t)key;
  779. - (void)removeValueForKey:(int64_t)aKey;
  780. - (void)removeAll;
  781. @end
  782. #pragma mark - Int64 -> Int32
  783. @interface GPBInt64Int32Dictionary : NSObject <NSCopying>
  784. @property(nonatomic, readonly) NSUInteger count;
  785. + (instancetype)dictionary;
  786. + (instancetype)dictionaryWithValue:(int32_t)value
  787. forKey:(int64_t)key;
  788. + (instancetype)dictionaryWithValues:(const int32_t [])values
  789. forKeys:(const int64_t [])keys
  790. count:(NSUInteger)count;
  791. + (instancetype)dictionaryWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
  792. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  793. - (instancetype)initWithValues:(const int32_t [])values
  794. forKeys:(const int64_t [])keys
  795. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  796. - (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
  797. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  798. - (BOOL)valueForKey:(int64_t)key value:(nullable int32_t *)value;
  799. - (void)enumerateKeysAndValuesUsingBlock:
  800. (void (^)(int64_t key, int32_t value, BOOL *stop))block;
  801. - (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;
  802. - (void)setValue:(int32_t)value forKey:(int64_t)key;
  803. - (void)removeValueForKey:(int64_t)aKey;
  804. - (void)removeAll;
  805. @end
  806. #pragma mark - Int64 -> UInt64
  807. @interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
  808. @property(nonatomic, readonly) NSUInteger count;
  809. + (instancetype)dictionary;
  810. + (instancetype)dictionaryWithValue:(uint64_t)value
  811. forKey:(int64_t)key;
  812. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  813. forKeys:(const int64_t [])keys
  814. count:(NSUInteger)count;
  815. + (instancetype)dictionaryWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
  816. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  817. - (instancetype)initWithValues:(const uint64_t [])values
  818. forKeys:(const int64_t [])keys
  819. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  820. - (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
  821. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  822. - (BOOL)valueForKey:(int64_t)key value:(nullable uint64_t *)value;
  823. - (void)enumerateKeysAndValuesUsingBlock:
  824. (void (^)(int64_t key, uint64_t value, BOOL *stop))block;
  825. - (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;
  826. - (void)setValue:(uint64_t)value forKey:(int64_t)key;
  827. - (void)removeValueForKey:(int64_t)aKey;
  828. - (void)removeAll;
  829. @end
  830. #pragma mark - Int64 -> Int64
  831. @interface GPBInt64Int64Dictionary : NSObject <NSCopying>
  832. @property(nonatomic, readonly) NSUInteger count;
  833. + (instancetype)dictionary;
  834. + (instancetype)dictionaryWithValue:(int64_t)value
  835. forKey:(int64_t)key;
  836. + (instancetype)dictionaryWithValues:(const int64_t [])values
  837. forKeys:(const int64_t [])keys
  838. count:(NSUInteger)count;
  839. + (instancetype)dictionaryWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
  840. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  841. - (instancetype)initWithValues:(const int64_t [])values
  842. forKeys:(const int64_t [])keys
  843. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  844. - (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
  845. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  846. - (BOOL)valueForKey:(int64_t)key value:(nullable int64_t *)value;
  847. - (void)enumerateKeysAndValuesUsingBlock:
  848. (void (^)(int64_t key, int64_t value, BOOL *stop))block;
  849. - (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;
  850. - (void)setValue:(int64_t)value forKey:(int64_t)key;
  851. - (void)removeValueForKey:(int64_t)aKey;
  852. - (void)removeAll;
  853. @end
  854. #pragma mark - Int64 -> Bool
  855. @interface GPBInt64BoolDictionary : NSObject <NSCopying>
  856. @property(nonatomic, readonly) NSUInteger count;
  857. + (instancetype)dictionary;
  858. + (instancetype)dictionaryWithValue:(BOOL)value
  859. forKey:(int64_t)key;
  860. + (instancetype)dictionaryWithValues:(const BOOL [])values
  861. forKeys:(const int64_t [])keys
  862. count:(NSUInteger)count;
  863. + (instancetype)dictionaryWithDictionary:(GPBInt64BoolDictionary *)dictionary;
  864. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  865. - (instancetype)initWithValues:(const BOOL [])values
  866. forKeys:(const int64_t [])keys
  867. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  868. - (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
  869. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  870. - (BOOL)valueForKey:(int64_t)key value:(nullable BOOL *)value;
  871. - (void)enumerateKeysAndValuesUsingBlock:
  872. (void (^)(int64_t key, BOOL value, BOOL *stop))block;
  873. - (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;
  874. - (void)setValue:(BOOL)value forKey:(int64_t)key;
  875. - (void)removeValueForKey:(int64_t)aKey;
  876. - (void)removeAll;
  877. @end
  878. #pragma mark - Int64 -> Float
  879. @interface GPBInt64FloatDictionary : NSObject <NSCopying>
  880. @property(nonatomic, readonly) NSUInteger count;
  881. + (instancetype)dictionary;
  882. + (instancetype)dictionaryWithValue:(float)value
  883. forKey:(int64_t)key;
  884. + (instancetype)dictionaryWithValues:(const float [])values
  885. forKeys:(const int64_t [])keys
  886. count:(NSUInteger)count;
  887. + (instancetype)dictionaryWithDictionary:(GPBInt64FloatDictionary *)dictionary;
  888. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  889. - (instancetype)initWithValues:(const float [])values
  890. forKeys:(const int64_t [])keys
  891. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  892. - (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
  893. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  894. - (BOOL)valueForKey:(int64_t)key value:(nullable float *)value;
  895. - (void)enumerateKeysAndValuesUsingBlock:
  896. (void (^)(int64_t key, float value, BOOL *stop))block;
  897. - (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;
  898. - (void)setValue:(float)value forKey:(int64_t)key;
  899. - (void)removeValueForKey:(int64_t)aKey;
  900. - (void)removeAll;
  901. @end
  902. #pragma mark - Int64 -> Double
  903. @interface GPBInt64DoubleDictionary : NSObject <NSCopying>
  904. @property(nonatomic, readonly) NSUInteger count;
  905. + (instancetype)dictionary;
  906. + (instancetype)dictionaryWithValue:(double)value
  907. forKey:(int64_t)key;
  908. + (instancetype)dictionaryWithValues:(const double [])values
  909. forKeys:(const int64_t [])keys
  910. count:(NSUInteger)count;
  911. + (instancetype)dictionaryWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
  912. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  913. - (instancetype)initWithValues:(const double [])values
  914. forKeys:(const int64_t [])keys
  915. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  916. - (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
  917. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  918. - (BOOL)valueForKey:(int64_t)key value:(nullable double *)value;
  919. - (void)enumerateKeysAndValuesUsingBlock:
  920. (void (^)(int64_t key, double value, BOOL *stop))block;
  921. - (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;
  922. - (void)setValue:(double)value forKey:(int64_t)key;
  923. - (void)removeValueForKey:(int64_t)aKey;
  924. - (void)removeAll;
  925. @end
  926. #pragma mark - Int64 -> Enum
  927. @interface GPBInt64EnumDictionary : NSObject <NSCopying>
  928. @property(nonatomic, readonly) NSUInteger count;
  929. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  930. + (instancetype)dictionary;
  931. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  932. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  933. rawValue:(int32_t)rawValue
  934. forKey:(int64_t)key;
  935. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  936. rawValues:(const int32_t [])values
  937. forKeys:(const int64_t [])keys
  938. count:(NSUInteger)count;
  939. + (instancetype)dictionaryWithDictionary:(GPBInt64EnumDictionary *)dictionary;
  940. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  941. capacity:(NSUInteger)numItems;
  942. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  943. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  944. rawValues:(const int32_t [])values
  945. forKeys:(const int64_t [])keys
  946. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  947. - (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
  948. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  949. capacity:(NSUInteger)numItems;
  950. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  951. // is not a valid enumerator as defined by validationFunc. If the actual value is
  952. // desired, use "raw" version of the method.
  953. - (BOOL)valueForKey:(int64_t)key value:(nullable int32_t *)value;
  954. - (void)enumerateKeysAndValuesUsingBlock:
  955. (void (^)(int64_t key, int32_t value, BOOL *stop))block;
  956. // These methods bypass the validationFunc to provide access to values that were not
  957. // known at the time the binary was compiled.
  958. - (BOOL)valueForKey:(int64_t)key rawValue:(nullable int32_t *)rawValue;
  959. - (void)enumerateKeysAndRawValuesUsingBlock:
  960. (void (^)(int64_t key, int32_t rawValue, BOOL *stop))block;
  961. - (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;
  962. // If value is not a valid enumerator as defined by validationFunc, these
  963. // methods will assert in debug, and will log in release and assign the value
  964. // to the default value. Use the rawValue methods below to assign non enumerator
  965. // values.
  966. - (void)setValue:(int32_t)value forKey:(int64_t)key;
  967. // This method bypass the validationFunc to provide setting of values that were not
  968. // known at the time the binary was compiled.
  969. - (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;
  970. // No validation applies to these methods.
  971. - (void)removeValueForKey:(int64_t)aKey;
  972. - (void)removeAll;
  973. @end
  974. #pragma mark - Int64 -> Object
  975. @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  976. @property(nonatomic, readonly) NSUInteger count;
  977. + (instancetype)dictionary;
  978. + (instancetype)dictionaryWithObject:(ObjectType)object
  979. forKey:(int64_t)key;
  980. + (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  981. forKeys:(const int64_t [])keys
  982. count:(NSUInteger)count;
  983. + (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
  984. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  985. - (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  986. forKeys:(const int64_t [])keys
  987. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  988. - (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
  989. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  990. - (ObjectType)objectForKey:(int64_t)key;
  991. - (void)enumerateKeysAndObjectsUsingBlock:
  992. (void (^)(int64_t key, ObjectType object, BOOL *stop))block;
  993. - (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
  994. - (void)setObject:(ObjectType)object forKey:(int64_t)key;
  995. - (void)removeObjectForKey:(int64_t)aKey;
  996. - (void)removeAll;
  997. @end
  998. #pragma mark - Bool -> UInt32
  999. @interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
  1000. @property(nonatomic, readonly) NSUInteger count;
  1001. + (instancetype)dictionary;
  1002. + (instancetype)dictionaryWithValue:(uint32_t)value
  1003. forKey:(BOOL)key;
  1004. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  1005. forKeys:(const BOOL [])keys
  1006. count:(NSUInteger)count;
  1007. + (instancetype)dictionaryWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
  1008. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1009. - (instancetype)initWithValues:(const uint32_t [])values
  1010. forKeys:(const BOOL [])keys
  1011. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1012. - (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
  1013. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1014. - (BOOL)valueForKey:(BOOL)key value:(nullable uint32_t *)value;
  1015. - (void)enumerateKeysAndValuesUsingBlock:
  1016. (void (^)(BOOL key, uint32_t value, BOOL *stop))block;
  1017. - (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;
  1018. - (void)setValue:(uint32_t)value forKey:(BOOL)key;
  1019. - (void)removeValueForKey:(BOOL)aKey;
  1020. - (void)removeAll;
  1021. @end
  1022. #pragma mark - Bool -> Int32
  1023. @interface GPBBoolInt32Dictionary : NSObject <NSCopying>
  1024. @property(nonatomic, readonly) NSUInteger count;
  1025. + (instancetype)dictionary;
  1026. + (instancetype)dictionaryWithValue:(int32_t)value
  1027. forKey:(BOOL)key;
  1028. + (instancetype)dictionaryWithValues:(const int32_t [])values
  1029. forKeys:(const BOOL [])keys
  1030. count:(NSUInteger)count;
  1031. + (instancetype)dictionaryWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
  1032. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1033. - (instancetype)initWithValues:(const int32_t [])values
  1034. forKeys:(const BOOL [])keys
  1035. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1036. - (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
  1037. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1038. - (BOOL)valueForKey:(BOOL)key value:(nullable int32_t *)value;
  1039. - (void)enumerateKeysAndValuesUsingBlock:
  1040. (void (^)(BOOL key, int32_t value, BOOL *stop))block;
  1041. - (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;
  1042. - (void)setValue:(int32_t)value forKey:(BOOL)key;
  1043. - (void)removeValueForKey:(BOOL)aKey;
  1044. - (void)removeAll;
  1045. @end
  1046. #pragma mark - Bool -> UInt64
  1047. @interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
  1048. @property(nonatomic, readonly) NSUInteger count;
  1049. + (instancetype)dictionary;
  1050. + (instancetype)dictionaryWithValue:(uint64_t)value
  1051. forKey:(BOOL)key;
  1052. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  1053. forKeys:(const BOOL [])keys
  1054. count:(NSUInteger)count;
  1055. + (instancetype)dictionaryWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
  1056. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1057. - (instancetype)initWithValues:(const uint64_t [])values
  1058. forKeys:(const BOOL [])keys
  1059. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1060. - (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
  1061. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1062. - (BOOL)valueForKey:(BOOL)key value:(nullable uint64_t *)value;
  1063. - (void)enumerateKeysAndValuesUsingBlock:
  1064. (void (^)(BOOL key, uint64_t value, BOOL *stop))block;
  1065. - (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;
  1066. - (void)setValue:(uint64_t)value forKey:(BOOL)key;
  1067. - (void)removeValueForKey:(BOOL)aKey;
  1068. - (void)removeAll;
  1069. @end
  1070. #pragma mark - Bool -> Int64
  1071. @interface GPBBoolInt64Dictionary : NSObject <NSCopying>
  1072. @property(nonatomic, readonly) NSUInteger count;
  1073. + (instancetype)dictionary;
  1074. + (instancetype)dictionaryWithValue:(int64_t)value
  1075. forKey:(BOOL)key;
  1076. + (instancetype)dictionaryWithValues:(const int64_t [])values
  1077. forKeys:(const BOOL [])keys
  1078. count:(NSUInteger)count;
  1079. + (instancetype)dictionaryWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
  1080. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1081. - (instancetype)initWithValues:(const int64_t [])values
  1082. forKeys:(const BOOL [])keys
  1083. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1084. - (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
  1085. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1086. - (BOOL)valueForKey:(BOOL)key value:(nullable int64_t *)value;
  1087. - (void)enumerateKeysAndValuesUsingBlock:
  1088. (void (^)(BOOL key, int64_t value, BOOL *stop))block;
  1089. - (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;
  1090. - (void)setValue:(int64_t)value forKey:(BOOL)key;
  1091. - (void)removeValueForKey:(BOOL)aKey;
  1092. - (void)removeAll;
  1093. @end
  1094. #pragma mark - Bool -> Bool
  1095. @interface GPBBoolBoolDictionary : NSObject <NSCopying>
  1096. @property(nonatomic, readonly) NSUInteger count;
  1097. + (instancetype)dictionary;
  1098. + (instancetype)dictionaryWithValue:(BOOL)value
  1099. forKey:(BOOL)key;
  1100. + (instancetype)dictionaryWithValues:(const BOOL [])values
  1101. forKeys:(const BOOL [])keys
  1102. count:(NSUInteger)count;
  1103. + (instancetype)dictionaryWithDictionary:(GPBBoolBoolDictionary *)dictionary;
  1104. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1105. - (instancetype)initWithValues:(const BOOL [])values
  1106. forKeys:(const BOOL [])keys
  1107. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1108. - (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
  1109. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1110. - (BOOL)valueForKey:(BOOL)key value:(nullable BOOL *)value;
  1111. - (void)enumerateKeysAndValuesUsingBlock:
  1112. (void (^)(BOOL key, BOOL value, BOOL *stop))block;
  1113. - (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;
  1114. - (void)setValue:(BOOL)value forKey:(BOOL)key;
  1115. - (void)removeValueForKey:(BOOL)aKey;
  1116. - (void)removeAll;
  1117. @end
  1118. #pragma mark - Bool -> Float
  1119. @interface GPBBoolFloatDictionary : NSObject <NSCopying>
  1120. @property(nonatomic, readonly) NSUInteger count;
  1121. + (instancetype)dictionary;
  1122. + (instancetype)dictionaryWithValue:(float)value
  1123. forKey:(BOOL)key;
  1124. + (instancetype)dictionaryWithValues:(const float [])values
  1125. forKeys:(const BOOL [])keys
  1126. count:(NSUInteger)count;
  1127. + (instancetype)dictionaryWithDictionary:(GPBBoolFloatDictionary *)dictionary;
  1128. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1129. - (instancetype)initWithValues:(const float [])values
  1130. forKeys:(const BOOL [])keys
  1131. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1132. - (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
  1133. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1134. - (BOOL)valueForKey:(BOOL)key value:(nullable float *)value;
  1135. - (void)enumerateKeysAndValuesUsingBlock:
  1136. (void (^)(BOOL key, float value, BOOL *stop))block;
  1137. - (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;
  1138. - (void)setValue:(float)value forKey:(BOOL)key;
  1139. - (void)removeValueForKey:(BOOL)aKey;
  1140. - (void)removeAll;
  1141. @end
  1142. #pragma mark - Bool -> Double
  1143. @interface GPBBoolDoubleDictionary : NSObject <NSCopying>
  1144. @property(nonatomic, readonly) NSUInteger count;
  1145. + (instancetype)dictionary;
  1146. + (instancetype)dictionaryWithValue:(double)value
  1147. forKey:(BOOL)key;
  1148. + (instancetype)dictionaryWithValues:(const double [])values
  1149. forKeys:(const BOOL [])keys
  1150. count:(NSUInteger)count;
  1151. + (instancetype)dictionaryWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
  1152. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1153. - (instancetype)initWithValues:(const double [])values
  1154. forKeys:(const BOOL [])keys
  1155. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1156. - (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
  1157. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1158. - (BOOL)valueForKey:(BOOL)key value:(nullable double *)value;
  1159. - (void)enumerateKeysAndValuesUsingBlock:
  1160. (void (^)(BOOL key, double value, BOOL *stop))block;
  1161. - (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;
  1162. - (void)setValue:(double)value forKey:(BOOL)key;
  1163. - (void)removeValueForKey:(BOOL)aKey;
  1164. - (void)removeAll;
  1165. @end
  1166. #pragma mark - Bool -> Enum
  1167. @interface GPBBoolEnumDictionary : NSObject <NSCopying>
  1168. @property(nonatomic, readonly) NSUInteger count;
  1169. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  1170. + (instancetype)dictionary;
  1171. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1172. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1173. rawValue:(int32_t)rawValue
  1174. forKey:(BOOL)key;
  1175. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1176. rawValues:(const int32_t [])values
  1177. forKeys:(const BOOL [])keys
  1178. count:(NSUInteger)count;
  1179. + (instancetype)dictionaryWithDictionary:(GPBBoolEnumDictionary *)dictionary;
  1180. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1181. capacity:(NSUInteger)numItems;
  1182. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1183. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1184. rawValues:(const int32_t [])values
  1185. forKeys:(const BOOL [])keys
  1186. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1187. - (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
  1188. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1189. capacity:(NSUInteger)numItems;
  1190. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  1191. // is not a valid enumerator as defined by validationFunc. If the actual value is
  1192. // desired, use "raw" version of the method.
  1193. - (BOOL)valueForKey:(BOOL)key value:(nullable int32_t *)value;
  1194. - (void)enumerateKeysAndValuesUsingBlock:
  1195. (void (^)(BOOL key, int32_t value, BOOL *stop))block;
  1196. // These methods bypass the validationFunc to provide access to values that were not
  1197. // known at the time the binary was compiled.
  1198. - (BOOL)valueForKey:(BOOL)key rawValue:(nullable int32_t *)rawValue;
  1199. - (void)enumerateKeysAndRawValuesUsingBlock:
  1200. (void (^)(BOOL key, int32_t rawValue, BOOL *stop))block;
  1201. - (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;
  1202. // If value is not a valid enumerator as defined by validationFunc, these
  1203. // methods will assert in debug, and will log in release and assign the value
  1204. // to the default value. Use the rawValue methods below to assign non enumerator
  1205. // values.
  1206. - (void)setValue:(int32_t)value forKey:(BOOL)key;
  1207. // This method bypass the validationFunc to provide setting of values that were not
  1208. // known at the time the binary was compiled.
  1209. - (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;
  1210. // No validation applies to these methods.
  1211. - (void)removeValueForKey:(BOOL)aKey;
  1212. - (void)removeAll;
  1213. @end
  1214. #pragma mark - Bool -> Object
  1215. @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  1216. @property(nonatomic, readonly) NSUInteger count;
  1217. + (instancetype)dictionary;
  1218. + (instancetype)dictionaryWithObject:(ObjectType)object
  1219. forKey:(BOOL)key;
  1220. + (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  1221. forKeys:(const BOOL [])keys
  1222. count:(NSUInteger)count;
  1223. + (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary;
  1224. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1225. - (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
  1226. forKeys:(const BOOL [])keys
  1227. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1228. - (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
  1229. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1230. - (ObjectType)objectForKey:(BOOL)key;
  1231. - (void)enumerateKeysAndObjectsUsingBlock:
  1232. (void (^)(BOOL key, ObjectType object, BOOL *stop))block;
  1233. - (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
  1234. - (void)setObject:(ObjectType)object forKey:(BOOL)key;
  1235. - (void)removeObjectForKey:(BOOL)aKey;
  1236. - (void)removeAll;
  1237. @end
  1238. #pragma mark - String -> UInt32
  1239. @interface GPBStringUInt32Dictionary : NSObject <NSCopying>
  1240. @property(nonatomic, readonly) NSUInteger count;
  1241. + (instancetype)dictionary;
  1242. + (instancetype)dictionaryWithValue:(uint32_t)value
  1243. forKey:(NSString *)key;
  1244. + (instancetype)dictionaryWithValues:(const uint32_t [])values
  1245. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1246. count:(NSUInteger)count;
  1247. + (instancetype)dictionaryWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
  1248. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1249. - (instancetype)initWithValues:(const uint32_t [])values
  1250. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1251. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1252. - (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
  1253. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1254. - (BOOL)valueForKey:(NSString *)key value:(nullable uint32_t *)value;
  1255. - (void)enumerateKeysAndValuesUsingBlock:
  1256. (void (^)(NSString *key, uint32_t value, BOOL *stop))block;
  1257. - (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;
  1258. - (void)setValue:(uint32_t)value forKey:(NSString *)key;
  1259. - (void)removeValueForKey:(NSString *)aKey;
  1260. - (void)removeAll;
  1261. @end
  1262. #pragma mark - String -> Int32
  1263. @interface GPBStringInt32Dictionary : NSObject <NSCopying>
  1264. @property(nonatomic, readonly) NSUInteger count;
  1265. + (instancetype)dictionary;
  1266. + (instancetype)dictionaryWithValue:(int32_t)value
  1267. forKey:(NSString *)key;
  1268. + (instancetype)dictionaryWithValues:(const int32_t [])values
  1269. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1270. count:(NSUInteger)count;
  1271. + (instancetype)dictionaryWithDictionary:(GPBStringInt32Dictionary *)dictionary;
  1272. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1273. - (instancetype)initWithValues:(const int32_t [])values
  1274. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1275. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1276. - (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
  1277. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1278. - (BOOL)valueForKey:(NSString *)key value:(nullable int32_t *)value;
  1279. - (void)enumerateKeysAndValuesUsingBlock:
  1280. (void (^)(NSString *key, int32_t value, BOOL *stop))block;
  1281. - (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;
  1282. - (void)setValue:(int32_t)value forKey:(NSString *)key;
  1283. - (void)removeValueForKey:(NSString *)aKey;
  1284. - (void)removeAll;
  1285. @end
  1286. #pragma mark - String -> UInt64
  1287. @interface GPBStringUInt64Dictionary : NSObject <NSCopying>
  1288. @property(nonatomic, readonly) NSUInteger count;
  1289. + (instancetype)dictionary;
  1290. + (instancetype)dictionaryWithValue:(uint64_t)value
  1291. forKey:(NSString *)key;
  1292. + (instancetype)dictionaryWithValues:(const uint64_t [])values
  1293. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1294. count:(NSUInteger)count;
  1295. + (instancetype)dictionaryWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
  1296. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1297. - (instancetype)initWithValues:(const uint64_t [])values
  1298. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1299. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1300. - (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
  1301. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1302. - (BOOL)valueForKey:(NSString *)key value:(nullable uint64_t *)value;
  1303. - (void)enumerateKeysAndValuesUsingBlock:
  1304. (void (^)(NSString *key, uint64_t value, BOOL *stop))block;
  1305. - (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;
  1306. - (void)setValue:(uint64_t)value forKey:(NSString *)key;
  1307. - (void)removeValueForKey:(NSString *)aKey;
  1308. - (void)removeAll;
  1309. @end
  1310. #pragma mark - String -> Int64
  1311. @interface GPBStringInt64Dictionary : NSObject <NSCopying>
  1312. @property(nonatomic, readonly) NSUInteger count;
  1313. + (instancetype)dictionary;
  1314. + (instancetype)dictionaryWithValue:(int64_t)value
  1315. forKey:(NSString *)key;
  1316. + (instancetype)dictionaryWithValues:(const int64_t [])values
  1317. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1318. count:(NSUInteger)count;
  1319. + (instancetype)dictionaryWithDictionary:(GPBStringInt64Dictionary *)dictionary;
  1320. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1321. - (instancetype)initWithValues:(const int64_t [])values
  1322. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1323. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1324. - (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
  1325. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1326. - (BOOL)valueForKey:(NSString *)key value:(nullable int64_t *)value;
  1327. - (void)enumerateKeysAndValuesUsingBlock:
  1328. (void (^)(NSString *key, int64_t value, BOOL *stop))block;
  1329. - (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;
  1330. - (void)setValue:(int64_t)value forKey:(NSString *)key;
  1331. - (void)removeValueForKey:(NSString *)aKey;
  1332. - (void)removeAll;
  1333. @end
  1334. #pragma mark - String -> Bool
  1335. @interface GPBStringBoolDictionary : NSObject <NSCopying>
  1336. @property(nonatomic, readonly) NSUInteger count;
  1337. + (instancetype)dictionary;
  1338. + (instancetype)dictionaryWithValue:(BOOL)value
  1339. forKey:(NSString *)key;
  1340. + (instancetype)dictionaryWithValues:(const BOOL [])values
  1341. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1342. count:(NSUInteger)count;
  1343. + (instancetype)dictionaryWithDictionary:(GPBStringBoolDictionary *)dictionary;
  1344. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1345. - (instancetype)initWithValues:(const BOOL [])values
  1346. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1347. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1348. - (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
  1349. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1350. - (BOOL)valueForKey:(NSString *)key value:(nullable BOOL *)value;
  1351. - (void)enumerateKeysAndValuesUsingBlock:
  1352. (void (^)(NSString *key, BOOL value, BOOL *stop))block;
  1353. - (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;
  1354. - (void)setValue:(BOOL)value forKey:(NSString *)key;
  1355. - (void)removeValueForKey:(NSString *)aKey;
  1356. - (void)removeAll;
  1357. @end
  1358. #pragma mark - String -> Float
  1359. @interface GPBStringFloatDictionary : NSObject <NSCopying>
  1360. @property(nonatomic, readonly) NSUInteger count;
  1361. + (instancetype)dictionary;
  1362. + (instancetype)dictionaryWithValue:(float)value
  1363. forKey:(NSString *)key;
  1364. + (instancetype)dictionaryWithValues:(const float [])values
  1365. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1366. count:(NSUInteger)count;
  1367. + (instancetype)dictionaryWithDictionary:(GPBStringFloatDictionary *)dictionary;
  1368. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1369. - (instancetype)initWithValues:(const float [])values
  1370. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1371. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1372. - (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
  1373. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1374. - (BOOL)valueForKey:(NSString *)key value:(nullable float *)value;
  1375. - (void)enumerateKeysAndValuesUsingBlock:
  1376. (void (^)(NSString *key, float value, BOOL *stop))block;
  1377. - (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;
  1378. - (void)setValue:(float)value forKey:(NSString *)key;
  1379. - (void)removeValueForKey:(NSString *)aKey;
  1380. - (void)removeAll;
  1381. @end
  1382. #pragma mark - String -> Double
  1383. @interface GPBStringDoubleDictionary : NSObject <NSCopying>
  1384. @property(nonatomic, readonly) NSUInteger count;
  1385. + (instancetype)dictionary;
  1386. + (instancetype)dictionaryWithValue:(double)value
  1387. forKey:(NSString *)key;
  1388. + (instancetype)dictionaryWithValues:(const double [])values
  1389. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1390. count:(NSUInteger)count;
  1391. + (instancetype)dictionaryWithDictionary:(GPBStringDoubleDictionary *)dictionary;
  1392. + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1393. - (instancetype)initWithValues:(const double [])values
  1394. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1395. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1396. - (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
  1397. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1398. - (BOOL)valueForKey:(NSString *)key value:(nullable double *)value;
  1399. - (void)enumerateKeysAndValuesUsingBlock:
  1400. (void (^)(NSString *key, double value, BOOL *stop))block;
  1401. - (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;
  1402. - (void)setValue:(double)value forKey:(NSString *)key;
  1403. - (void)removeValueForKey:(NSString *)aKey;
  1404. - (void)removeAll;
  1405. @end
  1406. #pragma mark - String -> Enum
  1407. @interface GPBStringEnumDictionary : NSObject <NSCopying>
  1408. @property(nonatomic, readonly) NSUInteger count;
  1409. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  1410. + (instancetype)dictionary;
  1411. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1412. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1413. rawValue:(int32_t)rawValue
  1414. forKey:(NSString *)key;
  1415. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1416. rawValues:(const int32_t [])values
  1417. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1418. count:(NSUInteger)count;
  1419. + (instancetype)dictionaryWithDictionary:(GPBStringEnumDictionary *)dictionary;
  1420. + (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1421. capacity:(NSUInteger)numItems;
  1422. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1423. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1424. rawValues:(const int32_t [])values
  1425. forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
  1426. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1427. - (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
  1428. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1429. capacity:(NSUInteger)numItems;
  1430. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  1431. // is not a valid enumerator as defined by validationFunc. If the actual value is
  1432. // desired, use "raw" version of the method.
  1433. - (BOOL)valueForKey:(NSString *)key value:(nullable int32_t *)value;
  1434. - (void)enumerateKeysAndValuesUsingBlock:
  1435. (void (^)(NSString *key, int32_t value, BOOL *stop))block;
  1436. // These methods bypass the validationFunc to provide access to values that were not
  1437. // known at the time the binary was compiled.
  1438. - (BOOL)valueForKey:(NSString *)key rawValue:(nullable int32_t *)rawValue;
  1439. - (void)enumerateKeysAndRawValuesUsingBlock:
  1440. (void (^)(NSString *key, int32_t rawValue, BOOL *stop))block;
  1441. - (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;
  1442. // If value is not a valid enumerator as defined by validationFunc, these
  1443. // methods will assert in debug, and will log in release and assign the value
  1444. // to the default value. Use the rawValue methods below to assign non enumerator
  1445. // values.
  1446. - (void)setValue:(int32_t)value forKey:(NSString *)key;
  1447. // This method bypass the validationFunc to provide setting of values that were not
  1448. // known at the time the binary was compiled.
  1449. - (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;
  1450. // No validation applies to these methods.
  1451. - (void)removeValueForKey:(NSString *)aKey;
  1452. - (void)removeAll;
  1453. @end
  1454. //%PDDM-EXPAND-END DECLARE_DICTIONARIES()
  1455. NS_ASSUME_NONNULL_END
  1456. //%PDDM-DEFINE DECLARE_DICTIONARIES()
  1457. //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t)
  1458. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t)
  1459. //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t)
  1460. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t)
  1461. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL)
  1462. //%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
  1463. //%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
  1464. //%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
  1465. //%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
  1466. //%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
  1467. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
  1468. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
  1469. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t)
  1470. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t)
  1471. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL)
  1472. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float)
  1473. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
  1474. //%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
  1475. //%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
  1476. //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, value)
  1477. //%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
  1478. //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, object)
  1479. //%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
  1480. //%- (BOOL)valueForKey:(KEY_TYPE)key value:(nullable VALUE_TYPE *)value;
  1481. //%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE)
  1482. //%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
  1483. //%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE)
  1484. //%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
  1485. //%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
  1486. // Nothing
  1487. //%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
  1488. // Nothing
  1489. //%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
  1490. //%GPB_UNSAFE_UNRETAINED ##
  1491. //%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  1492. //%GPB##KEY_NAME##VALUE_NAME##Dictionary
  1493. //%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  1494. //%GPB##KEY_NAME##VALUE_NAME##Dictionary
  1495. //%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  1496. //%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
  1497. //%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
  1498. //%#pragma mark - KEY_NAME -> VALUE_NAME
  1499. //%
  1500. //%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
  1501. //%
  1502. //%@property(nonatomic, readonly) NSUInteger count;
  1503. //%
  1504. //%+ (instancetype)dictionary;
  1505. //%+ (instancetype)dictionaryWith##VNAME$u##:(VALUE_TYPE)##VNAME
  1506. //% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key;
  1507. //%+ (instancetype)dictionaryWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
  1508. //% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
  1509. //% ##VNAME$S## count:(NSUInteger)count;
  1510. //%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  1511. //%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
  1512. //%
  1513. //%- (instancetype)initWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
  1514. //% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
  1515. //% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1516. //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  1517. //%- (instancetype)initWithCapacity:(NSUInteger)numItems;
  1518. //%
  1519. //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
  1520. //%
  1521. //%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
  1522. //%
  1523. //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
  1524. //%
  1525. //%@end
  1526. //%
  1527. //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
  1528. //%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum)
  1529. //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
  1530. //%#pragma mark - KEY_NAME -> VALUE_NAME
  1531. //%
  1532. //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
  1533. //%
  1534. //%@property(nonatomic, readonly) NSUInteger count;
  1535. //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  1536. //%
  1537. //%+ (instancetype)dictionary;
  1538. //%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1539. //%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1540. //% rawValue:(VALUE_TYPE)rawValue
  1541. //% forKey:(KEY_TYPE##KisP$S##KisP)key;
  1542. //%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1543. //% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
  1544. //% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
  1545. //% count:(NSUInteger)count;
  1546. //%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  1547. //%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1548. //% capacity:(NSUInteger)numItems;
  1549. //%
  1550. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1551. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1552. //% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
  1553. //% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
  1554. //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1555. //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  1556. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1557. //% capacity:(NSUInteger)numItems;
  1558. //%
  1559. //%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  1560. //%// is not a valid enumerator as defined by validationFunc. If the actual value is
  1561. //%// desired, use "raw" version of the method.
  1562. //%
  1563. //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
  1564. //%
  1565. //%// These methods bypass the validationFunc to provide access to values that were not
  1566. //%// known at the time the binary was compiled.
  1567. //%
  1568. //%- (BOOL)valueForKey:(KEY_TYPE##KisP$S##KisP)key rawValue:(nullable VALUE_TYPE *)rawValue;
  1569. //%
  1570. //%- (void)enumerateKeysAndRawValuesUsingBlock:
  1571. //% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
  1572. //%
  1573. //%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
  1574. //%
  1575. //%// If value is not a valid enumerator as defined by validationFunc, these
  1576. //%// methods will assert in debug, and will log in release and assign the value
  1577. //%// to the default value. Use the rawValue methods below to assign non enumerator
  1578. //%// values.
  1579. //%
  1580. //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
  1581. //%
  1582. //%@end
  1583. //%
  1584. //%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
  1585. //%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE)
  1586. //%
  1587. //%- (void)enumerateKeysAnd##VNAME$u##sUsingBlock:
  1588. //% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME, BOOL *stop))block;
  1589. //%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
  1590. //%- (void)set##VNAME$u##:(VALUE_TYPE)##VNAME forKey:(KEY_TYPE##KisP$S##KisP)key;
  1591. //%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  1592. //%- (void)remove##VNAME$u##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
  1593. //%- (void)removeAll;
  1594. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  1595. // Empty
  1596. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  1597. // Empty
  1598. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  1599. //%
  1600. //%// This method bypass the validationFunc to provide setting of values that were not
  1601. //%// known at the time the binary was compiled.
  1602. //%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
  1603. //%
  1604. //%// No validation applies to these methods.
  1605. //%