GPBDictionary.h 86 KB

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