GPBDictionary.h 88 KB

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