GPBDictionary.h 187 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #import <Foundation/Foundation.h>
  31. #import "GPBRuntimeTypes.h"
  32. // Note on naming: for the classes holding numeric values, a more natural
  33. // naming of the method might be things like "-valueForKey:",
  34. // "-setValue:forKey:"; etc. But those selectors are also defined by Key Value
  35. // Coding (KVC) as categories on NSObject. So "overloading" the selectors with
  36. // other meanings can cause warnings (based on compiler settings), but more
  37. // importantly, some of those selector get called as KVC breaks up keypaths.
  38. // So if those selectors are used, using KVC will compile cleanly, but could
  39. // crash as it invokes those selectors with the wrong types of arguments.
  40. NS_ASSUME_NONNULL_BEGIN
  41. //%PDDM-EXPAND DECLARE_DICTIONARIES()
  42. // This block of code is generated, do not edit it directly.
  43. // clang-format off
  44. #pragma mark - UInt32 -> UInt32
  45. /**
  46. * Class used for map fields of <uint32_t, uint32_t>
  47. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  48. *
  49. * @note This class is not meant to be subclassed.
  50. **/
  51. @interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
  52. /** Number of entries stored in this dictionary. */
  53. @property(nonatomic, readonly) NSUInteger count;
  54. /**
  55. * Initializes this dictionary, copying the given values and keys.
  56. *
  57. * @param values The values to be placed in this dictionary.
  58. * @param keys The keys under which to store the values.
  59. * @param count The number of elements to copy into the dictionary.
  60. *
  61. * @return A newly initialized dictionary with a copy of the values and keys.
  62. **/
  63. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  64. forKeys:(const uint32_t [__nullable])keys
  65. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  66. /**
  67. * Initializes this dictionary, copying the entries from the given dictionary.
  68. *
  69. * @param dictionary Dictionary containing the entries to add to this dictionary.
  70. *
  71. * @return A newly initialized dictionary with the entries of the given dictionary.
  72. **/
  73. - (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
  74. /**
  75. * Initializes this dictionary with the requested capacity.
  76. *
  77. * @param numItems Number of items needed for this dictionary.
  78. *
  79. * @return A newly initialized dictionary with the requested capacity.
  80. **/
  81. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  82. /**
  83. * Gets the value for the given key.
  84. *
  85. * @param value Pointer into which the value will be set, if found.
  86. * @param key Key under which the value is stored, if present.
  87. *
  88. * @return YES if the key was found and the value was copied, NO otherwise.
  89. **/
  90. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key;
  91. /**
  92. * Enumerates the keys and values on this dictionary with the given block.
  93. *
  94. * @param block The block to enumerate with.
  95. * **key**: The key for the current entry.
  96. * **value**: The value for the current entry
  97. * **stop**: A pointer to a boolean that when set stops the enumeration.
  98. **/
  99. - (void)enumerateKeysAndUInt32sUsingBlock:
  100. (void (NS_NOESCAPE ^)(uint32_t key, uint32_t value, BOOL *stop))block;
  101. /**
  102. * Adds the keys and values from another dictionary.
  103. *
  104. * @param otherDictionary Dictionary containing entries to be added to this
  105. * dictionary.
  106. **/
  107. - (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;
  108. /**
  109. * Sets the value for the given key.
  110. *
  111. * @param value The value to set.
  112. * @param key The key under which to store the value.
  113. **/
  114. - (void)setUInt32:(uint32_t)value forKey:(uint32_t)key;
  115. /**
  116. * Removes the entry for the given key.
  117. *
  118. * @param aKey Key to be removed from this dictionary.
  119. **/
  120. - (void)removeUInt32ForKey:(uint32_t)aKey;
  121. /**
  122. * Removes all entries in this dictionary.
  123. **/
  124. - (void)removeAll;
  125. @end
  126. #pragma mark - UInt32 -> Int32
  127. /**
  128. * Class used for map fields of <uint32_t, int32_t>
  129. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  130. *
  131. * @note This class is not meant to be subclassed.
  132. **/
  133. @interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
  134. /** Number of entries stored in this dictionary. */
  135. @property(nonatomic, readonly) NSUInteger count;
  136. /**
  137. * Initializes this dictionary, copying the given values and keys.
  138. *
  139. * @param values The values to be placed in this dictionary.
  140. * @param keys The keys under which to store the values.
  141. * @param count The number of elements to copy into the dictionary.
  142. *
  143. * @return A newly initialized dictionary with a copy of the values and keys.
  144. **/
  145. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  146. forKeys:(const uint32_t [__nullable])keys
  147. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  148. /**
  149. * Initializes this dictionary, copying the entries from the given dictionary.
  150. *
  151. * @param dictionary Dictionary containing the entries to add to this dictionary.
  152. *
  153. * @return A newly initialized dictionary with the entries of the given dictionary.
  154. **/
  155. - (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
  156. /**
  157. * Initializes this dictionary with the requested capacity.
  158. *
  159. * @param numItems Number of items needed for this dictionary.
  160. *
  161. * @return A newly initialized dictionary with the requested capacity.
  162. **/
  163. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  164. /**
  165. * Gets the value for the given key.
  166. *
  167. * @param value Pointer into which the value will be set, if found.
  168. * @param key Key under which the value is stored, if present.
  169. *
  170. * @return YES if the key was found and the value was copied, NO otherwise.
  171. **/
  172. - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key;
  173. /**
  174. * Enumerates the keys and values on this dictionary with the given block.
  175. *
  176. * @param block The block to enumerate with.
  177. * **key**: The key for the current entry.
  178. * **value**: The value for the current entry
  179. * **stop**: A pointer to a boolean that when set stops the enumeration.
  180. **/
  181. - (void)enumerateKeysAndInt32sUsingBlock:
  182. (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block;
  183. /**
  184. * Adds the keys and values from another dictionary.
  185. *
  186. * @param otherDictionary Dictionary containing entries to be added to this
  187. * dictionary.
  188. **/
  189. - (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;
  190. /**
  191. * Sets the value for the given key.
  192. *
  193. * @param value The value to set.
  194. * @param key The key under which to store the value.
  195. **/
  196. - (void)setInt32:(int32_t)value forKey:(uint32_t)key;
  197. /**
  198. * Removes the entry for the given key.
  199. *
  200. * @param aKey Key to be removed from this dictionary.
  201. **/
  202. - (void)removeInt32ForKey:(uint32_t)aKey;
  203. /**
  204. * Removes all entries in this dictionary.
  205. **/
  206. - (void)removeAll;
  207. @end
  208. #pragma mark - UInt32 -> UInt64
  209. /**
  210. * Class used for map fields of <uint32_t, uint64_t>
  211. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  212. *
  213. * @note This class is not meant to be subclassed.
  214. **/
  215. @interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
  216. /** Number of entries stored in this dictionary. */
  217. @property(nonatomic, readonly) NSUInteger count;
  218. /**
  219. * Initializes this dictionary, copying the given values and keys.
  220. *
  221. * @param values The values to be placed in this dictionary.
  222. * @param keys The keys under which to store the values.
  223. * @param count The number of elements to copy into the dictionary.
  224. *
  225. * @return A newly initialized dictionary with a copy of the values and keys.
  226. **/
  227. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  228. forKeys:(const uint32_t [__nullable])keys
  229. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  230. /**
  231. * Initializes this dictionary, copying the entries from the given dictionary.
  232. *
  233. * @param dictionary Dictionary containing the entries to add to this dictionary.
  234. *
  235. * @return A newly initialized dictionary with the entries of the given dictionary.
  236. **/
  237. - (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
  238. /**
  239. * Initializes this dictionary with the requested capacity.
  240. *
  241. * @param numItems Number of items needed for this dictionary.
  242. *
  243. * @return A newly initialized dictionary with the requested capacity.
  244. **/
  245. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  246. /**
  247. * Gets the value for the given key.
  248. *
  249. * @param value Pointer into which the value will be set, if found.
  250. * @param key Key under which the value is stored, if present.
  251. *
  252. * @return YES if the key was found and the value was copied, NO otherwise.
  253. **/
  254. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key;
  255. /**
  256. * Enumerates the keys and values on this dictionary with the given block.
  257. *
  258. * @param block The block to enumerate with.
  259. * **key**: The key for the current entry.
  260. * **value**: The value for the current entry
  261. * **stop**: A pointer to a boolean that when set stops the enumeration.
  262. **/
  263. - (void)enumerateKeysAndUInt64sUsingBlock:
  264. (void (NS_NOESCAPE ^)(uint32_t key, uint64_t value, BOOL *stop))block;
  265. /**
  266. * Adds the keys and values from another dictionary.
  267. *
  268. * @param otherDictionary Dictionary containing entries to be added to this
  269. * dictionary.
  270. **/
  271. - (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;
  272. /**
  273. * Sets the value for the given key.
  274. *
  275. * @param value The value to set.
  276. * @param key The key under which to store the value.
  277. **/
  278. - (void)setUInt64:(uint64_t)value forKey:(uint32_t)key;
  279. /**
  280. * Removes the entry for the given key.
  281. *
  282. * @param aKey Key to be removed from this dictionary.
  283. **/
  284. - (void)removeUInt64ForKey:(uint32_t)aKey;
  285. /**
  286. * Removes all entries in this dictionary.
  287. **/
  288. - (void)removeAll;
  289. @end
  290. #pragma mark - UInt32 -> Int64
  291. /**
  292. * Class used for map fields of <uint32_t, int64_t>
  293. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  294. *
  295. * @note This class is not meant to be subclassed.
  296. **/
  297. @interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
  298. /** Number of entries stored in this dictionary. */
  299. @property(nonatomic, readonly) NSUInteger count;
  300. /**
  301. * Initializes this dictionary, copying the given values and keys.
  302. *
  303. * @param values The values to be placed in this dictionary.
  304. * @param keys The keys under which to store the values.
  305. * @param count The number of elements to copy into the dictionary.
  306. *
  307. * @return A newly initialized dictionary with a copy of the values and keys.
  308. **/
  309. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  310. forKeys:(const uint32_t [__nullable])keys
  311. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  312. /**
  313. * Initializes this dictionary, copying the entries from the given dictionary.
  314. *
  315. * @param dictionary Dictionary containing the entries to add to this dictionary.
  316. *
  317. * @return A newly initialized dictionary with the entries of the given dictionary.
  318. **/
  319. - (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
  320. /**
  321. * Initializes this dictionary with the requested capacity.
  322. *
  323. * @param numItems Number of items needed for this dictionary.
  324. *
  325. * @return A newly initialized dictionary with the requested capacity.
  326. **/
  327. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  328. /**
  329. * Gets the value for the given key.
  330. *
  331. * @param value Pointer into which the value will be set, if found.
  332. * @param key Key under which the value is stored, if present.
  333. *
  334. * @return YES if the key was found and the value was copied, NO otherwise.
  335. **/
  336. - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key;
  337. /**
  338. * Enumerates the keys and values on this dictionary with the given block.
  339. *
  340. * @param block The block to enumerate with.
  341. * **key**: The key for the current entry.
  342. * **value**: The value for the current entry
  343. * **stop**: A pointer to a boolean that when set stops the enumeration.
  344. **/
  345. - (void)enumerateKeysAndInt64sUsingBlock:
  346. (void (NS_NOESCAPE ^)(uint32_t key, int64_t value, BOOL *stop))block;
  347. /**
  348. * Adds the keys and values from another dictionary.
  349. *
  350. * @param otherDictionary Dictionary containing entries to be added to this
  351. * dictionary.
  352. **/
  353. - (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;
  354. /**
  355. * Sets the value for the given key.
  356. *
  357. * @param value The value to set.
  358. * @param key The key under which to store the value.
  359. **/
  360. - (void)setInt64:(int64_t)value forKey:(uint32_t)key;
  361. /**
  362. * Removes the entry for the given key.
  363. *
  364. * @param aKey Key to be removed from this dictionary.
  365. **/
  366. - (void)removeInt64ForKey:(uint32_t)aKey;
  367. /**
  368. * Removes all entries in this dictionary.
  369. **/
  370. - (void)removeAll;
  371. @end
  372. #pragma mark - UInt32 -> Bool
  373. /**
  374. * Class used for map fields of <uint32_t, BOOL>
  375. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  376. *
  377. * @note This class is not meant to be subclassed.
  378. **/
  379. @interface GPBUInt32BoolDictionary : NSObject <NSCopying>
  380. /** Number of entries stored in this dictionary. */
  381. @property(nonatomic, readonly) NSUInteger count;
  382. /**
  383. * Initializes this dictionary, copying the given values and keys.
  384. *
  385. * @param values The values to be placed in this dictionary.
  386. * @param keys The keys under which to store the values.
  387. * @param count The number of elements to copy into the dictionary.
  388. *
  389. * @return A newly initialized dictionary with a copy of the values and keys.
  390. **/
  391. - (instancetype)initWithBools:(const BOOL [__nullable])values
  392. forKeys:(const uint32_t [__nullable])keys
  393. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  394. /**
  395. * Initializes this dictionary, copying the entries from the given dictionary.
  396. *
  397. * @param dictionary Dictionary containing the entries to add to this dictionary.
  398. *
  399. * @return A newly initialized dictionary with the entries of the given dictionary.
  400. **/
  401. - (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
  402. /**
  403. * Initializes this dictionary with the requested capacity.
  404. *
  405. * @param numItems Number of items needed for this dictionary.
  406. *
  407. * @return A newly initialized dictionary with the requested capacity.
  408. **/
  409. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  410. /**
  411. * Gets the value for the given key.
  412. *
  413. * @param value Pointer into which the value will be set, if found.
  414. * @param key Key under which the value is stored, if present.
  415. *
  416. * @return YES if the key was found and the value was copied, NO otherwise.
  417. **/
  418. - (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key;
  419. /**
  420. * Enumerates the keys and values on this dictionary with the given block.
  421. *
  422. * @param block The block to enumerate with.
  423. * **key**: The key for the current entry.
  424. * **value**: The value for the current entry
  425. * **stop**: A pointer to a boolean that when set stops the enumeration.
  426. **/
  427. - (void)enumerateKeysAndBoolsUsingBlock:
  428. (void (NS_NOESCAPE ^)(uint32_t key, BOOL value, BOOL *stop))block;
  429. /**
  430. * Adds the keys and values from another dictionary.
  431. *
  432. * @param otherDictionary Dictionary containing entries to be added to this
  433. * dictionary.
  434. **/
  435. - (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;
  436. /**
  437. * Sets the value for the given key.
  438. *
  439. * @param value The value to set.
  440. * @param key The key under which to store the value.
  441. **/
  442. - (void)setBool:(BOOL)value forKey:(uint32_t)key;
  443. /**
  444. * Removes the entry for the given key.
  445. *
  446. * @param aKey Key to be removed from this dictionary.
  447. **/
  448. - (void)removeBoolForKey:(uint32_t)aKey;
  449. /**
  450. * Removes all entries in this dictionary.
  451. **/
  452. - (void)removeAll;
  453. @end
  454. #pragma mark - UInt32 -> Float
  455. /**
  456. * Class used for map fields of <uint32_t, float>
  457. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  458. *
  459. * @note This class is not meant to be subclassed.
  460. **/
  461. @interface GPBUInt32FloatDictionary : NSObject <NSCopying>
  462. /** Number of entries stored in this dictionary. */
  463. @property(nonatomic, readonly) NSUInteger count;
  464. /**
  465. * Initializes this dictionary, copying the given values and keys.
  466. *
  467. * @param values The values to be placed in this dictionary.
  468. * @param keys The keys under which to store the values.
  469. * @param count The number of elements to copy into the dictionary.
  470. *
  471. * @return A newly initialized dictionary with a copy of the values and keys.
  472. **/
  473. - (instancetype)initWithFloats:(const float [__nullable])values
  474. forKeys:(const uint32_t [__nullable])keys
  475. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  476. /**
  477. * Initializes this dictionary, copying the entries from the given dictionary.
  478. *
  479. * @param dictionary Dictionary containing the entries to add to this dictionary.
  480. *
  481. * @return A newly initialized dictionary with the entries of the given dictionary.
  482. **/
  483. - (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
  484. /**
  485. * Initializes this dictionary with the requested capacity.
  486. *
  487. * @param numItems Number of items needed for this dictionary.
  488. *
  489. * @return A newly initialized dictionary with the requested capacity.
  490. **/
  491. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  492. /**
  493. * Gets the value for the given key.
  494. *
  495. * @param value Pointer into which the value will be set, if found.
  496. * @param key Key under which the value is stored, if present.
  497. *
  498. * @return YES if the key was found and the value was copied, NO otherwise.
  499. **/
  500. - (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key;
  501. /**
  502. * Enumerates the keys and values on this dictionary with the given block.
  503. *
  504. * @param block The block to enumerate with.
  505. * **key**: The key for the current entry.
  506. * **value**: The value for the current entry
  507. * **stop**: A pointer to a boolean that when set stops the enumeration.
  508. **/
  509. - (void)enumerateKeysAndFloatsUsingBlock:
  510. (void (NS_NOESCAPE ^)(uint32_t key, float value, BOOL *stop))block;
  511. /**
  512. * Adds the keys and values from another dictionary.
  513. *
  514. * @param otherDictionary Dictionary containing entries to be added to this
  515. * dictionary.
  516. **/
  517. - (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;
  518. /**
  519. * Sets the value for the given key.
  520. *
  521. * @param value The value to set.
  522. * @param key The key under which to store the value.
  523. **/
  524. - (void)setFloat:(float)value forKey:(uint32_t)key;
  525. /**
  526. * Removes the entry for the given key.
  527. *
  528. * @param aKey Key to be removed from this dictionary.
  529. **/
  530. - (void)removeFloatForKey:(uint32_t)aKey;
  531. /**
  532. * Removes all entries in this dictionary.
  533. **/
  534. - (void)removeAll;
  535. @end
  536. #pragma mark - UInt32 -> Double
  537. /**
  538. * Class used for map fields of <uint32_t, double>
  539. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  540. *
  541. * @note This class is not meant to be subclassed.
  542. **/
  543. @interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
  544. /** Number of entries stored in this dictionary. */
  545. @property(nonatomic, readonly) NSUInteger count;
  546. /**
  547. * Initializes this dictionary, copying the given values and keys.
  548. *
  549. * @param values The values to be placed in this dictionary.
  550. * @param keys The keys under which to store the values.
  551. * @param count The number of elements to copy into the dictionary.
  552. *
  553. * @return A newly initialized dictionary with a copy of the values and keys.
  554. **/
  555. - (instancetype)initWithDoubles:(const double [__nullable])values
  556. forKeys:(const uint32_t [__nullable])keys
  557. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  558. /**
  559. * Initializes this dictionary, copying the entries from the given dictionary.
  560. *
  561. * @param dictionary Dictionary containing the entries to add to this dictionary.
  562. *
  563. * @return A newly initialized dictionary with the entries of the given dictionary.
  564. **/
  565. - (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
  566. /**
  567. * Initializes this dictionary with the requested capacity.
  568. *
  569. * @param numItems Number of items needed for this dictionary.
  570. *
  571. * @return A newly initialized dictionary with the requested capacity.
  572. **/
  573. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  574. /**
  575. * Gets the value for the given key.
  576. *
  577. * @param value Pointer into which the value will be set, if found.
  578. * @param key Key under which the value is stored, if present.
  579. *
  580. * @return YES if the key was found and the value was copied, NO otherwise.
  581. **/
  582. - (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key;
  583. /**
  584. * Enumerates the keys and values on this dictionary with the given block.
  585. *
  586. * @param block The block to enumerate with.
  587. * **key**: The key for the current entry.
  588. * **value**: The value for the current entry
  589. * **stop**: A pointer to a boolean that when set stops the enumeration.
  590. **/
  591. - (void)enumerateKeysAndDoublesUsingBlock:
  592. (void (NS_NOESCAPE ^)(uint32_t key, double value, BOOL *stop))block;
  593. /**
  594. * Adds the keys and values from another dictionary.
  595. *
  596. * @param otherDictionary Dictionary containing entries to be added to this
  597. * dictionary.
  598. **/
  599. - (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;
  600. /**
  601. * Sets the value for the given key.
  602. *
  603. * @param value The value to set.
  604. * @param key The key under which to store the value.
  605. **/
  606. - (void)setDouble:(double)value forKey:(uint32_t)key;
  607. /**
  608. * Removes the entry for the given key.
  609. *
  610. * @param aKey Key to be removed from this dictionary.
  611. **/
  612. - (void)removeDoubleForKey:(uint32_t)aKey;
  613. /**
  614. * Removes all entries in this dictionary.
  615. **/
  616. - (void)removeAll;
  617. @end
  618. #pragma mark - UInt32 -> Enum
  619. /**
  620. * Class used for map fields of <uint32_t, int32_t>
  621. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  622. *
  623. * @note This class is not meant to be subclassed.
  624. **/
  625. @interface GPBUInt32EnumDictionary : NSObject <NSCopying>
  626. /** Number of entries stored in this dictionary. */
  627. @property(nonatomic, readonly) NSUInteger count;
  628. /** The validation function to check if the enums are valid. */
  629. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  630. /**
  631. * Initializes a dictionary with the given validation function.
  632. *
  633. * @param func The enum validation function for the dictionary.
  634. *
  635. * @return A newly initialized dictionary.
  636. **/
  637. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  638. /**
  639. * Initializes a dictionary with the entries given.
  640. *
  641. * @param func The enum validation function for the dictionary.
  642. * @param values The raw enum values values to be placed in the dictionary.
  643. * @param keys The keys under which to store the values.
  644. * @param count The number of entries to store in the dictionary.
  645. *
  646. * @return A newly initialized dictionary with the keys and values in it.
  647. **/
  648. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  649. rawValues:(const int32_t [__nullable])values
  650. forKeys:(const uint32_t [__nullable])keys
  651. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  652. /**
  653. * Initializes a dictionary with the entries from the given.
  654. * dictionary.
  655. *
  656. * @param dictionary Dictionary containing the entries to add to the dictionary.
  657. *
  658. * @return A newly initialized dictionary with the entries from the given
  659. * dictionary in it.
  660. **/
  661. - (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
  662. /**
  663. * Initializes a dictionary with the given capacity.
  664. *
  665. * @param func The enum validation function for the dictionary.
  666. * @param numItems Capacity needed for the dictionary.
  667. *
  668. * @return A newly initialized dictionary with the given capacity.
  669. **/
  670. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  671. capacity:(NSUInteger)numItems;
  672. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  673. // is not a valid enumerator as defined by validationFunc. If the actual value is
  674. // desired, use "raw" version of the method.
  675. /**
  676. * Gets the value for the given key.
  677. *
  678. * @param value Pointer into which the value will be set, if found.
  679. * @param key Key under which the value is stored, if present.
  680. *
  681. * @return YES if the key was found and the value was copied, NO otherwise.
  682. **/
  683. - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key;
  684. /**
  685. * Enumerates the keys and values on this dictionary with the given block.
  686. *
  687. * @param block The block to enumerate with.
  688. * **key**: The key for the current entry.
  689. * **value**: The value for the current entry
  690. * **stop**: A pointer to a boolean that when set stops the enumeration.
  691. **/
  692. - (void)enumerateKeysAndEnumsUsingBlock:
  693. (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block;
  694. /**
  695. * Gets the raw enum value for the given key.
  696. *
  697. * @note This method bypass the validationFunc to enable the access of values that
  698. * were not known at the time the binary was compiled.
  699. *
  700. * @param rawValue Pointer into which the value will be set, if found.
  701. * @param key Key under which the value is stored, if present.
  702. *
  703. * @return YES if the key was found and the value was copied, NO otherwise.
  704. **/
  705. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key;
  706. /**
  707. * Enumerates the keys and values on this dictionary with the given block.
  708. *
  709. * @note This method bypass the validationFunc to enable the access of values that
  710. * were not known at the time the binary was compiled.
  711. *
  712. * @param block The block to enumerate with.
  713. * **key**: The key for the current entry.
  714. * **rawValue**: The value for the current entry
  715. * **stop**: A pointer to a boolean that when set stops the enumeration.
  716. **/
  717. - (void)enumerateKeysAndRawValuesUsingBlock:
  718. (void (NS_NOESCAPE ^)(uint32_t key, int32_t rawValue, BOOL *stop))block;
  719. /**
  720. * Adds the keys and raw enum values from another dictionary.
  721. *
  722. * @note This method bypass the validationFunc to enable the setting of values that
  723. * were not known at the time the binary was compiled.
  724. *
  725. * @param otherDictionary Dictionary containing entries to be added to this
  726. * dictionary.
  727. **/
  728. - (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;
  729. // If value is not a valid enumerator as defined by validationFunc, these
  730. // methods will assert in debug, and will log in release and assign the value
  731. // to the default value. Use the rawValue methods below to assign non enumerator
  732. // values.
  733. /**
  734. * Sets the value for the given key.
  735. *
  736. * @param value The value to set.
  737. * @param key The key under which to store the value.
  738. **/
  739. - (void)setEnum:(int32_t)value forKey:(uint32_t)key;
  740. /**
  741. * Sets the raw enum value for the given key.
  742. *
  743. * @note This method bypass the validationFunc to enable the setting of values that
  744. * were not known at the time the binary was compiled.
  745. *
  746. * @param rawValue The raw enum value to set.
  747. * @param key The key under which to store the raw enum value.
  748. **/
  749. - (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;
  750. /**
  751. * Removes the entry for the given key.
  752. *
  753. * @param aKey Key to be removed from this dictionary.
  754. **/
  755. - (void)removeEnumForKey:(uint32_t)aKey;
  756. /**
  757. * Removes all entries in this dictionary.
  758. **/
  759. - (void)removeAll;
  760. @end
  761. #pragma mark - UInt32 -> Object
  762. /**
  763. * Class used for map fields of <uint32_t, ObjectType>
  764. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  765. *
  766. * @note This class is not meant to be subclassed.
  767. **/
  768. @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  769. /** Number of entries stored in this dictionary. */
  770. @property(nonatomic, readonly) NSUInteger count;
  771. /**
  772. * Initializes this dictionary, copying the given values and keys.
  773. *
  774. * @param objects The values to be placed in this dictionary.
  775. * @param keys The keys under which to store the values.
  776. * @param count The number of elements to copy into the dictionary.
  777. *
  778. * @return A newly initialized dictionary with a copy of the values and keys.
  779. **/
  780. - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
  781. forKeys:(const uint32_t [__nullable])keys
  782. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  783. /**
  784. * Initializes this dictionary, copying the entries from the given dictionary.
  785. *
  786. * @param dictionary Dictionary containing the entries to add to this dictionary.
  787. *
  788. * @return A newly initialized dictionary with the entries of the given dictionary.
  789. **/
  790. - (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
  791. /**
  792. * Initializes this dictionary with the requested capacity.
  793. *
  794. * @param numItems Number of items needed for this dictionary.
  795. *
  796. * @return A newly initialized dictionary with the requested capacity.
  797. **/
  798. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  799. /**
  800. * Fetches the object stored under the given key.
  801. *
  802. * @param key Key under which the value is stored, if present.
  803. *
  804. * @return The object if found, nil otherwise.
  805. **/
  806. - (ObjectType)objectForKey:(uint32_t)key;
  807. /**
  808. * Enumerates the keys and values on this dictionary with the given block.
  809. *
  810. * @param block The block to enumerate with.
  811. * **key**: The key for the current entry.
  812. * **object**: The value for the current entry
  813. * **stop**: A pointer to a boolean that when set stops the enumeration.
  814. **/
  815. - (void)enumerateKeysAndObjectsUsingBlock:
  816. (void (NS_NOESCAPE ^)(uint32_t key, ObjectType object, BOOL *stop))block;
  817. /**
  818. * Adds the keys and values from another dictionary.
  819. *
  820. * @param otherDictionary Dictionary containing entries to be added to this
  821. * dictionary.
  822. **/
  823. - (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
  824. /**
  825. * Sets the value for the given key.
  826. *
  827. * @param object The value to set.
  828. * @param key The key under which to store the value.
  829. **/
  830. - (void)setObject:(ObjectType)object forKey:(uint32_t)key;
  831. /**
  832. * Removes the entry for the given key.
  833. *
  834. * @param aKey Key to be removed from this dictionary.
  835. **/
  836. - (void)removeObjectForKey:(uint32_t)aKey;
  837. /**
  838. * Removes all entries in this dictionary.
  839. **/
  840. - (void)removeAll;
  841. @end
  842. #pragma mark - Int32 -> UInt32
  843. /**
  844. * Class used for map fields of <int32_t, uint32_t>
  845. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  846. *
  847. * @note This class is not meant to be subclassed.
  848. **/
  849. @interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
  850. /** Number of entries stored in this dictionary. */
  851. @property(nonatomic, readonly) NSUInteger count;
  852. /**
  853. * Initializes this dictionary, copying the given values and keys.
  854. *
  855. * @param values The values to be placed in this dictionary.
  856. * @param keys The keys under which to store the values.
  857. * @param count The number of elements to copy into the dictionary.
  858. *
  859. * @return A newly initialized dictionary with a copy of the values and keys.
  860. **/
  861. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  862. forKeys:(const int32_t [__nullable])keys
  863. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  864. /**
  865. * Initializes this dictionary, copying the entries from the given dictionary.
  866. *
  867. * @param dictionary Dictionary containing the entries to add to this dictionary.
  868. *
  869. * @return A newly initialized dictionary with the entries of the given dictionary.
  870. **/
  871. - (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
  872. /**
  873. * Initializes this dictionary with the requested capacity.
  874. *
  875. * @param numItems Number of items needed for this dictionary.
  876. *
  877. * @return A newly initialized dictionary with the requested capacity.
  878. **/
  879. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  880. /**
  881. * Gets the value for the given key.
  882. *
  883. * @param value Pointer into which the value will be set, if found.
  884. * @param key Key under which the value is stored, if present.
  885. *
  886. * @return YES if the key was found and the value was copied, NO otherwise.
  887. **/
  888. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key;
  889. /**
  890. * Enumerates the keys and values on this dictionary with the given block.
  891. *
  892. * @param block The block to enumerate with.
  893. * **key**: The key for the current entry.
  894. * **value**: The value for the current entry
  895. * **stop**: A pointer to a boolean that when set stops the enumeration.
  896. **/
  897. - (void)enumerateKeysAndUInt32sUsingBlock:
  898. (void (NS_NOESCAPE ^)(int32_t key, uint32_t value, BOOL *stop))block;
  899. /**
  900. * Adds the keys and values from another dictionary.
  901. *
  902. * @param otherDictionary Dictionary containing entries to be added to this
  903. * dictionary.
  904. **/
  905. - (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;
  906. /**
  907. * Sets the value for the given key.
  908. *
  909. * @param value The value to set.
  910. * @param key The key under which to store the value.
  911. **/
  912. - (void)setUInt32:(uint32_t)value forKey:(int32_t)key;
  913. /**
  914. * Removes the entry for the given key.
  915. *
  916. * @param aKey Key to be removed from this dictionary.
  917. **/
  918. - (void)removeUInt32ForKey:(int32_t)aKey;
  919. /**
  920. * Removes all entries in this dictionary.
  921. **/
  922. - (void)removeAll;
  923. @end
  924. #pragma mark - Int32 -> Int32
  925. /**
  926. * Class used for map fields of <int32_t, int32_t>
  927. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  928. *
  929. * @note This class is not meant to be subclassed.
  930. **/
  931. @interface GPBInt32Int32Dictionary : NSObject <NSCopying>
  932. /** Number of entries stored in this dictionary. */
  933. @property(nonatomic, readonly) NSUInteger count;
  934. /**
  935. * Initializes this dictionary, copying the given values and keys.
  936. *
  937. * @param values The values to be placed in this dictionary.
  938. * @param keys The keys under which to store the values.
  939. * @param count The number of elements to copy into the dictionary.
  940. *
  941. * @return A newly initialized dictionary with a copy of the values and keys.
  942. **/
  943. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  944. forKeys:(const int32_t [__nullable])keys
  945. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  946. /**
  947. * Initializes this dictionary, copying the entries from the given dictionary.
  948. *
  949. * @param dictionary Dictionary containing the entries to add to this dictionary.
  950. *
  951. * @return A newly initialized dictionary with the entries of the given dictionary.
  952. **/
  953. - (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
  954. /**
  955. * Initializes this dictionary with the requested capacity.
  956. *
  957. * @param numItems Number of items needed for this dictionary.
  958. *
  959. * @return A newly initialized dictionary with the requested capacity.
  960. **/
  961. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  962. /**
  963. * Gets the value for the given key.
  964. *
  965. * @param value Pointer into which the value will be set, if found.
  966. * @param key Key under which the value is stored, if present.
  967. *
  968. * @return YES if the key was found and the value was copied, NO otherwise.
  969. **/
  970. - (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key;
  971. /**
  972. * Enumerates the keys and values on this dictionary with the given block.
  973. *
  974. * @param block The block to enumerate with.
  975. * **key**: The key for the current entry.
  976. * **value**: The value for the current entry
  977. * **stop**: A pointer to a boolean that when set stops the enumeration.
  978. **/
  979. - (void)enumerateKeysAndInt32sUsingBlock:
  980. (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block;
  981. /**
  982. * Adds the keys and values from another dictionary.
  983. *
  984. * @param otherDictionary Dictionary containing entries to be added to this
  985. * dictionary.
  986. **/
  987. - (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;
  988. /**
  989. * Sets the value for the given key.
  990. *
  991. * @param value The value to set.
  992. * @param key The key under which to store the value.
  993. **/
  994. - (void)setInt32:(int32_t)value forKey:(int32_t)key;
  995. /**
  996. * Removes the entry for the given key.
  997. *
  998. * @param aKey Key to be removed from this dictionary.
  999. **/
  1000. - (void)removeInt32ForKey:(int32_t)aKey;
  1001. /**
  1002. * Removes all entries in this dictionary.
  1003. **/
  1004. - (void)removeAll;
  1005. @end
  1006. #pragma mark - Int32 -> UInt64
  1007. /**
  1008. * Class used for map fields of <int32_t, uint64_t>
  1009. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1010. *
  1011. * @note This class is not meant to be subclassed.
  1012. **/
  1013. @interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
  1014. /** Number of entries stored in this dictionary. */
  1015. @property(nonatomic, readonly) NSUInteger count;
  1016. /**
  1017. * Initializes this dictionary, copying the given values and keys.
  1018. *
  1019. * @param values The values to be placed in this dictionary.
  1020. * @param keys The keys under which to store the values.
  1021. * @param count The number of elements to copy into the dictionary.
  1022. *
  1023. * @return A newly initialized dictionary with a copy of the values and keys.
  1024. **/
  1025. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  1026. forKeys:(const int32_t [__nullable])keys
  1027. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1028. /**
  1029. * Initializes this dictionary, copying the entries from the given dictionary.
  1030. *
  1031. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1032. *
  1033. * @return A newly initialized dictionary with the entries of the given dictionary.
  1034. **/
  1035. - (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
  1036. /**
  1037. * Initializes this dictionary with the requested capacity.
  1038. *
  1039. * @param numItems Number of items needed for this dictionary.
  1040. *
  1041. * @return A newly initialized dictionary with the requested capacity.
  1042. **/
  1043. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1044. /**
  1045. * Gets the value for the given key.
  1046. *
  1047. * @param value Pointer into which the value will be set, if found.
  1048. * @param key Key under which the value is stored, if present.
  1049. *
  1050. * @return YES if the key was found and the value was copied, NO otherwise.
  1051. **/
  1052. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key;
  1053. /**
  1054. * Enumerates the keys and values on this dictionary with the given block.
  1055. *
  1056. * @param block The block to enumerate with.
  1057. * **key**: The key for the current entry.
  1058. * **value**: The value for the current entry
  1059. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1060. **/
  1061. - (void)enumerateKeysAndUInt64sUsingBlock:
  1062. (void (NS_NOESCAPE ^)(int32_t key, uint64_t value, BOOL *stop))block;
  1063. /**
  1064. * Adds the keys and values from another dictionary.
  1065. *
  1066. * @param otherDictionary Dictionary containing entries to be added to this
  1067. * dictionary.
  1068. **/
  1069. - (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;
  1070. /**
  1071. * Sets the value for the given key.
  1072. *
  1073. * @param value The value to set.
  1074. * @param key The key under which to store the value.
  1075. **/
  1076. - (void)setUInt64:(uint64_t)value forKey:(int32_t)key;
  1077. /**
  1078. * Removes the entry for the given key.
  1079. *
  1080. * @param aKey Key to be removed from this dictionary.
  1081. **/
  1082. - (void)removeUInt64ForKey:(int32_t)aKey;
  1083. /**
  1084. * Removes all entries in this dictionary.
  1085. **/
  1086. - (void)removeAll;
  1087. @end
  1088. #pragma mark - Int32 -> Int64
  1089. /**
  1090. * Class used for map fields of <int32_t, int64_t>
  1091. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1092. *
  1093. * @note This class is not meant to be subclassed.
  1094. **/
  1095. @interface GPBInt32Int64Dictionary : NSObject <NSCopying>
  1096. /** Number of entries stored in this dictionary. */
  1097. @property(nonatomic, readonly) NSUInteger count;
  1098. /**
  1099. * Initializes this dictionary, copying the given values and keys.
  1100. *
  1101. * @param values The values to be placed in this dictionary.
  1102. * @param keys The keys under which to store the values.
  1103. * @param count The number of elements to copy into the dictionary.
  1104. *
  1105. * @return A newly initialized dictionary with a copy of the values and keys.
  1106. **/
  1107. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  1108. forKeys:(const int32_t [__nullable])keys
  1109. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1110. /**
  1111. * Initializes this dictionary, copying the entries from the given dictionary.
  1112. *
  1113. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1114. *
  1115. * @return A newly initialized dictionary with the entries of the given dictionary.
  1116. **/
  1117. - (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
  1118. /**
  1119. * Initializes this dictionary with the requested capacity.
  1120. *
  1121. * @param numItems Number of items needed for this dictionary.
  1122. *
  1123. * @return A newly initialized dictionary with the requested capacity.
  1124. **/
  1125. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1126. /**
  1127. * Gets the value for the given key.
  1128. *
  1129. * @param value Pointer into which the value will be set, if found.
  1130. * @param key Key under which the value is stored, if present.
  1131. *
  1132. * @return YES if the key was found and the value was copied, NO otherwise.
  1133. **/
  1134. - (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key;
  1135. /**
  1136. * Enumerates the keys and values on this dictionary with the given block.
  1137. *
  1138. * @param block The block to enumerate with.
  1139. * **key**: The key for the current entry.
  1140. * **value**: The value for the current entry
  1141. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1142. **/
  1143. - (void)enumerateKeysAndInt64sUsingBlock:
  1144. (void (NS_NOESCAPE ^)(int32_t key, int64_t value, BOOL *stop))block;
  1145. /**
  1146. * Adds the keys and values from another dictionary.
  1147. *
  1148. * @param otherDictionary Dictionary containing entries to be added to this
  1149. * dictionary.
  1150. **/
  1151. - (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;
  1152. /**
  1153. * Sets the value for the given key.
  1154. *
  1155. * @param value The value to set.
  1156. * @param key The key under which to store the value.
  1157. **/
  1158. - (void)setInt64:(int64_t)value forKey:(int32_t)key;
  1159. /**
  1160. * Removes the entry for the given key.
  1161. *
  1162. * @param aKey Key to be removed from this dictionary.
  1163. **/
  1164. - (void)removeInt64ForKey:(int32_t)aKey;
  1165. /**
  1166. * Removes all entries in this dictionary.
  1167. **/
  1168. - (void)removeAll;
  1169. @end
  1170. #pragma mark - Int32 -> Bool
  1171. /**
  1172. * Class used for map fields of <int32_t, BOOL>
  1173. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1174. *
  1175. * @note This class is not meant to be subclassed.
  1176. **/
  1177. @interface GPBInt32BoolDictionary : NSObject <NSCopying>
  1178. /** Number of entries stored in this dictionary. */
  1179. @property(nonatomic, readonly) NSUInteger count;
  1180. /**
  1181. * Initializes this dictionary, copying the given values and keys.
  1182. *
  1183. * @param values The values to be placed in this dictionary.
  1184. * @param keys The keys under which to store the values.
  1185. * @param count The number of elements to copy into the dictionary.
  1186. *
  1187. * @return A newly initialized dictionary with a copy of the values and keys.
  1188. **/
  1189. - (instancetype)initWithBools:(const BOOL [__nullable])values
  1190. forKeys:(const int32_t [__nullable])keys
  1191. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1192. /**
  1193. * Initializes this dictionary, copying the entries from the given dictionary.
  1194. *
  1195. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1196. *
  1197. * @return A newly initialized dictionary with the entries of the given dictionary.
  1198. **/
  1199. - (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
  1200. /**
  1201. * Initializes this dictionary with the requested capacity.
  1202. *
  1203. * @param numItems Number of items needed for this dictionary.
  1204. *
  1205. * @return A newly initialized dictionary with the requested capacity.
  1206. **/
  1207. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1208. /**
  1209. * Gets the value for the given key.
  1210. *
  1211. * @param value Pointer into which the value will be set, if found.
  1212. * @param key Key under which the value is stored, if present.
  1213. *
  1214. * @return YES if the key was found and the value was copied, NO otherwise.
  1215. **/
  1216. - (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key;
  1217. /**
  1218. * Enumerates the keys and values on this dictionary with the given block.
  1219. *
  1220. * @param block The block to enumerate with.
  1221. * **key**: The key for the current entry.
  1222. * **value**: The value for the current entry
  1223. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1224. **/
  1225. - (void)enumerateKeysAndBoolsUsingBlock:
  1226. (void (NS_NOESCAPE ^)(int32_t key, BOOL value, BOOL *stop))block;
  1227. /**
  1228. * Adds the keys and values from another dictionary.
  1229. *
  1230. * @param otherDictionary Dictionary containing entries to be added to this
  1231. * dictionary.
  1232. **/
  1233. - (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;
  1234. /**
  1235. * Sets the value for the given key.
  1236. *
  1237. * @param value The value to set.
  1238. * @param key The key under which to store the value.
  1239. **/
  1240. - (void)setBool:(BOOL)value forKey:(int32_t)key;
  1241. /**
  1242. * Removes the entry for the given key.
  1243. *
  1244. * @param aKey Key to be removed from this dictionary.
  1245. **/
  1246. - (void)removeBoolForKey:(int32_t)aKey;
  1247. /**
  1248. * Removes all entries in this dictionary.
  1249. **/
  1250. - (void)removeAll;
  1251. @end
  1252. #pragma mark - Int32 -> Float
  1253. /**
  1254. * Class used for map fields of <int32_t, float>
  1255. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1256. *
  1257. * @note This class is not meant to be subclassed.
  1258. **/
  1259. @interface GPBInt32FloatDictionary : NSObject <NSCopying>
  1260. /** Number of entries stored in this dictionary. */
  1261. @property(nonatomic, readonly) NSUInteger count;
  1262. /**
  1263. * Initializes this dictionary, copying the given values and keys.
  1264. *
  1265. * @param values The values to be placed in this dictionary.
  1266. * @param keys The keys under which to store the values.
  1267. * @param count The number of elements to copy into the dictionary.
  1268. *
  1269. * @return A newly initialized dictionary with a copy of the values and keys.
  1270. **/
  1271. - (instancetype)initWithFloats:(const float [__nullable])values
  1272. forKeys:(const int32_t [__nullable])keys
  1273. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1274. /**
  1275. * Initializes this dictionary, copying the entries from the given dictionary.
  1276. *
  1277. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1278. *
  1279. * @return A newly initialized dictionary with the entries of the given dictionary.
  1280. **/
  1281. - (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
  1282. /**
  1283. * Initializes this dictionary with the requested capacity.
  1284. *
  1285. * @param numItems Number of items needed for this dictionary.
  1286. *
  1287. * @return A newly initialized dictionary with the requested capacity.
  1288. **/
  1289. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1290. /**
  1291. * Gets the value for the given key.
  1292. *
  1293. * @param value Pointer into which the value will be set, if found.
  1294. * @param key Key under which the value is stored, if present.
  1295. *
  1296. * @return YES if the key was found and the value was copied, NO otherwise.
  1297. **/
  1298. - (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key;
  1299. /**
  1300. * Enumerates the keys and values on this dictionary with the given block.
  1301. *
  1302. * @param block The block to enumerate with.
  1303. * **key**: The key for the current entry.
  1304. * **value**: The value for the current entry
  1305. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1306. **/
  1307. - (void)enumerateKeysAndFloatsUsingBlock:
  1308. (void (NS_NOESCAPE ^)(int32_t key, float value, BOOL *stop))block;
  1309. /**
  1310. * Adds the keys and values from another dictionary.
  1311. *
  1312. * @param otherDictionary Dictionary containing entries to be added to this
  1313. * dictionary.
  1314. **/
  1315. - (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;
  1316. /**
  1317. * Sets the value for the given key.
  1318. *
  1319. * @param value The value to set.
  1320. * @param key The key under which to store the value.
  1321. **/
  1322. - (void)setFloat:(float)value forKey:(int32_t)key;
  1323. /**
  1324. * Removes the entry for the given key.
  1325. *
  1326. * @param aKey Key to be removed from this dictionary.
  1327. **/
  1328. - (void)removeFloatForKey:(int32_t)aKey;
  1329. /**
  1330. * Removes all entries in this dictionary.
  1331. **/
  1332. - (void)removeAll;
  1333. @end
  1334. #pragma mark - Int32 -> Double
  1335. /**
  1336. * Class used for map fields of <int32_t, double>
  1337. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1338. *
  1339. * @note This class is not meant to be subclassed.
  1340. **/
  1341. @interface GPBInt32DoubleDictionary : NSObject <NSCopying>
  1342. /** Number of entries stored in this dictionary. */
  1343. @property(nonatomic, readonly) NSUInteger count;
  1344. /**
  1345. * Initializes this dictionary, copying the given values and keys.
  1346. *
  1347. * @param values The values to be placed in this dictionary.
  1348. * @param keys The keys under which to store the values.
  1349. * @param count The number of elements to copy into the dictionary.
  1350. *
  1351. * @return A newly initialized dictionary with a copy of the values and keys.
  1352. **/
  1353. - (instancetype)initWithDoubles:(const double [__nullable])values
  1354. forKeys:(const int32_t [__nullable])keys
  1355. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1356. /**
  1357. * Initializes this dictionary, copying the entries from the given dictionary.
  1358. *
  1359. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1360. *
  1361. * @return A newly initialized dictionary with the entries of the given dictionary.
  1362. **/
  1363. - (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
  1364. /**
  1365. * Initializes this dictionary with the requested capacity.
  1366. *
  1367. * @param numItems Number of items needed for this dictionary.
  1368. *
  1369. * @return A newly initialized dictionary with the requested capacity.
  1370. **/
  1371. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1372. /**
  1373. * Gets the value for the given key.
  1374. *
  1375. * @param value Pointer into which the value will be set, if found.
  1376. * @param key Key under which the value is stored, if present.
  1377. *
  1378. * @return YES if the key was found and the value was copied, NO otherwise.
  1379. **/
  1380. - (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key;
  1381. /**
  1382. * Enumerates the keys and values on this dictionary with the given block.
  1383. *
  1384. * @param block The block to enumerate with.
  1385. * **key**: The key for the current entry.
  1386. * **value**: The value for the current entry
  1387. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1388. **/
  1389. - (void)enumerateKeysAndDoublesUsingBlock:
  1390. (void (NS_NOESCAPE ^)(int32_t key, double value, BOOL *stop))block;
  1391. /**
  1392. * Adds the keys and values from another dictionary.
  1393. *
  1394. * @param otherDictionary Dictionary containing entries to be added to this
  1395. * dictionary.
  1396. **/
  1397. - (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;
  1398. /**
  1399. * Sets the value for the given key.
  1400. *
  1401. * @param value The value to set.
  1402. * @param key The key under which to store the value.
  1403. **/
  1404. - (void)setDouble:(double)value forKey:(int32_t)key;
  1405. /**
  1406. * Removes the entry for the given key.
  1407. *
  1408. * @param aKey Key to be removed from this dictionary.
  1409. **/
  1410. - (void)removeDoubleForKey:(int32_t)aKey;
  1411. /**
  1412. * Removes all entries in this dictionary.
  1413. **/
  1414. - (void)removeAll;
  1415. @end
  1416. #pragma mark - Int32 -> Enum
  1417. /**
  1418. * Class used for map fields of <int32_t, int32_t>
  1419. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1420. *
  1421. * @note This class is not meant to be subclassed.
  1422. **/
  1423. @interface GPBInt32EnumDictionary : NSObject <NSCopying>
  1424. /** Number of entries stored in this dictionary. */
  1425. @property(nonatomic, readonly) NSUInteger count;
  1426. /** The validation function to check if the enums are valid. */
  1427. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  1428. /**
  1429. * Initializes a dictionary with the given validation function.
  1430. *
  1431. * @param func The enum validation function for the dictionary.
  1432. *
  1433. * @return A newly initialized dictionary.
  1434. **/
  1435. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  1436. /**
  1437. * Initializes a dictionary with the entries given.
  1438. *
  1439. * @param func The enum validation function for the dictionary.
  1440. * @param values The raw enum values values to be placed in the dictionary.
  1441. * @param keys The keys under which to store the values.
  1442. * @param count The number of entries to store in the dictionary.
  1443. *
  1444. * @return A newly initialized dictionary with the keys and values in it.
  1445. **/
  1446. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1447. rawValues:(const int32_t [__nullable])values
  1448. forKeys:(const int32_t [__nullable])keys
  1449. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1450. /**
  1451. * Initializes a dictionary with the entries from the given.
  1452. * dictionary.
  1453. *
  1454. * @param dictionary Dictionary containing the entries to add to the dictionary.
  1455. *
  1456. * @return A newly initialized dictionary with the entries from the given
  1457. * dictionary in it.
  1458. **/
  1459. - (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
  1460. /**
  1461. * Initializes a dictionary with the given capacity.
  1462. *
  1463. * @param func The enum validation function for the dictionary.
  1464. * @param numItems Capacity needed for the dictionary.
  1465. *
  1466. * @return A newly initialized dictionary with the given capacity.
  1467. **/
  1468. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  1469. capacity:(NSUInteger)numItems;
  1470. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  1471. // is not a valid enumerator as defined by validationFunc. If the actual value is
  1472. // desired, use "raw" version of the method.
  1473. /**
  1474. * Gets the value for the given key.
  1475. *
  1476. * @param value Pointer into which the value will be set, if found.
  1477. * @param key Key under which the value is stored, if present.
  1478. *
  1479. * @return YES if the key was found and the value was copied, NO otherwise.
  1480. **/
  1481. - (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key;
  1482. /**
  1483. * Enumerates the keys and values on this dictionary with the given block.
  1484. *
  1485. * @param block The block to enumerate with.
  1486. * **key**: The key for the current entry.
  1487. * **value**: The value for the current entry
  1488. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1489. **/
  1490. - (void)enumerateKeysAndEnumsUsingBlock:
  1491. (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block;
  1492. /**
  1493. * Gets the raw enum value for the given key.
  1494. *
  1495. * @note This method bypass the validationFunc to enable the access of values that
  1496. * were not known at the time the binary was compiled.
  1497. *
  1498. * @param rawValue Pointer into which the value will be set, if found.
  1499. * @param key Key under which the value is stored, if present.
  1500. *
  1501. * @return YES if the key was found and the value was copied, NO otherwise.
  1502. **/
  1503. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key;
  1504. /**
  1505. * Enumerates the keys and values on this dictionary with the given block.
  1506. *
  1507. * @note This method bypass the validationFunc to enable the access of values that
  1508. * were not known at the time the binary was compiled.
  1509. *
  1510. * @param block The block to enumerate with.
  1511. * **key**: The key for the current entry.
  1512. * **rawValue**: The value for the current entry
  1513. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1514. **/
  1515. - (void)enumerateKeysAndRawValuesUsingBlock:
  1516. (void (NS_NOESCAPE ^)(int32_t key, int32_t rawValue, BOOL *stop))block;
  1517. /**
  1518. * Adds the keys and raw enum values from another dictionary.
  1519. *
  1520. * @note This method bypass the validationFunc to enable the setting of values that
  1521. * were not known at the time the binary was compiled.
  1522. *
  1523. * @param otherDictionary Dictionary containing entries to be added to this
  1524. * dictionary.
  1525. **/
  1526. - (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;
  1527. // If value is not a valid enumerator as defined by validationFunc, these
  1528. // methods will assert in debug, and will log in release and assign the value
  1529. // to the default value. Use the rawValue methods below to assign non enumerator
  1530. // values.
  1531. /**
  1532. * Sets the value for the given key.
  1533. *
  1534. * @param value The value to set.
  1535. * @param key The key under which to store the value.
  1536. **/
  1537. - (void)setEnum:(int32_t)value forKey:(int32_t)key;
  1538. /**
  1539. * Sets the raw enum value for the given key.
  1540. *
  1541. * @note This method bypass the validationFunc to enable the setting of values that
  1542. * were not known at the time the binary was compiled.
  1543. *
  1544. * @param rawValue The raw enum value to set.
  1545. * @param key The key under which to store the raw enum value.
  1546. **/
  1547. - (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;
  1548. /**
  1549. * Removes the entry for the given key.
  1550. *
  1551. * @param aKey Key to be removed from this dictionary.
  1552. **/
  1553. - (void)removeEnumForKey:(int32_t)aKey;
  1554. /**
  1555. * Removes all entries in this dictionary.
  1556. **/
  1557. - (void)removeAll;
  1558. @end
  1559. #pragma mark - Int32 -> Object
  1560. /**
  1561. * Class used for map fields of <int32_t, ObjectType>
  1562. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1563. *
  1564. * @note This class is not meant to be subclassed.
  1565. **/
  1566. @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  1567. /** Number of entries stored in this dictionary. */
  1568. @property(nonatomic, readonly) NSUInteger count;
  1569. /**
  1570. * Initializes this dictionary, copying the given values and keys.
  1571. *
  1572. * @param objects The values to be placed in this dictionary.
  1573. * @param keys The keys under which to store the values.
  1574. * @param count The number of elements to copy into the dictionary.
  1575. *
  1576. * @return A newly initialized dictionary with a copy of the values and keys.
  1577. **/
  1578. - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
  1579. forKeys:(const int32_t [__nullable])keys
  1580. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1581. /**
  1582. * Initializes this dictionary, copying the entries from the given dictionary.
  1583. *
  1584. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1585. *
  1586. * @return A newly initialized dictionary with the entries of the given dictionary.
  1587. **/
  1588. - (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
  1589. /**
  1590. * Initializes this dictionary with the requested capacity.
  1591. *
  1592. * @param numItems Number of items needed for this dictionary.
  1593. *
  1594. * @return A newly initialized dictionary with the requested capacity.
  1595. **/
  1596. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1597. /**
  1598. * Fetches the object stored under the given key.
  1599. *
  1600. * @param key Key under which the value is stored, if present.
  1601. *
  1602. * @return The object if found, nil otherwise.
  1603. **/
  1604. - (ObjectType)objectForKey:(int32_t)key;
  1605. /**
  1606. * Enumerates the keys and values on this dictionary with the given block.
  1607. *
  1608. * @param block The block to enumerate with.
  1609. * **key**: The key for the current entry.
  1610. * **object**: The value for the current entry
  1611. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1612. **/
  1613. - (void)enumerateKeysAndObjectsUsingBlock:
  1614. (void (NS_NOESCAPE ^)(int32_t key, ObjectType object, BOOL *stop))block;
  1615. /**
  1616. * Adds the keys and values from another dictionary.
  1617. *
  1618. * @param otherDictionary Dictionary containing entries to be added to this
  1619. * dictionary.
  1620. **/
  1621. - (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
  1622. /**
  1623. * Sets the value for the given key.
  1624. *
  1625. * @param object The value to set.
  1626. * @param key The key under which to store the value.
  1627. **/
  1628. - (void)setObject:(ObjectType)object forKey:(int32_t)key;
  1629. /**
  1630. * Removes the entry for the given key.
  1631. *
  1632. * @param aKey Key to be removed from this dictionary.
  1633. **/
  1634. - (void)removeObjectForKey:(int32_t)aKey;
  1635. /**
  1636. * Removes all entries in this dictionary.
  1637. **/
  1638. - (void)removeAll;
  1639. @end
  1640. #pragma mark - UInt64 -> UInt32
  1641. /**
  1642. * Class used for map fields of <uint64_t, uint32_t>
  1643. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1644. *
  1645. * @note This class is not meant to be subclassed.
  1646. **/
  1647. @interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
  1648. /** Number of entries stored in this dictionary. */
  1649. @property(nonatomic, readonly) NSUInteger count;
  1650. /**
  1651. * Initializes this dictionary, copying the given values and keys.
  1652. *
  1653. * @param values The values to be placed in this dictionary.
  1654. * @param keys The keys under which to store the values.
  1655. * @param count The number of elements to copy into the dictionary.
  1656. *
  1657. * @return A newly initialized dictionary with a copy of the values and keys.
  1658. **/
  1659. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  1660. forKeys:(const uint64_t [__nullable])keys
  1661. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1662. /**
  1663. * Initializes this dictionary, copying the entries from the given dictionary.
  1664. *
  1665. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1666. *
  1667. * @return A newly initialized dictionary with the entries of the given dictionary.
  1668. **/
  1669. - (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
  1670. /**
  1671. * Initializes this dictionary with the requested capacity.
  1672. *
  1673. * @param numItems Number of items needed for this dictionary.
  1674. *
  1675. * @return A newly initialized dictionary with the requested capacity.
  1676. **/
  1677. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1678. /**
  1679. * Gets the value for the given key.
  1680. *
  1681. * @param value Pointer into which the value will be set, if found.
  1682. * @param key Key under which the value is stored, if present.
  1683. *
  1684. * @return YES if the key was found and the value was copied, NO otherwise.
  1685. **/
  1686. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key;
  1687. /**
  1688. * Enumerates the keys and values on this dictionary with the given block.
  1689. *
  1690. * @param block The block to enumerate with.
  1691. * **key**: The key for the current entry.
  1692. * **value**: The value for the current entry
  1693. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1694. **/
  1695. - (void)enumerateKeysAndUInt32sUsingBlock:
  1696. (void (NS_NOESCAPE ^)(uint64_t key, uint32_t value, BOOL *stop))block;
  1697. /**
  1698. * Adds the keys and values from another dictionary.
  1699. *
  1700. * @param otherDictionary Dictionary containing entries to be added to this
  1701. * dictionary.
  1702. **/
  1703. - (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;
  1704. /**
  1705. * Sets the value for the given key.
  1706. *
  1707. * @param value The value to set.
  1708. * @param key The key under which to store the value.
  1709. **/
  1710. - (void)setUInt32:(uint32_t)value forKey:(uint64_t)key;
  1711. /**
  1712. * Removes the entry for the given key.
  1713. *
  1714. * @param aKey Key to be removed from this dictionary.
  1715. **/
  1716. - (void)removeUInt32ForKey:(uint64_t)aKey;
  1717. /**
  1718. * Removes all entries in this dictionary.
  1719. **/
  1720. - (void)removeAll;
  1721. @end
  1722. #pragma mark - UInt64 -> Int32
  1723. /**
  1724. * Class used for map fields of <uint64_t, int32_t>
  1725. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1726. *
  1727. * @note This class is not meant to be subclassed.
  1728. **/
  1729. @interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
  1730. /** Number of entries stored in this dictionary. */
  1731. @property(nonatomic, readonly) NSUInteger count;
  1732. /**
  1733. * Initializes this dictionary, copying the given values and keys.
  1734. *
  1735. * @param values The values to be placed in this dictionary.
  1736. * @param keys The keys under which to store the values.
  1737. * @param count The number of elements to copy into the dictionary.
  1738. *
  1739. * @return A newly initialized dictionary with a copy of the values and keys.
  1740. **/
  1741. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  1742. forKeys:(const uint64_t [__nullable])keys
  1743. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1744. /**
  1745. * Initializes this dictionary, copying the entries from the given dictionary.
  1746. *
  1747. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1748. *
  1749. * @return A newly initialized dictionary with the entries of the given dictionary.
  1750. **/
  1751. - (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
  1752. /**
  1753. * Initializes this dictionary with the requested capacity.
  1754. *
  1755. * @param numItems Number of items needed for this dictionary.
  1756. *
  1757. * @return A newly initialized dictionary with the requested capacity.
  1758. **/
  1759. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1760. /**
  1761. * Gets the value for the given key.
  1762. *
  1763. * @param value Pointer into which the value will be set, if found.
  1764. * @param key Key under which the value is stored, if present.
  1765. *
  1766. * @return YES if the key was found and the value was copied, NO otherwise.
  1767. **/
  1768. - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key;
  1769. /**
  1770. * Enumerates the keys and values on this dictionary with the given block.
  1771. *
  1772. * @param block The block to enumerate with.
  1773. * **key**: The key for the current entry.
  1774. * **value**: The value for the current entry
  1775. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1776. **/
  1777. - (void)enumerateKeysAndInt32sUsingBlock:
  1778. (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block;
  1779. /**
  1780. * Adds the keys and values from another dictionary.
  1781. *
  1782. * @param otherDictionary Dictionary containing entries to be added to this
  1783. * dictionary.
  1784. **/
  1785. - (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;
  1786. /**
  1787. * Sets the value for the given key.
  1788. *
  1789. * @param value The value to set.
  1790. * @param key The key under which to store the value.
  1791. **/
  1792. - (void)setInt32:(int32_t)value forKey:(uint64_t)key;
  1793. /**
  1794. * Removes the entry for the given key.
  1795. *
  1796. * @param aKey Key to be removed from this dictionary.
  1797. **/
  1798. - (void)removeInt32ForKey:(uint64_t)aKey;
  1799. /**
  1800. * Removes all entries in this dictionary.
  1801. **/
  1802. - (void)removeAll;
  1803. @end
  1804. #pragma mark - UInt64 -> UInt64
  1805. /**
  1806. * Class used for map fields of <uint64_t, uint64_t>
  1807. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1808. *
  1809. * @note This class is not meant to be subclassed.
  1810. **/
  1811. @interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
  1812. /** Number of entries stored in this dictionary. */
  1813. @property(nonatomic, readonly) NSUInteger count;
  1814. /**
  1815. * Initializes this dictionary, copying the given values and keys.
  1816. *
  1817. * @param values The values to be placed in this dictionary.
  1818. * @param keys The keys under which to store the values.
  1819. * @param count The number of elements to copy into the dictionary.
  1820. *
  1821. * @return A newly initialized dictionary with a copy of the values and keys.
  1822. **/
  1823. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  1824. forKeys:(const uint64_t [__nullable])keys
  1825. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1826. /**
  1827. * Initializes this dictionary, copying the entries from the given dictionary.
  1828. *
  1829. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1830. *
  1831. * @return A newly initialized dictionary with the entries of the given dictionary.
  1832. **/
  1833. - (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
  1834. /**
  1835. * Initializes this dictionary with the requested capacity.
  1836. *
  1837. * @param numItems Number of items needed for this dictionary.
  1838. *
  1839. * @return A newly initialized dictionary with the requested capacity.
  1840. **/
  1841. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1842. /**
  1843. * Gets the value for the given key.
  1844. *
  1845. * @param value Pointer into which the value will be set, if found.
  1846. * @param key Key under which the value is stored, if present.
  1847. *
  1848. * @return YES if the key was found and the value was copied, NO otherwise.
  1849. **/
  1850. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key;
  1851. /**
  1852. * Enumerates the keys and values on this dictionary with the given block.
  1853. *
  1854. * @param block The block to enumerate with.
  1855. * **key**: The key for the current entry.
  1856. * **value**: The value for the current entry
  1857. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1858. **/
  1859. - (void)enumerateKeysAndUInt64sUsingBlock:
  1860. (void (NS_NOESCAPE ^)(uint64_t key, uint64_t value, BOOL *stop))block;
  1861. /**
  1862. * Adds the keys and values from another dictionary.
  1863. *
  1864. * @param otherDictionary Dictionary containing entries to be added to this
  1865. * dictionary.
  1866. **/
  1867. - (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;
  1868. /**
  1869. * Sets the value for the given key.
  1870. *
  1871. * @param value The value to set.
  1872. * @param key The key under which to store the value.
  1873. **/
  1874. - (void)setUInt64:(uint64_t)value forKey:(uint64_t)key;
  1875. /**
  1876. * Removes the entry for the given key.
  1877. *
  1878. * @param aKey Key to be removed from this dictionary.
  1879. **/
  1880. - (void)removeUInt64ForKey:(uint64_t)aKey;
  1881. /**
  1882. * Removes all entries in this dictionary.
  1883. **/
  1884. - (void)removeAll;
  1885. @end
  1886. #pragma mark - UInt64 -> Int64
  1887. /**
  1888. * Class used for map fields of <uint64_t, int64_t>
  1889. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1890. *
  1891. * @note This class is not meant to be subclassed.
  1892. **/
  1893. @interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
  1894. /** Number of entries stored in this dictionary. */
  1895. @property(nonatomic, readonly) NSUInteger count;
  1896. /**
  1897. * Initializes this dictionary, copying the given values and keys.
  1898. *
  1899. * @param values The values to be placed in this dictionary.
  1900. * @param keys The keys under which to store the values.
  1901. * @param count The number of elements to copy into the dictionary.
  1902. *
  1903. * @return A newly initialized dictionary with a copy of the values and keys.
  1904. **/
  1905. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  1906. forKeys:(const uint64_t [__nullable])keys
  1907. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1908. /**
  1909. * Initializes this dictionary, copying the entries from the given dictionary.
  1910. *
  1911. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1912. *
  1913. * @return A newly initialized dictionary with the entries of the given dictionary.
  1914. **/
  1915. - (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
  1916. /**
  1917. * Initializes this dictionary with the requested capacity.
  1918. *
  1919. * @param numItems Number of items needed for this dictionary.
  1920. *
  1921. * @return A newly initialized dictionary with the requested capacity.
  1922. **/
  1923. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  1924. /**
  1925. * Gets the value for the given key.
  1926. *
  1927. * @param value Pointer into which the value will be set, if found.
  1928. * @param key Key under which the value is stored, if present.
  1929. *
  1930. * @return YES if the key was found and the value was copied, NO otherwise.
  1931. **/
  1932. - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key;
  1933. /**
  1934. * Enumerates the keys and values on this dictionary with the given block.
  1935. *
  1936. * @param block The block to enumerate with.
  1937. * **key**: The key for the current entry.
  1938. * **value**: The value for the current entry
  1939. * **stop**: A pointer to a boolean that when set stops the enumeration.
  1940. **/
  1941. - (void)enumerateKeysAndInt64sUsingBlock:
  1942. (void (NS_NOESCAPE ^)(uint64_t key, int64_t value, BOOL *stop))block;
  1943. /**
  1944. * Adds the keys and values from another dictionary.
  1945. *
  1946. * @param otherDictionary Dictionary containing entries to be added to this
  1947. * dictionary.
  1948. **/
  1949. - (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;
  1950. /**
  1951. * Sets the value for the given key.
  1952. *
  1953. * @param value The value to set.
  1954. * @param key The key under which to store the value.
  1955. **/
  1956. - (void)setInt64:(int64_t)value forKey:(uint64_t)key;
  1957. /**
  1958. * Removes the entry for the given key.
  1959. *
  1960. * @param aKey Key to be removed from this dictionary.
  1961. **/
  1962. - (void)removeInt64ForKey:(uint64_t)aKey;
  1963. /**
  1964. * Removes all entries in this dictionary.
  1965. **/
  1966. - (void)removeAll;
  1967. @end
  1968. #pragma mark - UInt64 -> Bool
  1969. /**
  1970. * Class used for map fields of <uint64_t, BOOL>
  1971. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  1972. *
  1973. * @note This class is not meant to be subclassed.
  1974. **/
  1975. @interface GPBUInt64BoolDictionary : NSObject <NSCopying>
  1976. /** Number of entries stored in this dictionary. */
  1977. @property(nonatomic, readonly) NSUInteger count;
  1978. /**
  1979. * Initializes this dictionary, copying the given values and keys.
  1980. *
  1981. * @param values The values to be placed in this dictionary.
  1982. * @param keys The keys under which to store the values.
  1983. * @param count The number of elements to copy into the dictionary.
  1984. *
  1985. * @return A newly initialized dictionary with a copy of the values and keys.
  1986. **/
  1987. - (instancetype)initWithBools:(const BOOL [__nullable])values
  1988. forKeys:(const uint64_t [__nullable])keys
  1989. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  1990. /**
  1991. * Initializes this dictionary, copying the entries from the given dictionary.
  1992. *
  1993. * @param dictionary Dictionary containing the entries to add to this dictionary.
  1994. *
  1995. * @return A newly initialized dictionary with the entries of the given dictionary.
  1996. **/
  1997. - (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
  1998. /**
  1999. * Initializes this dictionary with the requested capacity.
  2000. *
  2001. * @param numItems Number of items needed for this dictionary.
  2002. *
  2003. * @return A newly initialized dictionary with the requested capacity.
  2004. **/
  2005. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2006. /**
  2007. * Gets the value for the given key.
  2008. *
  2009. * @param value Pointer into which the value will be set, if found.
  2010. * @param key Key under which the value is stored, if present.
  2011. *
  2012. * @return YES if the key was found and the value was copied, NO otherwise.
  2013. **/
  2014. - (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key;
  2015. /**
  2016. * Enumerates the keys and values on this dictionary with the given block.
  2017. *
  2018. * @param block The block to enumerate with.
  2019. * **key**: The key for the current entry.
  2020. * **value**: The value for the current entry
  2021. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2022. **/
  2023. - (void)enumerateKeysAndBoolsUsingBlock:
  2024. (void (NS_NOESCAPE ^)(uint64_t key, BOOL value, BOOL *stop))block;
  2025. /**
  2026. * Adds the keys and values from another dictionary.
  2027. *
  2028. * @param otherDictionary Dictionary containing entries to be added to this
  2029. * dictionary.
  2030. **/
  2031. - (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;
  2032. /**
  2033. * Sets the value for the given key.
  2034. *
  2035. * @param value The value to set.
  2036. * @param key The key under which to store the value.
  2037. **/
  2038. - (void)setBool:(BOOL)value forKey:(uint64_t)key;
  2039. /**
  2040. * Removes the entry for the given key.
  2041. *
  2042. * @param aKey Key to be removed from this dictionary.
  2043. **/
  2044. - (void)removeBoolForKey:(uint64_t)aKey;
  2045. /**
  2046. * Removes all entries in this dictionary.
  2047. **/
  2048. - (void)removeAll;
  2049. @end
  2050. #pragma mark - UInt64 -> Float
  2051. /**
  2052. * Class used for map fields of <uint64_t, float>
  2053. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2054. *
  2055. * @note This class is not meant to be subclassed.
  2056. **/
  2057. @interface GPBUInt64FloatDictionary : NSObject <NSCopying>
  2058. /** Number of entries stored in this dictionary. */
  2059. @property(nonatomic, readonly) NSUInteger count;
  2060. /**
  2061. * Initializes this dictionary, copying the given values and keys.
  2062. *
  2063. * @param values The values to be placed in this dictionary.
  2064. * @param keys The keys under which to store the values.
  2065. * @param count The number of elements to copy into the dictionary.
  2066. *
  2067. * @return A newly initialized dictionary with a copy of the values and keys.
  2068. **/
  2069. - (instancetype)initWithFloats:(const float [__nullable])values
  2070. forKeys:(const uint64_t [__nullable])keys
  2071. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2072. /**
  2073. * Initializes this dictionary, copying the entries from the given dictionary.
  2074. *
  2075. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2076. *
  2077. * @return A newly initialized dictionary with the entries of the given dictionary.
  2078. **/
  2079. - (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
  2080. /**
  2081. * Initializes this dictionary with the requested capacity.
  2082. *
  2083. * @param numItems Number of items needed for this dictionary.
  2084. *
  2085. * @return A newly initialized dictionary with the requested capacity.
  2086. **/
  2087. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2088. /**
  2089. * Gets the value for the given key.
  2090. *
  2091. * @param value Pointer into which the value will be set, if found.
  2092. * @param key Key under which the value is stored, if present.
  2093. *
  2094. * @return YES if the key was found and the value was copied, NO otherwise.
  2095. **/
  2096. - (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key;
  2097. /**
  2098. * Enumerates the keys and values on this dictionary with the given block.
  2099. *
  2100. * @param block The block to enumerate with.
  2101. * **key**: The key for the current entry.
  2102. * **value**: The value for the current entry
  2103. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2104. **/
  2105. - (void)enumerateKeysAndFloatsUsingBlock:
  2106. (void (NS_NOESCAPE ^)(uint64_t key, float value, BOOL *stop))block;
  2107. /**
  2108. * Adds the keys and values from another dictionary.
  2109. *
  2110. * @param otherDictionary Dictionary containing entries to be added to this
  2111. * dictionary.
  2112. **/
  2113. - (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;
  2114. /**
  2115. * Sets the value for the given key.
  2116. *
  2117. * @param value The value to set.
  2118. * @param key The key under which to store the value.
  2119. **/
  2120. - (void)setFloat:(float)value forKey:(uint64_t)key;
  2121. /**
  2122. * Removes the entry for the given key.
  2123. *
  2124. * @param aKey Key to be removed from this dictionary.
  2125. **/
  2126. - (void)removeFloatForKey:(uint64_t)aKey;
  2127. /**
  2128. * Removes all entries in this dictionary.
  2129. **/
  2130. - (void)removeAll;
  2131. @end
  2132. #pragma mark - UInt64 -> Double
  2133. /**
  2134. * Class used for map fields of <uint64_t, double>
  2135. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2136. *
  2137. * @note This class is not meant to be subclassed.
  2138. **/
  2139. @interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
  2140. /** Number of entries stored in this dictionary. */
  2141. @property(nonatomic, readonly) NSUInteger count;
  2142. /**
  2143. * Initializes this dictionary, copying the given values and keys.
  2144. *
  2145. * @param values The values to be placed in this dictionary.
  2146. * @param keys The keys under which to store the values.
  2147. * @param count The number of elements to copy into the dictionary.
  2148. *
  2149. * @return A newly initialized dictionary with a copy of the values and keys.
  2150. **/
  2151. - (instancetype)initWithDoubles:(const double [__nullable])values
  2152. forKeys:(const uint64_t [__nullable])keys
  2153. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2154. /**
  2155. * Initializes this dictionary, copying the entries from the given dictionary.
  2156. *
  2157. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2158. *
  2159. * @return A newly initialized dictionary with the entries of the given dictionary.
  2160. **/
  2161. - (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
  2162. /**
  2163. * Initializes this dictionary with the requested capacity.
  2164. *
  2165. * @param numItems Number of items needed for this dictionary.
  2166. *
  2167. * @return A newly initialized dictionary with the requested capacity.
  2168. **/
  2169. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2170. /**
  2171. * Gets the value for the given key.
  2172. *
  2173. * @param value Pointer into which the value will be set, if found.
  2174. * @param key Key under which the value is stored, if present.
  2175. *
  2176. * @return YES if the key was found and the value was copied, NO otherwise.
  2177. **/
  2178. - (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key;
  2179. /**
  2180. * Enumerates the keys and values on this dictionary with the given block.
  2181. *
  2182. * @param block The block to enumerate with.
  2183. * **key**: The key for the current entry.
  2184. * **value**: The value for the current entry
  2185. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2186. **/
  2187. - (void)enumerateKeysAndDoublesUsingBlock:
  2188. (void (NS_NOESCAPE ^)(uint64_t key, double value, BOOL *stop))block;
  2189. /**
  2190. * Adds the keys and values from another dictionary.
  2191. *
  2192. * @param otherDictionary Dictionary containing entries to be added to this
  2193. * dictionary.
  2194. **/
  2195. - (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;
  2196. /**
  2197. * Sets the value for the given key.
  2198. *
  2199. * @param value The value to set.
  2200. * @param key The key under which to store the value.
  2201. **/
  2202. - (void)setDouble:(double)value forKey:(uint64_t)key;
  2203. /**
  2204. * Removes the entry for the given key.
  2205. *
  2206. * @param aKey Key to be removed from this dictionary.
  2207. **/
  2208. - (void)removeDoubleForKey:(uint64_t)aKey;
  2209. /**
  2210. * Removes all entries in this dictionary.
  2211. **/
  2212. - (void)removeAll;
  2213. @end
  2214. #pragma mark - UInt64 -> Enum
  2215. /**
  2216. * Class used for map fields of <uint64_t, int32_t>
  2217. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2218. *
  2219. * @note This class is not meant to be subclassed.
  2220. **/
  2221. @interface GPBUInt64EnumDictionary : NSObject <NSCopying>
  2222. /** Number of entries stored in this dictionary. */
  2223. @property(nonatomic, readonly) NSUInteger count;
  2224. /** The validation function to check if the enums are valid. */
  2225. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  2226. /**
  2227. * Initializes a dictionary with the given validation function.
  2228. *
  2229. * @param func The enum validation function for the dictionary.
  2230. *
  2231. * @return A newly initialized dictionary.
  2232. **/
  2233. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  2234. /**
  2235. * Initializes a dictionary with the entries given.
  2236. *
  2237. * @param func The enum validation function for the dictionary.
  2238. * @param values The raw enum values values to be placed in the dictionary.
  2239. * @param keys The keys under which to store the values.
  2240. * @param count The number of entries to store in the dictionary.
  2241. *
  2242. * @return A newly initialized dictionary with the keys and values in it.
  2243. **/
  2244. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  2245. rawValues:(const int32_t [__nullable])values
  2246. forKeys:(const uint64_t [__nullable])keys
  2247. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2248. /**
  2249. * Initializes a dictionary with the entries from the given.
  2250. * dictionary.
  2251. *
  2252. * @param dictionary Dictionary containing the entries to add to the dictionary.
  2253. *
  2254. * @return A newly initialized dictionary with the entries from the given
  2255. * dictionary in it.
  2256. **/
  2257. - (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
  2258. /**
  2259. * Initializes a dictionary with the given capacity.
  2260. *
  2261. * @param func The enum validation function for the dictionary.
  2262. * @param numItems Capacity needed for the dictionary.
  2263. *
  2264. * @return A newly initialized dictionary with the given capacity.
  2265. **/
  2266. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  2267. capacity:(NSUInteger)numItems;
  2268. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  2269. // is not a valid enumerator as defined by validationFunc. If the actual value is
  2270. // desired, use "raw" version of the method.
  2271. /**
  2272. * Gets the value for the given key.
  2273. *
  2274. * @param value Pointer into which the value will be set, if found.
  2275. * @param key Key under which the value is stored, if present.
  2276. *
  2277. * @return YES if the key was found and the value was copied, NO otherwise.
  2278. **/
  2279. - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key;
  2280. /**
  2281. * Enumerates the keys and values on this dictionary with the given block.
  2282. *
  2283. * @param block The block to enumerate with.
  2284. * **key**: The key for the current entry.
  2285. * **value**: The value for the current entry
  2286. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2287. **/
  2288. - (void)enumerateKeysAndEnumsUsingBlock:
  2289. (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block;
  2290. /**
  2291. * Gets the raw enum value for the given key.
  2292. *
  2293. * @note This method bypass the validationFunc to enable the access of values that
  2294. * were not known at the time the binary was compiled.
  2295. *
  2296. * @param rawValue Pointer into which the value will be set, if found.
  2297. * @param key Key under which the value is stored, if present.
  2298. *
  2299. * @return YES if the key was found and the value was copied, NO otherwise.
  2300. **/
  2301. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key;
  2302. /**
  2303. * Enumerates the keys and values on this dictionary with the given block.
  2304. *
  2305. * @note This method bypass the validationFunc to enable the access of values that
  2306. * were not known at the time the binary was compiled.
  2307. *
  2308. * @param block The block to enumerate with.
  2309. * **key**: The key for the current entry.
  2310. * **rawValue**: The value for the current entry
  2311. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2312. **/
  2313. - (void)enumerateKeysAndRawValuesUsingBlock:
  2314. (void (NS_NOESCAPE ^)(uint64_t key, int32_t rawValue, BOOL *stop))block;
  2315. /**
  2316. * Adds the keys and raw enum values from another dictionary.
  2317. *
  2318. * @note This method bypass the validationFunc to enable the setting of values that
  2319. * were not known at the time the binary was compiled.
  2320. *
  2321. * @param otherDictionary Dictionary containing entries to be added to this
  2322. * dictionary.
  2323. **/
  2324. - (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;
  2325. // If value is not a valid enumerator as defined by validationFunc, these
  2326. // methods will assert in debug, and will log in release and assign the value
  2327. // to the default value. Use the rawValue methods below to assign non enumerator
  2328. // values.
  2329. /**
  2330. * Sets the value for the given key.
  2331. *
  2332. * @param value The value to set.
  2333. * @param key The key under which to store the value.
  2334. **/
  2335. - (void)setEnum:(int32_t)value forKey:(uint64_t)key;
  2336. /**
  2337. * Sets the raw enum value for the given key.
  2338. *
  2339. * @note This method bypass the validationFunc to enable the setting of values that
  2340. * were not known at the time the binary was compiled.
  2341. *
  2342. * @param rawValue The raw enum value to set.
  2343. * @param key The key under which to store the raw enum value.
  2344. **/
  2345. - (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;
  2346. /**
  2347. * Removes the entry for the given key.
  2348. *
  2349. * @param aKey Key to be removed from this dictionary.
  2350. **/
  2351. - (void)removeEnumForKey:(uint64_t)aKey;
  2352. /**
  2353. * Removes all entries in this dictionary.
  2354. **/
  2355. - (void)removeAll;
  2356. @end
  2357. #pragma mark - UInt64 -> Object
  2358. /**
  2359. * Class used for map fields of <uint64_t, ObjectType>
  2360. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2361. *
  2362. * @note This class is not meant to be subclassed.
  2363. **/
  2364. @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  2365. /** Number of entries stored in this dictionary. */
  2366. @property(nonatomic, readonly) NSUInteger count;
  2367. /**
  2368. * Initializes this dictionary, copying the given values and keys.
  2369. *
  2370. * @param objects The values to be placed in this dictionary.
  2371. * @param keys The keys under which to store the values.
  2372. * @param count The number of elements to copy into the dictionary.
  2373. *
  2374. * @return A newly initialized dictionary with a copy of the values and keys.
  2375. **/
  2376. - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
  2377. forKeys:(const uint64_t [__nullable])keys
  2378. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2379. /**
  2380. * Initializes this dictionary, copying the entries from the given dictionary.
  2381. *
  2382. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2383. *
  2384. * @return A newly initialized dictionary with the entries of the given dictionary.
  2385. **/
  2386. - (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
  2387. /**
  2388. * Initializes this dictionary with the requested capacity.
  2389. *
  2390. * @param numItems Number of items needed for this dictionary.
  2391. *
  2392. * @return A newly initialized dictionary with the requested capacity.
  2393. **/
  2394. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2395. /**
  2396. * Fetches the object stored under the given key.
  2397. *
  2398. * @param key Key under which the value is stored, if present.
  2399. *
  2400. * @return The object if found, nil otherwise.
  2401. **/
  2402. - (ObjectType)objectForKey:(uint64_t)key;
  2403. /**
  2404. * Enumerates the keys and values on this dictionary with the given block.
  2405. *
  2406. * @param block The block to enumerate with.
  2407. * **key**: The key for the current entry.
  2408. * **object**: The value for the current entry
  2409. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2410. **/
  2411. - (void)enumerateKeysAndObjectsUsingBlock:
  2412. (void (NS_NOESCAPE ^)(uint64_t key, ObjectType object, BOOL *stop))block;
  2413. /**
  2414. * Adds the keys and values from another dictionary.
  2415. *
  2416. * @param otherDictionary Dictionary containing entries to be added to this
  2417. * dictionary.
  2418. **/
  2419. - (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
  2420. /**
  2421. * Sets the value for the given key.
  2422. *
  2423. * @param object The value to set.
  2424. * @param key The key under which to store the value.
  2425. **/
  2426. - (void)setObject:(ObjectType)object forKey:(uint64_t)key;
  2427. /**
  2428. * Removes the entry for the given key.
  2429. *
  2430. * @param aKey Key to be removed from this dictionary.
  2431. **/
  2432. - (void)removeObjectForKey:(uint64_t)aKey;
  2433. /**
  2434. * Removes all entries in this dictionary.
  2435. **/
  2436. - (void)removeAll;
  2437. @end
  2438. #pragma mark - Int64 -> UInt32
  2439. /**
  2440. * Class used for map fields of <int64_t, uint32_t>
  2441. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2442. *
  2443. * @note This class is not meant to be subclassed.
  2444. **/
  2445. @interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
  2446. /** Number of entries stored in this dictionary. */
  2447. @property(nonatomic, readonly) NSUInteger count;
  2448. /**
  2449. * Initializes this dictionary, copying the given values and keys.
  2450. *
  2451. * @param values The values to be placed in this dictionary.
  2452. * @param keys The keys under which to store the values.
  2453. * @param count The number of elements to copy into the dictionary.
  2454. *
  2455. * @return A newly initialized dictionary with a copy of the values and keys.
  2456. **/
  2457. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  2458. forKeys:(const int64_t [__nullable])keys
  2459. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2460. /**
  2461. * Initializes this dictionary, copying the entries from the given dictionary.
  2462. *
  2463. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2464. *
  2465. * @return A newly initialized dictionary with the entries of the given dictionary.
  2466. **/
  2467. - (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
  2468. /**
  2469. * Initializes this dictionary with the requested capacity.
  2470. *
  2471. * @param numItems Number of items needed for this dictionary.
  2472. *
  2473. * @return A newly initialized dictionary with the requested capacity.
  2474. **/
  2475. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2476. /**
  2477. * Gets the value for the given key.
  2478. *
  2479. * @param value Pointer into which the value will be set, if found.
  2480. * @param key Key under which the value is stored, if present.
  2481. *
  2482. * @return YES if the key was found and the value was copied, NO otherwise.
  2483. **/
  2484. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key;
  2485. /**
  2486. * Enumerates the keys and values on this dictionary with the given block.
  2487. *
  2488. * @param block The block to enumerate with.
  2489. * **key**: The key for the current entry.
  2490. * **value**: The value for the current entry
  2491. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2492. **/
  2493. - (void)enumerateKeysAndUInt32sUsingBlock:
  2494. (void (NS_NOESCAPE ^)(int64_t key, uint32_t value, BOOL *stop))block;
  2495. /**
  2496. * Adds the keys and values from another dictionary.
  2497. *
  2498. * @param otherDictionary Dictionary containing entries to be added to this
  2499. * dictionary.
  2500. **/
  2501. - (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;
  2502. /**
  2503. * Sets the value for the given key.
  2504. *
  2505. * @param value The value to set.
  2506. * @param key The key under which to store the value.
  2507. **/
  2508. - (void)setUInt32:(uint32_t)value forKey:(int64_t)key;
  2509. /**
  2510. * Removes the entry for the given key.
  2511. *
  2512. * @param aKey Key to be removed from this dictionary.
  2513. **/
  2514. - (void)removeUInt32ForKey:(int64_t)aKey;
  2515. /**
  2516. * Removes all entries in this dictionary.
  2517. **/
  2518. - (void)removeAll;
  2519. @end
  2520. #pragma mark - Int64 -> Int32
  2521. /**
  2522. * Class used for map fields of <int64_t, int32_t>
  2523. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2524. *
  2525. * @note This class is not meant to be subclassed.
  2526. **/
  2527. @interface GPBInt64Int32Dictionary : NSObject <NSCopying>
  2528. /** Number of entries stored in this dictionary. */
  2529. @property(nonatomic, readonly) NSUInteger count;
  2530. /**
  2531. * Initializes this dictionary, copying the given values and keys.
  2532. *
  2533. * @param values The values to be placed in this dictionary.
  2534. * @param keys The keys under which to store the values.
  2535. * @param count The number of elements to copy into the dictionary.
  2536. *
  2537. * @return A newly initialized dictionary with a copy of the values and keys.
  2538. **/
  2539. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  2540. forKeys:(const int64_t [__nullable])keys
  2541. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2542. /**
  2543. * Initializes this dictionary, copying the entries from the given dictionary.
  2544. *
  2545. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2546. *
  2547. * @return A newly initialized dictionary with the entries of the given dictionary.
  2548. **/
  2549. - (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
  2550. /**
  2551. * Initializes this dictionary with the requested capacity.
  2552. *
  2553. * @param numItems Number of items needed for this dictionary.
  2554. *
  2555. * @return A newly initialized dictionary with the requested capacity.
  2556. **/
  2557. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2558. /**
  2559. * Gets the value for the given key.
  2560. *
  2561. * @param value Pointer into which the value will be set, if found.
  2562. * @param key Key under which the value is stored, if present.
  2563. *
  2564. * @return YES if the key was found and the value was copied, NO otherwise.
  2565. **/
  2566. - (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key;
  2567. /**
  2568. * Enumerates the keys and values on this dictionary with the given block.
  2569. *
  2570. * @param block The block to enumerate with.
  2571. * **key**: The key for the current entry.
  2572. * **value**: The value for the current entry
  2573. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2574. **/
  2575. - (void)enumerateKeysAndInt32sUsingBlock:
  2576. (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block;
  2577. /**
  2578. * Adds the keys and values from another dictionary.
  2579. *
  2580. * @param otherDictionary Dictionary containing entries to be added to this
  2581. * dictionary.
  2582. **/
  2583. - (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;
  2584. /**
  2585. * Sets the value for the given key.
  2586. *
  2587. * @param value The value to set.
  2588. * @param key The key under which to store the value.
  2589. **/
  2590. - (void)setInt32:(int32_t)value forKey:(int64_t)key;
  2591. /**
  2592. * Removes the entry for the given key.
  2593. *
  2594. * @param aKey Key to be removed from this dictionary.
  2595. **/
  2596. - (void)removeInt32ForKey:(int64_t)aKey;
  2597. /**
  2598. * Removes all entries in this dictionary.
  2599. **/
  2600. - (void)removeAll;
  2601. @end
  2602. #pragma mark - Int64 -> UInt64
  2603. /**
  2604. * Class used for map fields of <int64_t, uint64_t>
  2605. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2606. *
  2607. * @note This class is not meant to be subclassed.
  2608. **/
  2609. @interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
  2610. /** Number of entries stored in this dictionary. */
  2611. @property(nonatomic, readonly) NSUInteger count;
  2612. /**
  2613. * Initializes this dictionary, copying the given values and keys.
  2614. *
  2615. * @param values The values to be placed in this dictionary.
  2616. * @param keys The keys under which to store the values.
  2617. * @param count The number of elements to copy into the dictionary.
  2618. *
  2619. * @return A newly initialized dictionary with a copy of the values and keys.
  2620. **/
  2621. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  2622. forKeys:(const int64_t [__nullable])keys
  2623. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2624. /**
  2625. * Initializes this dictionary, copying the entries from the given dictionary.
  2626. *
  2627. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2628. *
  2629. * @return A newly initialized dictionary with the entries of the given dictionary.
  2630. **/
  2631. - (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
  2632. /**
  2633. * Initializes this dictionary with the requested capacity.
  2634. *
  2635. * @param numItems Number of items needed for this dictionary.
  2636. *
  2637. * @return A newly initialized dictionary with the requested capacity.
  2638. **/
  2639. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2640. /**
  2641. * Gets the value for the given key.
  2642. *
  2643. * @param value Pointer into which the value will be set, if found.
  2644. * @param key Key under which the value is stored, if present.
  2645. *
  2646. * @return YES if the key was found and the value was copied, NO otherwise.
  2647. **/
  2648. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key;
  2649. /**
  2650. * Enumerates the keys and values on this dictionary with the given block.
  2651. *
  2652. * @param block The block to enumerate with.
  2653. * **key**: The key for the current entry.
  2654. * **value**: The value for the current entry
  2655. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2656. **/
  2657. - (void)enumerateKeysAndUInt64sUsingBlock:
  2658. (void (NS_NOESCAPE ^)(int64_t key, uint64_t value, BOOL *stop))block;
  2659. /**
  2660. * Adds the keys and values from another dictionary.
  2661. *
  2662. * @param otherDictionary Dictionary containing entries to be added to this
  2663. * dictionary.
  2664. **/
  2665. - (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;
  2666. /**
  2667. * Sets the value for the given key.
  2668. *
  2669. * @param value The value to set.
  2670. * @param key The key under which to store the value.
  2671. **/
  2672. - (void)setUInt64:(uint64_t)value forKey:(int64_t)key;
  2673. /**
  2674. * Removes the entry for the given key.
  2675. *
  2676. * @param aKey Key to be removed from this dictionary.
  2677. **/
  2678. - (void)removeUInt64ForKey:(int64_t)aKey;
  2679. /**
  2680. * Removes all entries in this dictionary.
  2681. **/
  2682. - (void)removeAll;
  2683. @end
  2684. #pragma mark - Int64 -> Int64
  2685. /**
  2686. * Class used for map fields of <int64_t, int64_t>
  2687. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2688. *
  2689. * @note This class is not meant to be subclassed.
  2690. **/
  2691. @interface GPBInt64Int64Dictionary : NSObject <NSCopying>
  2692. /** Number of entries stored in this dictionary. */
  2693. @property(nonatomic, readonly) NSUInteger count;
  2694. /**
  2695. * Initializes this dictionary, copying the given values and keys.
  2696. *
  2697. * @param values The values to be placed in this dictionary.
  2698. * @param keys The keys under which to store the values.
  2699. * @param count The number of elements to copy into the dictionary.
  2700. *
  2701. * @return A newly initialized dictionary with a copy of the values and keys.
  2702. **/
  2703. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  2704. forKeys:(const int64_t [__nullable])keys
  2705. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2706. /**
  2707. * Initializes this dictionary, copying the entries from the given dictionary.
  2708. *
  2709. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2710. *
  2711. * @return A newly initialized dictionary with the entries of the given dictionary.
  2712. **/
  2713. - (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
  2714. /**
  2715. * Initializes this dictionary with the requested capacity.
  2716. *
  2717. * @param numItems Number of items needed for this dictionary.
  2718. *
  2719. * @return A newly initialized dictionary with the requested capacity.
  2720. **/
  2721. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2722. /**
  2723. * Gets the value for the given key.
  2724. *
  2725. * @param value Pointer into which the value will be set, if found.
  2726. * @param key Key under which the value is stored, if present.
  2727. *
  2728. * @return YES if the key was found and the value was copied, NO otherwise.
  2729. **/
  2730. - (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key;
  2731. /**
  2732. * Enumerates the keys and values on this dictionary with the given block.
  2733. *
  2734. * @param block The block to enumerate with.
  2735. * **key**: The key for the current entry.
  2736. * **value**: The value for the current entry
  2737. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2738. **/
  2739. - (void)enumerateKeysAndInt64sUsingBlock:
  2740. (void (NS_NOESCAPE ^)(int64_t key, int64_t value, BOOL *stop))block;
  2741. /**
  2742. * Adds the keys and values from another dictionary.
  2743. *
  2744. * @param otherDictionary Dictionary containing entries to be added to this
  2745. * dictionary.
  2746. **/
  2747. - (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;
  2748. /**
  2749. * Sets the value for the given key.
  2750. *
  2751. * @param value The value to set.
  2752. * @param key The key under which to store the value.
  2753. **/
  2754. - (void)setInt64:(int64_t)value forKey:(int64_t)key;
  2755. /**
  2756. * Removes the entry for the given key.
  2757. *
  2758. * @param aKey Key to be removed from this dictionary.
  2759. **/
  2760. - (void)removeInt64ForKey:(int64_t)aKey;
  2761. /**
  2762. * Removes all entries in this dictionary.
  2763. **/
  2764. - (void)removeAll;
  2765. @end
  2766. #pragma mark - Int64 -> Bool
  2767. /**
  2768. * Class used for map fields of <int64_t, BOOL>
  2769. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2770. *
  2771. * @note This class is not meant to be subclassed.
  2772. **/
  2773. @interface GPBInt64BoolDictionary : NSObject <NSCopying>
  2774. /** Number of entries stored in this dictionary. */
  2775. @property(nonatomic, readonly) NSUInteger count;
  2776. /**
  2777. * Initializes this dictionary, copying the given values and keys.
  2778. *
  2779. * @param values The values to be placed in this dictionary.
  2780. * @param keys The keys under which to store the values.
  2781. * @param count The number of elements to copy into the dictionary.
  2782. *
  2783. * @return A newly initialized dictionary with a copy of the values and keys.
  2784. **/
  2785. - (instancetype)initWithBools:(const BOOL [__nullable])values
  2786. forKeys:(const int64_t [__nullable])keys
  2787. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2788. /**
  2789. * Initializes this dictionary, copying the entries from the given dictionary.
  2790. *
  2791. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2792. *
  2793. * @return A newly initialized dictionary with the entries of the given dictionary.
  2794. **/
  2795. - (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
  2796. /**
  2797. * Initializes this dictionary with the requested capacity.
  2798. *
  2799. * @param numItems Number of items needed for this dictionary.
  2800. *
  2801. * @return A newly initialized dictionary with the requested capacity.
  2802. **/
  2803. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2804. /**
  2805. * Gets the value for the given key.
  2806. *
  2807. * @param value Pointer into which the value will be set, if found.
  2808. * @param key Key under which the value is stored, if present.
  2809. *
  2810. * @return YES if the key was found and the value was copied, NO otherwise.
  2811. **/
  2812. - (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key;
  2813. /**
  2814. * Enumerates the keys and values on this dictionary with the given block.
  2815. *
  2816. * @param block The block to enumerate with.
  2817. * **key**: The key for the current entry.
  2818. * **value**: The value for the current entry
  2819. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2820. **/
  2821. - (void)enumerateKeysAndBoolsUsingBlock:
  2822. (void (NS_NOESCAPE ^)(int64_t key, BOOL value, BOOL *stop))block;
  2823. /**
  2824. * Adds the keys and values from another dictionary.
  2825. *
  2826. * @param otherDictionary Dictionary containing entries to be added to this
  2827. * dictionary.
  2828. **/
  2829. - (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;
  2830. /**
  2831. * Sets the value for the given key.
  2832. *
  2833. * @param value The value to set.
  2834. * @param key The key under which to store the value.
  2835. **/
  2836. - (void)setBool:(BOOL)value forKey:(int64_t)key;
  2837. /**
  2838. * Removes the entry for the given key.
  2839. *
  2840. * @param aKey Key to be removed from this dictionary.
  2841. **/
  2842. - (void)removeBoolForKey:(int64_t)aKey;
  2843. /**
  2844. * Removes all entries in this dictionary.
  2845. **/
  2846. - (void)removeAll;
  2847. @end
  2848. #pragma mark - Int64 -> Float
  2849. /**
  2850. * Class used for map fields of <int64_t, float>
  2851. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2852. *
  2853. * @note This class is not meant to be subclassed.
  2854. **/
  2855. @interface GPBInt64FloatDictionary : NSObject <NSCopying>
  2856. /** Number of entries stored in this dictionary. */
  2857. @property(nonatomic, readonly) NSUInteger count;
  2858. /**
  2859. * Initializes this dictionary, copying the given values and keys.
  2860. *
  2861. * @param values The values to be placed in this dictionary.
  2862. * @param keys The keys under which to store the values.
  2863. * @param count The number of elements to copy into the dictionary.
  2864. *
  2865. * @return A newly initialized dictionary with a copy of the values and keys.
  2866. **/
  2867. - (instancetype)initWithFloats:(const float [__nullable])values
  2868. forKeys:(const int64_t [__nullable])keys
  2869. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2870. /**
  2871. * Initializes this dictionary, copying the entries from the given dictionary.
  2872. *
  2873. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2874. *
  2875. * @return A newly initialized dictionary with the entries of the given dictionary.
  2876. **/
  2877. - (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
  2878. /**
  2879. * Initializes this dictionary with the requested capacity.
  2880. *
  2881. * @param numItems Number of items needed for this dictionary.
  2882. *
  2883. * @return A newly initialized dictionary with the requested capacity.
  2884. **/
  2885. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2886. /**
  2887. * Gets the value for the given key.
  2888. *
  2889. * @param value Pointer into which the value will be set, if found.
  2890. * @param key Key under which the value is stored, if present.
  2891. *
  2892. * @return YES if the key was found and the value was copied, NO otherwise.
  2893. **/
  2894. - (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key;
  2895. /**
  2896. * Enumerates the keys and values on this dictionary with the given block.
  2897. *
  2898. * @param block The block to enumerate with.
  2899. * **key**: The key for the current entry.
  2900. * **value**: The value for the current entry
  2901. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2902. **/
  2903. - (void)enumerateKeysAndFloatsUsingBlock:
  2904. (void (NS_NOESCAPE ^)(int64_t key, float value, BOOL *stop))block;
  2905. /**
  2906. * Adds the keys and values from another dictionary.
  2907. *
  2908. * @param otherDictionary Dictionary containing entries to be added to this
  2909. * dictionary.
  2910. **/
  2911. - (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;
  2912. /**
  2913. * Sets the value for the given key.
  2914. *
  2915. * @param value The value to set.
  2916. * @param key The key under which to store the value.
  2917. **/
  2918. - (void)setFloat:(float)value forKey:(int64_t)key;
  2919. /**
  2920. * Removes the entry for the given key.
  2921. *
  2922. * @param aKey Key to be removed from this dictionary.
  2923. **/
  2924. - (void)removeFloatForKey:(int64_t)aKey;
  2925. /**
  2926. * Removes all entries in this dictionary.
  2927. **/
  2928. - (void)removeAll;
  2929. @end
  2930. #pragma mark - Int64 -> Double
  2931. /**
  2932. * Class used for map fields of <int64_t, double>
  2933. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  2934. *
  2935. * @note This class is not meant to be subclassed.
  2936. **/
  2937. @interface GPBInt64DoubleDictionary : NSObject <NSCopying>
  2938. /** Number of entries stored in this dictionary. */
  2939. @property(nonatomic, readonly) NSUInteger count;
  2940. /**
  2941. * Initializes this dictionary, copying the given values and keys.
  2942. *
  2943. * @param values The values to be placed in this dictionary.
  2944. * @param keys The keys under which to store the values.
  2945. * @param count The number of elements to copy into the dictionary.
  2946. *
  2947. * @return A newly initialized dictionary with a copy of the values and keys.
  2948. **/
  2949. - (instancetype)initWithDoubles:(const double [__nullable])values
  2950. forKeys:(const int64_t [__nullable])keys
  2951. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  2952. /**
  2953. * Initializes this dictionary, copying the entries from the given dictionary.
  2954. *
  2955. * @param dictionary Dictionary containing the entries to add to this dictionary.
  2956. *
  2957. * @return A newly initialized dictionary with the entries of the given dictionary.
  2958. **/
  2959. - (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
  2960. /**
  2961. * Initializes this dictionary with the requested capacity.
  2962. *
  2963. * @param numItems Number of items needed for this dictionary.
  2964. *
  2965. * @return A newly initialized dictionary with the requested capacity.
  2966. **/
  2967. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  2968. /**
  2969. * Gets the value for the given key.
  2970. *
  2971. * @param value Pointer into which the value will be set, if found.
  2972. * @param key Key under which the value is stored, if present.
  2973. *
  2974. * @return YES if the key was found and the value was copied, NO otherwise.
  2975. **/
  2976. - (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key;
  2977. /**
  2978. * Enumerates the keys and values on this dictionary with the given block.
  2979. *
  2980. * @param block The block to enumerate with.
  2981. * **key**: The key for the current entry.
  2982. * **value**: The value for the current entry
  2983. * **stop**: A pointer to a boolean that when set stops the enumeration.
  2984. **/
  2985. - (void)enumerateKeysAndDoublesUsingBlock:
  2986. (void (NS_NOESCAPE ^)(int64_t key, double value, BOOL *stop))block;
  2987. /**
  2988. * Adds the keys and values from another dictionary.
  2989. *
  2990. * @param otherDictionary Dictionary containing entries to be added to this
  2991. * dictionary.
  2992. **/
  2993. - (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;
  2994. /**
  2995. * Sets the value for the given key.
  2996. *
  2997. * @param value The value to set.
  2998. * @param key The key under which to store the value.
  2999. **/
  3000. - (void)setDouble:(double)value forKey:(int64_t)key;
  3001. /**
  3002. * Removes the entry for the given key.
  3003. *
  3004. * @param aKey Key to be removed from this dictionary.
  3005. **/
  3006. - (void)removeDoubleForKey:(int64_t)aKey;
  3007. /**
  3008. * Removes all entries in this dictionary.
  3009. **/
  3010. - (void)removeAll;
  3011. @end
  3012. #pragma mark - Int64 -> Enum
  3013. /**
  3014. * Class used for map fields of <int64_t, int32_t>
  3015. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3016. *
  3017. * @note This class is not meant to be subclassed.
  3018. **/
  3019. @interface GPBInt64EnumDictionary : NSObject <NSCopying>
  3020. /** Number of entries stored in this dictionary. */
  3021. @property(nonatomic, readonly) NSUInteger count;
  3022. /** The validation function to check if the enums are valid. */
  3023. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  3024. /**
  3025. * Initializes a dictionary with the given validation function.
  3026. *
  3027. * @param func The enum validation function for the dictionary.
  3028. *
  3029. * @return A newly initialized dictionary.
  3030. **/
  3031. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  3032. /**
  3033. * Initializes a dictionary with the entries given.
  3034. *
  3035. * @param func The enum validation function for the dictionary.
  3036. * @param values The raw enum values values to be placed in the dictionary.
  3037. * @param keys The keys under which to store the values.
  3038. * @param count The number of entries to store in the dictionary.
  3039. *
  3040. * @return A newly initialized dictionary with the keys and values in it.
  3041. **/
  3042. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  3043. rawValues:(const int32_t [__nullable])values
  3044. forKeys:(const int64_t [__nullable])keys
  3045. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3046. /**
  3047. * Initializes a dictionary with the entries from the given.
  3048. * dictionary.
  3049. *
  3050. * @param dictionary Dictionary containing the entries to add to the dictionary.
  3051. *
  3052. * @return A newly initialized dictionary with the entries from the given
  3053. * dictionary in it.
  3054. **/
  3055. - (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
  3056. /**
  3057. * Initializes a dictionary with the given capacity.
  3058. *
  3059. * @param func The enum validation function for the dictionary.
  3060. * @param numItems Capacity needed for the dictionary.
  3061. *
  3062. * @return A newly initialized dictionary with the given capacity.
  3063. **/
  3064. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  3065. capacity:(NSUInteger)numItems;
  3066. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  3067. // is not a valid enumerator as defined by validationFunc. If the actual value is
  3068. // desired, use "raw" version of the method.
  3069. /**
  3070. * Gets the value for the given key.
  3071. *
  3072. * @param value Pointer into which the value will be set, if found.
  3073. * @param key Key under which the value is stored, if present.
  3074. *
  3075. * @return YES if the key was found and the value was copied, NO otherwise.
  3076. **/
  3077. - (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key;
  3078. /**
  3079. * Enumerates the keys and values on this dictionary with the given block.
  3080. *
  3081. * @param block The block to enumerate with.
  3082. * **key**: The key for the current entry.
  3083. * **value**: The value for the current entry
  3084. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3085. **/
  3086. - (void)enumerateKeysAndEnumsUsingBlock:
  3087. (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block;
  3088. /**
  3089. * Gets the raw enum value for the given key.
  3090. *
  3091. * @note This method bypass the validationFunc to enable the access of values that
  3092. * were not known at the time the binary was compiled.
  3093. *
  3094. * @param rawValue Pointer into which the value will be set, if found.
  3095. * @param key Key under which the value is stored, if present.
  3096. *
  3097. * @return YES if the key was found and the value was copied, NO otherwise.
  3098. **/
  3099. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key;
  3100. /**
  3101. * Enumerates the keys and values on this dictionary with the given block.
  3102. *
  3103. * @note This method bypass the validationFunc to enable the access of values that
  3104. * were not known at the time the binary was compiled.
  3105. *
  3106. * @param block The block to enumerate with.
  3107. * **key**: The key for the current entry.
  3108. * **rawValue**: The value for the current entry
  3109. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3110. **/
  3111. - (void)enumerateKeysAndRawValuesUsingBlock:
  3112. (void (NS_NOESCAPE ^)(int64_t key, int32_t rawValue, BOOL *stop))block;
  3113. /**
  3114. * Adds the keys and raw enum values from another dictionary.
  3115. *
  3116. * @note This method bypass the validationFunc to enable the setting of values that
  3117. * were not known at the time the binary was compiled.
  3118. *
  3119. * @param otherDictionary Dictionary containing entries to be added to this
  3120. * dictionary.
  3121. **/
  3122. - (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;
  3123. // If value is not a valid enumerator as defined by validationFunc, these
  3124. // methods will assert in debug, and will log in release and assign the value
  3125. // to the default value. Use the rawValue methods below to assign non enumerator
  3126. // values.
  3127. /**
  3128. * Sets the value for the given key.
  3129. *
  3130. * @param value The value to set.
  3131. * @param key The key under which to store the value.
  3132. **/
  3133. - (void)setEnum:(int32_t)value forKey:(int64_t)key;
  3134. /**
  3135. * Sets the raw enum value for the given key.
  3136. *
  3137. * @note This method bypass the validationFunc to enable the setting of values that
  3138. * were not known at the time the binary was compiled.
  3139. *
  3140. * @param rawValue The raw enum value to set.
  3141. * @param key The key under which to store the raw enum value.
  3142. **/
  3143. - (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;
  3144. /**
  3145. * Removes the entry for the given key.
  3146. *
  3147. * @param aKey Key to be removed from this dictionary.
  3148. **/
  3149. - (void)removeEnumForKey:(int64_t)aKey;
  3150. /**
  3151. * Removes all entries in this dictionary.
  3152. **/
  3153. - (void)removeAll;
  3154. @end
  3155. #pragma mark - Int64 -> Object
  3156. /**
  3157. * Class used for map fields of <int64_t, ObjectType>
  3158. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3159. *
  3160. * @note This class is not meant to be subclassed.
  3161. **/
  3162. @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  3163. /** Number of entries stored in this dictionary. */
  3164. @property(nonatomic, readonly) NSUInteger count;
  3165. /**
  3166. * Initializes this dictionary, copying the given values and keys.
  3167. *
  3168. * @param objects The values to be placed in this dictionary.
  3169. * @param keys The keys under which to store the values.
  3170. * @param count The number of elements to copy into the dictionary.
  3171. *
  3172. * @return A newly initialized dictionary with a copy of the values and keys.
  3173. **/
  3174. - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
  3175. forKeys:(const int64_t [__nullable])keys
  3176. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3177. /**
  3178. * Initializes this dictionary, copying the entries from the given dictionary.
  3179. *
  3180. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3181. *
  3182. * @return A newly initialized dictionary with the entries of the given dictionary.
  3183. **/
  3184. - (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
  3185. /**
  3186. * Initializes this dictionary with the requested capacity.
  3187. *
  3188. * @param numItems Number of items needed for this dictionary.
  3189. *
  3190. * @return A newly initialized dictionary with the requested capacity.
  3191. **/
  3192. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3193. /**
  3194. * Fetches the object stored under the given key.
  3195. *
  3196. * @param key Key under which the value is stored, if present.
  3197. *
  3198. * @return The object if found, nil otherwise.
  3199. **/
  3200. - (ObjectType)objectForKey:(int64_t)key;
  3201. /**
  3202. * Enumerates the keys and values on this dictionary with the given block.
  3203. *
  3204. * @param block The block to enumerate with.
  3205. * **key**: The key for the current entry.
  3206. * **object**: The value for the current entry
  3207. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3208. **/
  3209. - (void)enumerateKeysAndObjectsUsingBlock:
  3210. (void (NS_NOESCAPE ^)(int64_t key, ObjectType object, BOOL *stop))block;
  3211. /**
  3212. * Adds the keys and values from another dictionary.
  3213. *
  3214. * @param otherDictionary Dictionary containing entries to be added to this
  3215. * dictionary.
  3216. **/
  3217. - (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
  3218. /**
  3219. * Sets the value for the given key.
  3220. *
  3221. * @param object The value to set.
  3222. * @param key The key under which to store the value.
  3223. **/
  3224. - (void)setObject:(ObjectType)object forKey:(int64_t)key;
  3225. /**
  3226. * Removes the entry for the given key.
  3227. *
  3228. * @param aKey Key to be removed from this dictionary.
  3229. **/
  3230. - (void)removeObjectForKey:(int64_t)aKey;
  3231. /**
  3232. * Removes all entries in this dictionary.
  3233. **/
  3234. - (void)removeAll;
  3235. @end
  3236. #pragma mark - Bool -> UInt32
  3237. /**
  3238. * Class used for map fields of <BOOL, uint32_t>
  3239. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3240. *
  3241. * @note This class is not meant to be subclassed.
  3242. **/
  3243. @interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
  3244. /** Number of entries stored in this dictionary. */
  3245. @property(nonatomic, readonly) NSUInteger count;
  3246. /**
  3247. * Initializes this dictionary, copying the given values and keys.
  3248. *
  3249. * @param values The values to be placed in this dictionary.
  3250. * @param keys The keys under which to store the values.
  3251. * @param count The number of elements to copy into the dictionary.
  3252. *
  3253. * @return A newly initialized dictionary with a copy of the values and keys.
  3254. **/
  3255. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  3256. forKeys:(const BOOL [__nullable])keys
  3257. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3258. /**
  3259. * Initializes this dictionary, copying the entries from the given dictionary.
  3260. *
  3261. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3262. *
  3263. * @return A newly initialized dictionary with the entries of the given dictionary.
  3264. **/
  3265. - (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
  3266. /**
  3267. * Initializes this dictionary with the requested capacity.
  3268. *
  3269. * @param numItems Number of items needed for this dictionary.
  3270. *
  3271. * @return A newly initialized dictionary with the requested capacity.
  3272. **/
  3273. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3274. /**
  3275. * Gets the value for the given key.
  3276. *
  3277. * @param value Pointer into which the value will be set, if found.
  3278. * @param key Key under which the value is stored, if present.
  3279. *
  3280. * @return YES if the key was found and the value was copied, NO otherwise.
  3281. **/
  3282. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key;
  3283. /**
  3284. * Enumerates the keys and values on this dictionary with the given block.
  3285. *
  3286. * @param block The block to enumerate with.
  3287. * **key**: The key for the current entry.
  3288. * **value**: The value for the current entry
  3289. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3290. **/
  3291. - (void)enumerateKeysAndUInt32sUsingBlock:
  3292. (void (NS_NOESCAPE ^)(BOOL key, uint32_t value, BOOL *stop))block;
  3293. /**
  3294. * Adds the keys and values from another dictionary.
  3295. *
  3296. * @param otherDictionary Dictionary containing entries to be added to this
  3297. * dictionary.
  3298. **/
  3299. - (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;
  3300. /**
  3301. * Sets the value for the given key.
  3302. *
  3303. * @param value The value to set.
  3304. * @param key The key under which to store the value.
  3305. **/
  3306. - (void)setUInt32:(uint32_t)value forKey:(BOOL)key;
  3307. /**
  3308. * Removes the entry for the given key.
  3309. *
  3310. * @param aKey Key to be removed from this dictionary.
  3311. **/
  3312. - (void)removeUInt32ForKey:(BOOL)aKey;
  3313. /**
  3314. * Removes all entries in this dictionary.
  3315. **/
  3316. - (void)removeAll;
  3317. @end
  3318. #pragma mark - Bool -> Int32
  3319. /**
  3320. * Class used for map fields of <BOOL, int32_t>
  3321. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3322. *
  3323. * @note This class is not meant to be subclassed.
  3324. **/
  3325. @interface GPBBoolInt32Dictionary : NSObject <NSCopying>
  3326. /** Number of entries stored in this dictionary. */
  3327. @property(nonatomic, readonly) NSUInteger count;
  3328. /**
  3329. * Initializes this dictionary, copying the given values and keys.
  3330. *
  3331. * @param values The values to be placed in this dictionary.
  3332. * @param keys The keys under which to store the values.
  3333. * @param count The number of elements to copy into the dictionary.
  3334. *
  3335. * @return A newly initialized dictionary with a copy of the values and keys.
  3336. **/
  3337. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  3338. forKeys:(const BOOL [__nullable])keys
  3339. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3340. /**
  3341. * Initializes this dictionary, copying the entries from the given dictionary.
  3342. *
  3343. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3344. *
  3345. * @return A newly initialized dictionary with the entries of the given dictionary.
  3346. **/
  3347. - (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
  3348. /**
  3349. * Initializes this dictionary with the requested capacity.
  3350. *
  3351. * @param numItems Number of items needed for this dictionary.
  3352. *
  3353. * @return A newly initialized dictionary with the requested capacity.
  3354. **/
  3355. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3356. /**
  3357. * Gets the value for the given key.
  3358. *
  3359. * @param value Pointer into which the value will be set, if found.
  3360. * @param key Key under which the value is stored, if present.
  3361. *
  3362. * @return YES if the key was found and the value was copied, NO otherwise.
  3363. **/
  3364. - (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key;
  3365. /**
  3366. * Enumerates the keys and values on this dictionary with the given block.
  3367. *
  3368. * @param block The block to enumerate with.
  3369. * **key**: The key for the current entry.
  3370. * **value**: The value for the current entry
  3371. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3372. **/
  3373. - (void)enumerateKeysAndInt32sUsingBlock:
  3374. (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block;
  3375. /**
  3376. * Adds the keys and values from another dictionary.
  3377. *
  3378. * @param otherDictionary Dictionary containing entries to be added to this
  3379. * dictionary.
  3380. **/
  3381. - (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;
  3382. /**
  3383. * Sets the value for the given key.
  3384. *
  3385. * @param value The value to set.
  3386. * @param key The key under which to store the value.
  3387. **/
  3388. - (void)setInt32:(int32_t)value forKey:(BOOL)key;
  3389. /**
  3390. * Removes the entry for the given key.
  3391. *
  3392. * @param aKey Key to be removed from this dictionary.
  3393. **/
  3394. - (void)removeInt32ForKey:(BOOL)aKey;
  3395. /**
  3396. * Removes all entries in this dictionary.
  3397. **/
  3398. - (void)removeAll;
  3399. @end
  3400. #pragma mark - Bool -> UInt64
  3401. /**
  3402. * Class used for map fields of <BOOL, uint64_t>
  3403. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3404. *
  3405. * @note This class is not meant to be subclassed.
  3406. **/
  3407. @interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
  3408. /** Number of entries stored in this dictionary. */
  3409. @property(nonatomic, readonly) NSUInteger count;
  3410. /**
  3411. * Initializes this dictionary, copying the given values and keys.
  3412. *
  3413. * @param values The values to be placed in this dictionary.
  3414. * @param keys The keys under which to store the values.
  3415. * @param count The number of elements to copy into the dictionary.
  3416. *
  3417. * @return A newly initialized dictionary with a copy of the values and keys.
  3418. **/
  3419. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  3420. forKeys:(const BOOL [__nullable])keys
  3421. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3422. /**
  3423. * Initializes this dictionary, copying the entries from the given dictionary.
  3424. *
  3425. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3426. *
  3427. * @return A newly initialized dictionary with the entries of the given dictionary.
  3428. **/
  3429. - (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
  3430. /**
  3431. * Initializes this dictionary with the requested capacity.
  3432. *
  3433. * @param numItems Number of items needed for this dictionary.
  3434. *
  3435. * @return A newly initialized dictionary with the requested capacity.
  3436. **/
  3437. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3438. /**
  3439. * Gets the value for the given key.
  3440. *
  3441. * @param value Pointer into which the value will be set, if found.
  3442. * @param key Key under which the value is stored, if present.
  3443. *
  3444. * @return YES if the key was found and the value was copied, NO otherwise.
  3445. **/
  3446. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key;
  3447. /**
  3448. * Enumerates the keys and values on this dictionary with the given block.
  3449. *
  3450. * @param block The block to enumerate with.
  3451. * **key**: The key for the current entry.
  3452. * **value**: The value for the current entry
  3453. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3454. **/
  3455. - (void)enumerateKeysAndUInt64sUsingBlock:
  3456. (void (NS_NOESCAPE ^)(BOOL key, uint64_t value, BOOL *stop))block;
  3457. /**
  3458. * Adds the keys and values from another dictionary.
  3459. *
  3460. * @param otherDictionary Dictionary containing entries to be added to this
  3461. * dictionary.
  3462. **/
  3463. - (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;
  3464. /**
  3465. * Sets the value for the given key.
  3466. *
  3467. * @param value The value to set.
  3468. * @param key The key under which to store the value.
  3469. **/
  3470. - (void)setUInt64:(uint64_t)value forKey:(BOOL)key;
  3471. /**
  3472. * Removes the entry for the given key.
  3473. *
  3474. * @param aKey Key to be removed from this dictionary.
  3475. **/
  3476. - (void)removeUInt64ForKey:(BOOL)aKey;
  3477. /**
  3478. * Removes all entries in this dictionary.
  3479. **/
  3480. - (void)removeAll;
  3481. @end
  3482. #pragma mark - Bool -> Int64
  3483. /**
  3484. * Class used for map fields of <BOOL, int64_t>
  3485. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3486. *
  3487. * @note This class is not meant to be subclassed.
  3488. **/
  3489. @interface GPBBoolInt64Dictionary : NSObject <NSCopying>
  3490. /** Number of entries stored in this dictionary. */
  3491. @property(nonatomic, readonly) NSUInteger count;
  3492. /**
  3493. * Initializes this dictionary, copying the given values and keys.
  3494. *
  3495. * @param values The values to be placed in this dictionary.
  3496. * @param keys The keys under which to store the values.
  3497. * @param count The number of elements to copy into the dictionary.
  3498. *
  3499. * @return A newly initialized dictionary with a copy of the values and keys.
  3500. **/
  3501. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  3502. forKeys:(const BOOL [__nullable])keys
  3503. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3504. /**
  3505. * Initializes this dictionary, copying the entries from the given dictionary.
  3506. *
  3507. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3508. *
  3509. * @return A newly initialized dictionary with the entries of the given dictionary.
  3510. **/
  3511. - (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
  3512. /**
  3513. * Initializes this dictionary with the requested capacity.
  3514. *
  3515. * @param numItems Number of items needed for this dictionary.
  3516. *
  3517. * @return A newly initialized dictionary with the requested capacity.
  3518. **/
  3519. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3520. /**
  3521. * Gets the value for the given key.
  3522. *
  3523. * @param value Pointer into which the value will be set, if found.
  3524. * @param key Key under which the value is stored, if present.
  3525. *
  3526. * @return YES if the key was found and the value was copied, NO otherwise.
  3527. **/
  3528. - (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key;
  3529. /**
  3530. * Enumerates the keys and values on this dictionary with the given block.
  3531. *
  3532. * @param block The block to enumerate with.
  3533. * **key**: The key for the current entry.
  3534. * **value**: The value for the current entry
  3535. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3536. **/
  3537. - (void)enumerateKeysAndInt64sUsingBlock:
  3538. (void (NS_NOESCAPE ^)(BOOL key, int64_t value, BOOL *stop))block;
  3539. /**
  3540. * Adds the keys and values from another dictionary.
  3541. *
  3542. * @param otherDictionary Dictionary containing entries to be added to this
  3543. * dictionary.
  3544. **/
  3545. - (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;
  3546. /**
  3547. * Sets the value for the given key.
  3548. *
  3549. * @param value The value to set.
  3550. * @param key The key under which to store the value.
  3551. **/
  3552. - (void)setInt64:(int64_t)value forKey:(BOOL)key;
  3553. /**
  3554. * Removes the entry for the given key.
  3555. *
  3556. * @param aKey Key to be removed from this dictionary.
  3557. **/
  3558. - (void)removeInt64ForKey:(BOOL)aKey;
  3559. /**
  3560. * Removes all entries in this dictionary.
  3561. **/
  3562. - (void)removeAll;
  3563. @end
  3564. #pragma mark - Bool -> Bool
  3565. /**
  3566. * Class used for map fields of <BOOL, BOOL>
  3567. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3568. *
  3569. * @note This class is not meant to be subclassed.
  3570. **/
  3571. @interface GPBBoolBoolDictionary : NSObject <NSCopying>
  3572. /** Number of entries stored in this dictionary. */
  3573. @property(nonatomic, readonly) NSUInteger count;
  3574. /**
  3575. * Initializes this dictionary, copying the given values and keys.
  3576. *
  3577. * @param values The values to be placed in this dictionary.
  3578. * @param keys The keys under which to store the values.
  3579. * @param count The number of elements to copy into the dictionary.
  3580. *
  3581. * @return A newly initialized dictionary with a copy of the values and keys.
  3582. **/
  3583. - (instancetype)initWithBools:(const BOOL [__nullable])values
  3584. forKeys:(const BOOL [__nullable])keys
  3585. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3586. /**
  3587. * Initializes this dictionary, copying the entries from the given dictionary.
  3588. *
  3589. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3590. *
  3591. * @return A newly initialized dictionary with the entries of the given dictionary.
  3592. **/
  3593. - (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
  3594. /**
  3595. * Initializes this dictionary with the requested capacity.
  3596. *
  3597. * @param numItems Number of items needed for this dictionary.
  3598. *
  3599. * @return A newly initialized dictionary with the requested capacity.
  3600. **/
  3601. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3602. /**
  3603. * Gets the value for the given key.
  3604. *
  3605. * @param value Pointer into which the value will be set, if found.
  3606. * @param key Key under which the value is stored, if present.
  3607. *
  3608. * @return YES if the key was found and the value was copied, NO otherwise.
  3609. **/
  3610. - (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key;
  3611. /**
  3612. * Enumerates the keys and values on this dictionary with the given block.
  3613. *
  3614. * @param block The block to enumerate with.
  3615. * **key**: The key for the current entry.
  3616. * **value**: The value for the current entry
  3617. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3618. **/
  3619. - (void)enumerateKeysAndBoolsUsingBlock:
  3620. (void (NS_NOESCAPE ^)(BOOL key, BOOL value, BOOL *stop))block;
  3621. /**
  3622. * Adds the keys and values from another dictionary.
  3623. *
  3624. * @param otherDictionary Dictionary containing entries to be added to this
  3625. * dictionary.
  3626. **/
  3627. - (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;
  3628. /**
  3629. * Sets the value for the given key.
  3630. *
  3631. * @param value The value to set.
  3632. * @param key The key under which to store the value.
  3633. **/
  3634. - (void)setBool:(BOOL)value forKey:(BOOL)key;
  3635. /**
  3636. * Removes the entry for the given key.
  3637. *
  3638. * @param aKey Key to be removed from this dictionary.
  3639. **/
  3640. - (void)removeBoolForKey:(BOOL)aKey;
  3641. /**
  3642. * Removes all entries in this dictionary.
  3643. **/
  3644. - (void)removeAll;
  3645. @end
  3646. #pragma mark - Bool -> Float
  3647. /**
  3648. * Class used for map fields of <BOOL, float>
  3649. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3650. *
  3651. * @note This class is not meant to be subclassed.
  3652. **/
  3653. @interface GPBBoolFloatDictionary : NSObject <NSCopying>
  3654. /** Number of entries stored in this dictionary. */
  3655. @property(nonatomic, readonly) NSUInteger count;
  3656. /**
  3657. * Initializes this dictionary, copying the given values and keys.
  3658. *
  3659. * @param values The values to be placed in this dictionary.
  3660. * @param keys The keys under which to store the values.
  3661. * @param count The number of elements to copy into the dictionary.
  3662. *
  3663. * @return A newly initialized dictionary with a copy of the values and keys.
  3664. **/
  3665. - (instancetype)initWithFloats:(const float [__nullable])values
  3666. forKeys:(const BOOL [__nullable])keys
  3667. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3668. /**
  3669. * Initializes this dictionary, copying the entries from the given dictionary.
  3670. *
  3671. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3672. *
  3673. * @return A newly initialized dictionary with the entries of the given dictionary.
  3674. **/
  3675. - (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
  3676. /**
  3677. * Initializes this dictionary with the requested capacity.
  3678. *
  3679. * @param numItems Number of items needed for this dictionary.
  3680. *
  3681. * @return A newly initialized dictionary with the requested capacity.
  3682. **/
  3683. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3684. /**
  3685. * Gets the value for the given key.
  3686. *
  3687. * @param value Pointer into which the value will be set, if found.
  3688. * @param key Key under which the value is stored, if present.
  3689. *
  3690. * @return YES if the key was found and the value was copied, NO otherwise.
  3691. **/
  3692. - (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key;
  3693. /**
  3694. * Enumerates the keys and values on this dictionary with the given block.
  3695. *
  3696. * @param block The block to enumerate with.
  3697. * **key**: The key for the current entry.
  3698. * **value**: The value for the current entry
  3699. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3700. **/
  3701. - (void)enumerateKeysAndFloatsUsingBlock:
  3702. (void (NS_NOESCAPE ^)(BOOL key, float value, BOOL *stop))block;
  3703. /**
  3704. * Adds the keys and values from another dictionary.
  3705. *
  3706. * @param otherDictionary Dictionary containing entries to be added to this
  3707. * dictionary.
  3708. **/
  3709. - (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;
  3710. /**
  3711. * Sets the value for the given key.
  3712. *
  3713. * @param value The value to set.
  3714. * @param key The key under which to store the value.
  3715. **/
  3716. - (void)setFloat:(float)value forKey:(BOOL)key;
  3717. /**
  3718. * Removes the entry for the given key.
  3719. *
  3720. * @param aKey Key to be removed from this dictionary.
  3721. **/
  3722. - (void)removeFloatForKey:(BOOL)aKey;
  3723. /**
  3724. * Removes all entries in this dictionary.
  3725. **/
  3726. - (void)removeAll;
  3727. @end
  3728. #pragma mark - Bool -> Double
  3729. /**
  3730. * Class used for map fields of <BOOL, double>
  3731. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3732. *
  3733. * @note This class is not meant to be subclassed.
  3734. **/
  3735. @interface GPBBoolDoubleDictionary : NSObject <NSCopying>
  3736. /** Number of entries stored in this dictionary. */
  3737. @property(nonatomic, readonly) NSUInteger count;
  3738. /**
  3739. * Initializes this dictionary, copying the given values and keys.
  3740. *
  3741. * @param values The values to be placed in this dictionary.
  3742. * @param keys The keys under which to store the values.
  3743. * @param count The number of elements to copy into the dictionary.
  3744. *
  3745. * @return A newly initialized dictionary with a copy of the values and keys.
  3746. **/
  3747. - (instancetype)initWithDoubles:(const double [__nullable])values
  3748. forKeys:(const BOOL [__nullable])keys
  3749. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3750. /**
  3751. * Initializes this dictionary, copying the entries from the given dictionary.
  3752. *
  3753. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3754. *
  3755. * @return A newly initialized dictionary with the entries of the given dictionary.
  3756. **/
  3757. - (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
  3758. /**
  3759. * Initializes this dictionary with the requested capacity.
  3760. *
  3761. * @param numItems Number of items needed for this dictionary.
  3762. *
  3763. * @return A newly initialized dictionary with the requested capacity.
  3764. **/
  3765. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3766. /**
  3767. * Gets the value for the given key.
  3768. *
  3769. * @param value Pointer into which the value will be set, if found.
  3770. * @param key Key under which the value is stored, if present.
  3771. *
  3772. * @return YES if the key was found and the value was copied, NO otherwise.
  3773. **/
  3774. - (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key;
  3775. /**
  3776. * Enumerates the keys and values on this dictionary with the given block.
  3777. *
  3778. * @param block The block to enumerate with.
  3779. * **key**: The key for the current entry.
  3780. * **value**: The value for the current entry
  3781. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3782. **/
  3783. - (void)enumerateKeysAndDoublesUsingBlock:
  3784. (void (NS_NOESCAPE ^)(BOOL key, double value, BOOL *stop))block;
  3785. /**
  3786. * Adds the keys and values from another dictionary.
  3787. *
  3788. * @param otherDictionary Dictionary containing entries to be added to this
  3789. * dictionary.
  3790. **/
  3791. - (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;
  3792. /**
  3793. * Sets the value for the given key.
  3794. *
  3795. * @param value The value to set.
  3796. * @param key The key under which to store the value.
  3797. **/
  3798. - (void)setDouble:(double)value forKey:(BOOL)key;
  3799. /**
  3800. * Removes the entry for the given key.
  3801. *
  3802. * @param aKey Key to be removed from this dictionary.
  3803. **/
  3804. - (void)removeDoubleForKey:(BOOL)aKey;
  3805. /**
  3806. * Removes all entries in this dictionary.
  3807. **/
  3808. - (void)removeAll;
  3809. @end
  3810. #pragma mark - Bool -> Enum
  3811. /**
  3812. * Class used for map fields of <BOOL, int32_t>
  3813. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3814. *
  3815. * @note This class is not meant to be subclassed.
  3816. **/
  3817. @interface GPBBoolEnumDictionary : NSObject <NSCopying>
  3818. /** Number of entries stored in this dictionary. */
  3819. @property(nonatomic, readonly) NSUInteger count;
  3820. /** The validation function to check if the enums are valid. */
  3821. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  3822. /**
  3823. * Initializes a dictionary with the given validation function.
  3824. *
  3825. * @param func The enum validation function for the dictionary.
  3826. *
  3827. * @return A newly initialized dictionary.
  3828. **/
  3829. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  3830. /**
  3831. * Initializes a dictionary with the entries given.
  3832. *
  3833. * @param func The enum validation function for the dictionary.
  3834. * @param values The raw enum values values to be placed in the dictionary.
  3835. * @param keys The keys under which to store the values.
  3836. * @param count The number of entries to store in the dictionary.
  3837. *
  3838. * @return A newly initialized dictionary with the keys and values in it.
  3839. **/
  3840. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  3841. rawValues:(const int32_t [__nullable])values
  3842. forKeys:(const BOOL [__nullable])keys
  3843. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3844. /**
  3845. * Initializes a dictionary with the entries from the given.
  3846. * dictionary.
  3847. *
  3848. * @param dictionary Dictionary containing the entries to add to the dictionary.
  3849. *
  3850. * @return A newly initialized dictionary with the entries from the given
  3851. * dictionary in it.
  3852. **/
  3853. - (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
  3854. /**
  3855. * Initializes a dictionary with the given capacity.
  3856. *
  3857. * @param func The enum validation function for the dictionary.
  3858. * @param numItems Capacity needed for the dictionary.
  3859. *
  3860. * @return A newly initialized dictionary with the given capacity.
  3861. **/
  3862. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  3863. capacity:(NSUInteger)numItems;
  3864. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  3865. // is not a valid enumerator as defined by validationFunc. If the actual value is
  3866. // desired, use "raw" version of the method.
  3867. /**
  3868. * Gets the value for the given key.
  3869. *
  3870. * @param value Pointer into which the value will be set, if found.
  3871. * @param key Key under which the value is stored, if present.
  3872. *
  3873. * @return YES if the key was found and the value was copied, NO otherwise.
  3874. **/
  3875. - (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key;
  3876. /**
  3877. * Enumerates the keys and values on this dictionary with the given block.
  3878. *
  3879. * @param block The block to enumerate with.
  3880. * **key**: The key for the current entry.
  3881. * **value**: The value for the current entry
  3882. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3883. **/
  3884. - (void)enumerateKeysAndEnumsUsingBlock:
  3885. (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block;
  3886. /**
  3887. * Gets the raw enum value for the given key.
  3888. *
  3889. * @note This method bypass the validationFunc to enable the access of values that
  3890. * were not known at the time the binary was compiled.
  3891. *
  3892. * @param rawValue Pointer into which the value will be set, if found.
  3893. * @param key Key under which the value is stored, if present.
  3894. *
  3895. * @return YES if the key was found and the value was copied, NO otherwise.
  3896. **/
  3897. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key;
  3898. /**
  3899. * Enumerates the keys and values on this dictionary with the given block.
  3900. *
  3901. * @note This method bypass the validationFunc to enable the access of values that
  3902. * were not known at the time the binary was compiled.
  3903. *
  3904. * @param block The block to enumerate with.
  3905. * **key**: The key for the current entry.
  3906. * **rawValue**: The value for the current entry
  3907. * **stop**: A pointer to a boolean that when set stops the enumeration.
  3908. **/
  3909. - (void)enumerateKeysAndRawValuesUsingBlock:
  3910. (void (NS_NOESCAPE ^)(BOOL key, int32_t rawValue, BOOL *stop))block;
  3911. /**
  3912. * Adds the keys and raw enum values from another dictionary.
  3913. *
  3914. * @note This method bypass the validationFunc to enable the setting of values that
  3915. * were not known at the time the binary was compiled.
  3916. *
  3917. * @param otherDictionary Dictionary containing entries to be added to this
  3918. * dictionary.
  3919. **/
  3920. - (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;
  3921. // If value is not a valid enumerator as defined by validationFunc, these
  3922. // methods will assert in debug, and will log in release and assign the value
  3923. // to the default value. Use the rawValue methods below to assign non enumerator
  3924. // values.
  3925. /**
  3926. * Sets the value for the given key.
  3927. *
  3928. * @param value The value to set.
  3929. * @param key The key under which to store the value.
  3930. **/
  3931. - (void)setEnum:(int32_t)value forKey:(BOOL)key;
  3932. /**
  3933. * Sets the raw enum value for the given key.
  3934. *
  3935. * @note This method bypass the validationFunc to enable the setting of values that
  3936. * were not known at the time the binary was compiled.
  3937. *
  3938. * @param rawValue The raw enum value to set.
  3939. * @param key The key under which to store the raw enum value.
  3940. **/
  3941. - (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;
  3942. /**
  3943. * Removes the entry for the given key.
  3944. *
  3945. * @param aKey Key to be removed from this dictionary.
  3946. **/
  3947. - (void)removeEnumForKey:(BOOL)aKey;
  3948. /**
  3949. * Removes all entries in this dictionary.
  3950. **/
  3951. - (void)removeAll;
  3952. @end
  3953. #pragma mark - Bool -> Object
  3954. /**
  3955. * Class used for map fields of <BOOL, ObjectType>
  3956. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  3957. *
  3958. * @note This class is not meant to be subclassed.
  3959. **/
  3960. @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
  3961. /** Number of entries stored in this dictionary. */
  3962. @property(nonatomic, readonly) NSUInteger count;
  3963. /**
  3964. * Initializes this dictionary, copying the given values and keys.
  3965. *
  3966. * @param objects The values to be placed in this dictionary.
  3967. * @param keys The keys under which to store the values.
  3968. * @param count The number of elements to copy into the dictionary.
  3969. *
  3970. * @return A newly initialized dictionary with a copy of the values and keys.
  3971. **/
  3972. - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
  3973. forKeys:(const BOOL [__nullable])keys
  3974. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  3975. /**
  3976. * Initializes this dictionary, copying the entries from the given dictionary.
  3977. *
  3978. * @param dictionary Dictionary containing the entries to add to this dictionary.
  3979. *
  3980. * @return A newly initialized dictionary with the entries of the given dictionary.
  3981. **/
  3982. - (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
  3983. /**
  3984. * Initializes this dictionary with the requested capacity.
  3985. *
  3986. * @param numItems Number of items needed for this dictionary.
  3987. *
  3988. * @return A newly initialized dictionary with the requested capacity.
  3989. **/
  3990. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  3991. /**
  3992. * Fetches the object stored under the given key.
  3993. *
  3994. * @param key Key under which the value is stored, if present.
  3995. *
  3996. * @return The object if found, nil otherwise.
  3997. **/
  3998. - (ObjectType)objectForKey:(BOOL)key;
  3999. /**
  4000. * Enumerates the keys and values on this dictionary with the given block.
  4001. *
  4002. * @param block The block to enumerate with.
  4003. * **key**: The key for the current entry.
  4004. * **object**: The value for the current entry
  4005. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4006. **/
  4007. - (void)enumerateKeysAndObjectsUsingBlock:
  4008. (void (NS_NOESCAPE ^)(BOOL key, ObjectType object, BOOL *stop))block;
  4009. /**
  4010. * Adds the keys and values from another dictionary.
  4011. *
  4012. * @param otherDictionary Dictionary containing entries to be added to this
  4013. * dictionary.
  4014. **/
  4015. - (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
  4016. /**
  4017. * Sets the value for the given key.
  4018. *
  4019. * @param object The value to set.
  4020. * @param key The key under which to store the value.
  4021. **/
  4022. - (void)setObject:(ObjectType)object forKey:(BOOL)key;
  4023. /**
  4024. * Removes the entry for the given key.
  4025. *
  4026. * @param aKey Key to be removed from this dictionary.
  4027. **/
  4028. - (void)removeObjectForKey:(BOOL)aKey;
  4029. /**
  4030. * Removes all entries in this dictionary.
  4031. **/
  4032. - (void)removeAll;
  4033. @end
  4034. #pragma mark - String -> UInt32
  4035. /**
  4036. * Class used for map fields of <NSString, uint32_t>
  4037. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4038. *
  4039. * @note This class is not meant to be subclassed.
  4040. **/
  4041. @interface GPBStringUInt32Dictionary : NSObject <NSCopying>
  4042. /** Number of entries stored in this dictionary. */
  4043. @property(nonatomic, readonly) NSUInteger count;
  4044. /**
  4045. * Initializes this dictionary, copying the given values and keys.
  4046. *
  4047. * @param values The values to be placed in this dictionary.
  4048. * @param keys The keys under which to store the values.
  4049. * @param count The number of elements to copy into the dictionary.
  4050. *
  4051. * @return A newly initialized dictionary with a copy of the values and keys.
  4052. **/
  4053. - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
  4054. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4055. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4056. /**
  4057. * Initializes this dictionary, copying the entries from the given dictionary.
  4058. *
  4059. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4060. *
  4061. * @return A newly initialized dictionary with the entries of the given dictionary.
  4062. **/
  4063. - (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
  4064. /**
  4065. * Initializes this dictionary with the requested capacity.
  4066. *
  4067. * @param numItems Number of items needed for this dictionary.
  4068. *
  4069. * @return A newly initialized dictionary with the requested capacity.
  4070. **/
  4071. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4072. /**
  4073. * Gets the value for the given key.
  4074. *
  4075. * @param value Pointer into which the value will be set, if found.
  4076. * @param key Key under which the value is stored, if present.
  4077. *
  4078. * @return YES if the key was found and the value was copied, NO otherwise.
  4079. **/
  4080. - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key;
  4081. /**
  4082. * Enumerates the keys and values on this dictionary with the given block.
  4083. *
  4084. * @param block The block to enumerate with.
  4085. * **key**: The key for the current entry.
  4086. * **value**: The value for the current entry
  4087. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4088. **/
  4089. - (void)enumerateKeysAndUInt32sUsingBlock:
  4090. (void (NS_NOESCAPE ^)(NSString *key, uint32_t value, BOOL *stop))block;
  4091. /**
  4092. * Adds the keys and values from another dictionary.
  4093. *
  4094. * @param otherDictionary Dictionary containing entries to be added to this
  4095. * dictionary.
  4096. **/
  4097. - (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;
  4098. /**
  4099. * Sets the value for the given key.
  4100. *
  4101. * @param value The value to set.
  4102. * @param key The key under which to store the value.
  4103. **/
  4104. - (void)setUInt32:(uint32_t)value forKey:(NSString *)key;
  4105. /**
  4106. * Removes the entry for the given key.
  4107. *
  4108. * @param aKey Key to be removed from this dictionary.
  4109. **/
  4110. - (void)removeUInt32ForKey:(NSString *)aKey;
  4111. /**
  4112. * Removes all entries in this dictionary.
  4113. **/
  4114. - (void)removeAll;
  4115. @end
  4116. #pragma mark - String -> Int32
  4117. /**
  4118. * Class used for map fields of <NSString, int32_t>
  4119. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4120. *
  4121. * @note This class is not meant to be subclassed.
  4122. **/
  4123. @interface GPBStringInt32Dictionary : NSObject <NSCopying>
  4124. /** Number of entries stored in this dictionary. */
  4125. @property(nonatomic, readonly) NSUInteger count;
  4126. /**
  4127. * Initializes this dictionary, copying the given values and keys.
  4128. *
  4129. * @param values The values to be placed in this dictionary.
  4130. * @param keys The keys under which to store the values.
  4131. * @param count The number of elements to copy into the dictionary.
  4132. *
  4133. * @return A newly initialized dictionary with a copy of the values and keys.
  4134. **/
  4135. - (instancetype)initWithInt32s:(const int32_t [__nullable])values
  4136. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4137. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4138. /**
  4139. * Initializes this dictionary, copying the entries from the given dictionary.
  4140. *
  4141. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4142. *
  4143. * @return A newly initialized dictionary with the entries of the given dictionary.
  4144. **/
  4145. - (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
  4146. /**
  4147. * Initializes this dictionary with the requested capacity.
  4148. *
  4149. * @param numItems Number of items needed for this dictionary.
  4150. *
  4151. * @return A newly initialized dictionary with the requested capacity.
  4152. **/
  4153. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4154. /**
  4155. * Gets the value for the given key.
  4156. *
  4157. * @param value Pointer into which the value will be set, if found.
  4158. * @param key Key under which the value is stored, if present.
  4159. *
  4160. * @return YES if the key was found and the value was copied, NO otherwise.
  4161. **/
  4162. - (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key;
  4163. /**
  4164. * Enumerates the keys and values on this dictionary with the given block.
  4165. *
  4166. * @param block The block to enumerate with.
  4167. * **key**: The key for the current entry.
  4168. * **value**: The value for the current entry
  4169. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4170. **/
  4171. - (void)enumerateKeysAndInt32sUsingBlock:
  4172. (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block;
  4173. /**
  4174. * Adds the keys and values from another dictionary.
  4175. *
  4176. * @param otherDictionary Dictionary containing entries to be added to this
  4177. * dictionary.
  4178. **/
  4179. - (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;
  4180. /**
  4181. * Sets the value for the given key.
  4182. *
  4183. * @param value The value to set.
  4184. * @param key The key under which to store the value.
  4185. **/
  4186. - (void)setInt32:(int32_t)value forKey:(NSString *)key;
  4187. /**
  4188. * Removes the entry for the given key.
  4189. *
  4190. * @param aKey Key to be removed from this dictionary.
  4191. **/
  4192. - (void)removeInt32ForKey:(NSString *)aKey;
  4193. /**
  4194. * Removes all entries in this dictionary.
  4195. **/
  4196. - (void)removeAll;
  4197. @end
  4198. #pragma mark - String -> UInt64
  4199. /**
  4200. * Class used for map fields of <NSString, uint64_t>
  4201. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4202. *
  4203. * @note This class is not meant to be subclassed.
  4204. **/
  4205. @interface GPBStringUInt64Dictionary : NSObject <NSCopying>
  4206. /** Number of entries stored in this dictionary. */
  4207. @property(nonatomic, readonly) NSUInteger count;
  4208. /**
  4209. * Initializes this dictionary, copying the given values and keys.
  4210. *
  4211. * @param values The values to be placed in this dictionary.
  4212. * @param keys The keys under which to store the values.
  4213. * @param count The number of elements to copy into the dictionary.
  4214. *
  4215. * @return A newly initialized dictionary with a copy of the values and keys.
  4216. **/
  4217. - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
  4218. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4219. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4220. /**
  4221. * Initializes this dictionary, copying the entries from the given dictionary.
  4222. *
  4223. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4224. *
  4225. * @return A newly initialized dictionary with the entries of the given dictionary.
  4226. **/
  4227. - (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
  4228. /**
  4229. * Initializes this dictionary with the requested capacity.
  4230. *
  4231. * @param numItems Number of items needed for this dictionary.
  4232. *
  4233. * @return A newly initialized dictionary with the requested capacity.
  4234. **/
  4235. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4236. /**
  4237. * Gets the value for the given key.
  4238. *
  4239. * @param value Pointer into which the value will be set, if found.
  4240. * @param key Key under which the value is stored, if present.
  4241. *
  4242. * @return YES if the key was found and the value was copied, NO otherwise.
  4243. **/
  4244. - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key;
  4245. /**
  4246. * Enumerates the keys and values on this dictionary with the given block.
  4247. *
  4248. * @param block The block to enumerate with.
  4249. * **key**: The key for the current entry.
  4250. * **value**: The value for the current entry
  4251. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4252. **/
  4253. - (void)enumerateKeysAndUInt64sUsingBlock:
  4254. (void (NS_NOESCAPE ^)(NSString *key, uint64_t value, BOOL *stop))block;
  4255. /**
  4256. * Adds the keys and values from another dictionary.
  4257. *
  4258. * @param otherDictionary Dictionary containing entries to be added to this
  4259. * dictionary.
  4260. **/
  4261. - (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;
  4262. /**
  4263. * Sets the value for the given key.
  4264. *
  4265. * @param value The value to set.
  4266. * @param key The key under which to store the value.
  4267. **/
  4268. - (void)setUInt64:(uint64_t)value forKey:(NSString *)key;
  4269. /**
  4270. * Removes the entry for the given key.
  4271. *
  4272. * @param aKey Key to be removed from this dictionary.
  4273. **/
  4274. - (void)removeUInt64ForKey:(NSString *)aKey;
  4275. /**
  4276. * Removes all entries in this dictionary.
  4277. **/
  4278. - (void)removeAll;
  4279. @end
  4280. #pragma mark - String -> Int64
  4281. /**
  4282. * Class used for map fields of <NSString, int64_t>
  4283. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4284. *
  4285. * @note This class is not meant to be subclassed.
  4286. **/
  4287. @interface GPBStringInt64Dictionary : NSObject <NSCopying>
  4288. /** Number of entries stored in this dictionary. */
  4289. @property(nonatomic, readonly) NSUInteger count;
  4290. /**
  4291. * Initializes this dictionary, copying the given values and keys.
  4292. *
  4293. * @param values The values to be placed in this dictionary.
  4294. * @param keys The keys under which to store the values.
  4295. * @param count The number of elements to copy into the dictionary.
  4296. *
  4297. * @return A newly initialized dictionary with a copy of the values and keys.
  4298. **/
  4299. - (instancetype)initWithInt64s:(const int64_t [__nullable])values
  4300. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4301. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4302. /**
  4303. * Initializes this dictionary, copying the entries from the given dictionary.
  4304. *
  4305. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4306. *
  4307. * @return A newly initialized dictionary with the entries of the given dictionary.
  4308. **/
  4309. - (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
  4310. /**
  4311. * Initializes this dictionary with the requested capacity.
  4312. *
  4313. * @param numItems Number of items needed for this dictionary.
  4314. *
  4315. * @return A newly initialized dictionary with the requested capacity.
  4316. **/
  4317. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4318. /**
  4319. * Gets the value for the given key.
  4320. *
  4321. * @param value Pointer into which the value will be set, if found.
  4322. * @param key Key under which the value is stored, if present.
  4323. *
  4324. * @return YES if the key was found and the value was copied, NO otherwise.
  4325. **/
  4326. - (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key;
  4327. /**
  4328. * Enumerates the keys and values on this dictionary with the given block.
  4329. *
  4330. * @param block The block to enumerate with.
  4331. * **key**: The key for the current entry.
  4332. * **value**: The value for the current entry
  4333. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4334. **/
  4335. - (void)enumerateKeysAndInt64sUsingBlock:
  4336. (void (NS_NOESCAPE ^)(NSString *key, int64_t value, BOOL *stop))block;
  4337. /**
  4338. * Adds the keys and values from another dictionary.
  4339. *
  4340. * @param otherDictionary Dictionary containing entries to be added to this
  4341. * dictionary.
  4342. **/
  4343. - (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;
  4344. /**
  4345. * Sets the value for the given key.
  4346. *
  4347. * @param value The value to set.
  4348. * @param key The key under which to store the value.
  4349. **/
  4350. - (void)setInt64:(int64_t)value forKey:(NSString *)key;
  4351. /**
  4352. * Removes the entry for the given key.
  4353. *
  4354. * @param aKey Key to be removed from this dictionary.
  4355. **/
  4356. - (void)removeInt64ForKey:(NSString *)aKey;
  4357. /**
  4358. * Removes all entries in this dictionary.
  4359. **/
  4360. - (void)removeAll;
  4361. @end
  4362. #pragma mark - String -> Bool
  4363. /**
  4364. * Class used for map fields of <NSString, BOOL>
  4365. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4366. *
  4367. * @note This class is not meant to be subclassed.
  4368. **/
  4369. @interface GPBStringBoolDictionary : NSObject <NSCopying>
  4370. /** Number of entries stored in this dictionary. */
  4371. @property(nonatomic, readonly) NSUInteger count;
  4372. /**
  4373. * Initializes this dictionary, copying the given values and keys.
  4374. *
  4375. * @param values The values to be placed in this dictionary.
  4376. * @param keys The keys under which to store the values.
  4377. * @param count The number of elements to copy into the dictionary.
  4378. *
  4379. * @return A newly initialized dictionary with a copy of the values and keys.
  4380. **/
  4381. - (instancetype)initWithBools:(const BOOL [__nullable])values
  4382. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4383. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4384. /**
  4385. * Initializes this dictionary, copying the entries from the given dictionary.
  4386. *
  4387. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4388. *
  4389. * @return A newly initialized dictionary with the entries of the given dictionary.
  4390. **/
  4391. - (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
  4392. /**
  4393. * Initializes this dictionary with the requested capacity.
  4394. *
  4395. * @param numItems Number of items needed for this dictionary.
  4396. *
  4397. * @return A newly initialized dictionary with the requested capacity.
  4398. **/
  4399. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4400. /**
  4401. * Gets the value for the given key.
  4402. *
  4403. * @param value Pointer into which the value will be set, if found.
  4404. * @param key Key under which the value is stored, if present.
  4405. *
  4406. * @return YES if the key was found and the value was copied, NO otherwise.
  4407. **/
  4408. - (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key;
  4409. /**
  4410. * Enumerates the keys and values on this dictionary with the given block.
  4411. *
  4412. * @param block The block to enumerate with.
  4413. * **key**: The key for the current entry.
  4414. * **value**: The value for the current entry
  4415. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4416. **/
  4417. - (void)enumerateKeysAndBoolsUsingBlock:
  4418. (void (NS_NOESCAPE ^)(NSString *key, BOOL value, BOOL *stop))block;
  4419. /**
  4420. * Adds the keys and values from another dictionary.
  4421. *
  4422. * @param otherDictionary Dictionary containing entries to be added to this
  4423. * dictionary.
  4424. **/
  4425. - (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;
  4426. /**
  4427. * Sets the value for the given key.
  4428. *
  4429. * @param value The value to set.
  4430. * @param key The key under which to store the value.
  4431. **/
  4432. - (void)setBool:(BOOL)value forKey:(NSString *)key;
  4433. /**
  4434. * Removes the entry for the given key.
  4435. *
  4436. * @param aKey Key to be removed from this dictionary.
  4437. **/
  4438. - (void)removeBoolForKey:(NSString *)aKey;
  4439. /**
  4440. * Removes all entries in this dictionary.
  4441. **/
  4442. - (void)removeAll;
  4443. @end
  4444. #pragma mark - String -> Float
  4445. /**
  4446. * Class used for map fields of <NSString, float>
  4447. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4448. *
  4449. * @note This class is not meant to be subclassed.
  4450. **/
  4451. @interface GPBStringFloatDictionary : NSObject <NSCopying>
  4452. /** Number of entries stored in this dictionary. */
  4453. @property(nonatomic, readonly) NSUInteger count;
  4454. /**
  4455. * Initializes this dictionary, copying the given values and keys.
  4456. *
  4457. * @param values The values to be placed in this dictionary.
  4458. * @param keys The keys under which to store the values.
  4459. * @param count The number of elements to copy into the dictionary.
  4460. *
  4461. * @return A newly initialized dictionary with a copy of the values and keys.
  4462. **/
  4463. - (instancetype)initWithFloats:(const float [__nullable])values
  4464. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4465. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4466. /**
  4467. * Initializes this dictionary, copying the entries from the given dictionary.
  4468. *
  4469. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4470. *
  4471. * @return A newly initialized dictionary with the entries of the given dictionary.
  4472. **/
  4473. - (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
  4474. /**
  4475. * Initializes this dictionary with the requested capacity.
  4476. *
  4477. * @param numItems Number of items needed for this dictionary.
  4478. *
  4479. * @return A newly initialized dictionary with the requested capacity.
  4480. **/
  4481. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4482. /**
  4483. * Gets the value for the given key.
  4484. *
  4485. * @param value Pointer into which the value will be set, if found.
  4486. * @param key Key under which the value is stored, if present.
  4487. *
  4488. * @return YES if the key was found and the value was copied, NO otherwise.
  4489. **/
  4490. - (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key;
  4491. /**
  4492. * Enumerates the keys and values on this dictionary with the given block.
  4493. *
  4494. * @param block The block to enumerate with.
  4495. * **key**: The key for the current entry.
  4496. * **value**: The value for the current entry
  4497. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4498. **/
  4499. - (void)enumerateKeysAndFloatsUsingBlock:
  4500. (void (NS_NOESCAPE ^)(NSString *key, float value, BOOL *stop))block;
  4501. /**
  4502. * Adds the keys and values from another dictionary.
  4503. *
  4504. * @param otherDictionary Dictionary containing entries to be added to this
  4505. * dictionary.
  4506. **/
  4507. - (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;
  4508. /**
  4509. * Sets the value for the given key.
  4510. *
  4511. * @param value The value to set.
  4512. * @param key The key under which to store the value.
  4513. **/
  4514. - (void)setFloat:(float)value forKey:(NSString *)key;
  4515. /**
  4516. * Removes the entry for the given key.
  4517. *
  4518. * @param aKey Key to be removed from this dictionary.
  4519. **/
  4520. - (void)removeFloatForKey:(NSString *)aKey;
  4521. /**
  4522. * Removes all entries in this dictionary.
  4523. **/
  4524. - (void)removeAll;
  4525. @end
  4526. #pragma mark - String -> Double
  4527. /**
  4528. * Class used for map fields of <NSString, double>
  4529. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4530. *
  4531. * @note This class is not meant to be subclassed.
  4532. **/
  4533. @interface GPBStringDoubleDictionary : NSObject <NSCopying>
  4534. /** Number of entries stored in this dictionary. */
  4535. @property(nonatomic, readonly) NSUInteger count;
  4536. /**
  4537. * Initializes this dictionary, copying the given values and keys.
  4538. *
  4539. * @param values The values to be placed in this dictionary.
  4540. * @param keys The keys under which to store the values.
  4541. * @param count The number of elements to copy into the dictionary.
  4542. *
  4543. * @return A newly initialized dictionary with a copy of the values and keys.
  4544. **/
  4545. - (instancetype)initWithDoubles:(const double [__nullable])values
  4546. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4547. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4548. /**
  4549. * Initializes this dictionary, copying the entries from the given dictionary.
  4550. *
  4551. * @param dictionary Dictionary containing the entries to add to this dictionary.
  4552. *
  4553. * @return A newly initialized dictionary with the entries of the given dictionary.
  4554. **/
  4555. - (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
  4556. /**
  4557. * Initializes this dictionary with the requested capacity.
  4558. *
  4559. * @param numItems Number of items needed for this dictionary.
  4560. *
  4561. * @return A newly initialized dictionary with the requested capacity.
  4562. **/
  4563. - (instancetype)initWithCapacity:(NSUInteger)numItems;
  4564. /**
  4565. * Gets the value for the given key.
  4566. *
  4567. * @param value Pointer into which the value will be set, if found.
  4568. * @param key Key under which the value is stored, if present.
  4569. *
  4570. * @return YES if the key was found and the value was copied, NO otherwise.
  4571. **/
  4572. - (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key;
  4573. /**
  4574. * Enumerates the keys and values on this dictionary with the given block.
  4575. *
  4576. * @param block The block to enumerate with.
  4577. * **key**: The key for the current entry.
  4578. * **value**: The value for the current entry
  4579. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4580. **/
  4581. - (void)enumerateKeysAndDoublesUsingBlock:
  4582. (void (NS_NOESCAPE ^)(NSString *key, double value, BOOL *stop))block;
  4583. /**
  4584. * Adds the keys and values from another dictionary.
  4585. *
  4586. * @param otherDictionary Dictionary containing entries to be added to this
  4587. * dictionary.
  4588. **/
  4589. - (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;
  4590. /**
  4591. * Sets the value for the given key.
  4592. *
  4593. * @param value The value to set.
  4594. * @param key The key under which to store the value.
  4595. **/
  4596. - (void)setDouble:(double)value forKey:(NSString *)key;
  4597. /**
  4598. * Removes the entry for the given key.
  4599. *
  4600. * @param aKey Key to be removed from this dictionary.
  4601. **/
  4602. - (void)removeDoubleForKey:(NSString *)aKey;
  4603. /**
  4604. * Removes all entries in this dictionary.
  4605. **/
  4606. - (void)removeAll;
  4607. @end
  4608. #pragma mark - String -> Enum
  4609. /**
  4610. * Class used for map fields of <NSString, int32_t>
  4611. * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4612. *
  4613. * @note This class is not meant to be subclassed.
  4614. **/
  4615. @interface GPBStringEnumDictionary : NSObject <NSCopying>
  4616. /** Number of entries stored in this dictionary. */
  4617. @property(nonatomic, readonly) NSUInteger count;
  4618. /** The validation function to check if the enums are valid. */
  4619. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  4620. /**
  4621. * Initializes a dictionary with the given validation function.
  4622. *
  4623. * @param func The enum validation function for the dictionary.
  4624. *
  4625. * @return A newly initialized dictionary.
  4626. **/
  4627. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  4628. /**
  4629. * Initializes a dictionary with the entries given.
  4630. *
  4631. * @param func The enum validation function for the dictionary.
  4632. * @param values The raw enum values values to be placed in the dictionary.
  4633. * @param keys The keys under which to store the values.
  4634. * @param count The number of entries to store in the dictionary.
  4635. *
  4636. * @return A newly initialized dictionary with the keys and values in it.
  4637. **/
  4638. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  4639. rawValues:(const int32_t [__nullable])values
  4640. forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
  4641. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4642. /**
  4643. * Initializes a dictionary with the entries from the given.
  4644. * dictionary.
  4645. *
  4646. * @param dictionary Dictionary containing the entries to add to the dictionary.
  4647. *
  4648. * @return A newly initialized dictionary with the entries from the given
  4649. * dictionary in it.
  4650. **/
  4651. - (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
  4652. /**
  4653. * Initializes a dictionary with the given capacity.
  4654. *
  4655. * @param func The enum validation function for the dictionary.
  4656. * @param numItems Capacity needed for the dictionary.
  4657. *
  4658. * @return A newly initialized dictionary with the given capacity.
  4659. **/
  4660. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  4661. capacity:(NSUInteger)numItems;
  4662. // These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  4663. // is not a valid enumerator as defined by validationFunc. If the actual value is
  4664. // desired, use "raw" version of the method.
  4665. /**
  4666. * Gets the value for the given key.
  4667. *
  4668. * @param value Pointer into which the value will be set, if found.
  4669. * @param key Key under which the value is stored, if present.
  4670. *
  4671. * @return YES if the key was found and the value was copied, NO otherwise.
  4672. **/
  4673. - (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key;
  4674. /**
  4675. * Enumerates the keys and values on this dictionary with the given block.
  4676. *
  4677. * @param block The block to enumerate with.
  4678. * **key**: The key for the current entry.
  4679. * **value**: The value for the current entry
  4680. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4681. **/
  4682. - (void)enumerateKeysAndEnumsUsingBlock:
  4683. (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block;
  4684. /**
  4685. * Gets the raw enum value for the given key.
  4686. *
  4687. * @note This method bypass the validationFunc to enable the access of values that
  4688. * were not known at the time the binary was compiled.
  4689. *
  4690. * @param rawValue Pointer into which the value will be set, if found.
  4691. * @param key Key under which the value is stored, if present.
  4692. *
  4693. * @return YES if the key was found and the value was copied, NO otherwise.
  4694. **/
  4695. - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key;
  4696. /**
  4697. * Enumerates the keys and values on this dictionary with the given block.
  4698. *
  4699. * @note This method bypass the validationFunc to enable the access of values that
  4700. * were not known at the time the binary was compiled.
  4701. *
  4702. * @param block The block to enumerate with.
  4703. * **key**: The key for the current entry.
  4704. * **rawValue**: The value for the current entry
  4705. * **stop**: A pointer to a boolean that when set stops the enumeration.
  4706. **/
  4707. - (void)enumerateKeysAndRawValuesUsingBlock:
  4708. (void (NS_NOESCAPE ^)(NSString *key, int32_t rawValue, BOOL *stop))block;
  4709. /**
  4710. * Adds the keys and raw enum values from another dictionary.
  4711. *
  4712. * @note This method bypass the validationFunc to enable the setting of values that
  4713. * were not known at the time the binary was compiled.
  4714. *
  4715. * @param otherDictionary Dictionary containing entries to be added to this
  4716. * dictionary.
  4717. **/
  4718. - (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;
  4719. // If value is not a valid enumerator as defined by validationFunc, these
  4720. // methods will assert in debug, and will log in release and assign the value
  4721. // to the default value. Use the rawValue methods below to assign non enumerator
  4722. // values.
  4723. /**
  4724. * Sets the value for the given key.
  4725. *
  4726. * @param value The value to set.
  4727. * @param key The key under which to store the value.
  4728. **/
  4729. - (void)setEnum:(int32_t)value forKey:(NSString *)key;
  4730. /**
  4731. * Sets the raw enum value for the given key.
  4732. *
  4733. * @note This method bypass the validationFunc to enable the setting of values that
  4734. * were not known at the time the binary was compiled.
  4735. *
  4736. * @param rawValue The raw enum value to set.
  4737. * @param key The key under which to store the raw enum value.
  4738. **/
  4739. - (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;
  4740. /**
  4741. * Removes the entry for the given key.
  4742. *
  4743. * @param aKey Key to be removed from this dictionary.
  4744. **/
  4745. - (void)removeEnumForKey:(NSString *)aKey;
  4746. /**
  4747. * Removes all entries in this dictionary.
  4748. **/
  4749. - (void)removeAll;
  4750. @end
  4751. // clang-format on
  4752. //%PDDM-EXPAND-END DECLARE_DICTIONARIES()
  4753. NS_ASSUME_NONNULL_END
  4754. //%PDDM-DEFINE DECLARE_DICTIONARIES()
  4755. //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t)
  4756. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t)
  4757. //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t)
  4758. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t)
  4759. //%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL)
  4760. //%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
  4761. //%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
  4762. //%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
  4763. //%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
  4764. //%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
  4765. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
  4766. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
  4767. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t)
  4768. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t)
  4769. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL)
  4770. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float)
  4771. //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
  4772. //%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
  4773. //%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
  4774. //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
  4775. //%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
  4776. //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
  4777. //%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
  4778. //%/**
  4779. //% * Gets the value for the given key.
  4780. //% *
  4781. //% * @param value Pointer into which the value will be set, if found.
  4782. //% * @param key Key under which the value is stored, if present.
  4783. //% *
  4784. //% * @return YES if the key was found and the value was copied, NO otherwise.
  4785. //% **/
  4786. //%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
  4787. //%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
  4788. //%/**
  4789. //% * Fetches the object stored under the given key.
  4790. //% *
  4791. //% * @param key Key under which the value is stored, if present.
  4792. //% *
  4793. //% * @return The object if found, nil otherwise.
  4794. //% **/
  4795. //%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
  4796. //%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
  4797. //%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
  4798. //%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
  4799. // Nothing
  4800. //%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
  4801. // Nothing
  4802. //%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
  4803. //%__nonnull GPB_UNSAFE_UNRETAINED ##
  4804. //%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  4805. //%GPB##KEY_NAME##VALUE_NAME##Dictionary
  4806. //%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  4807. //%GPB##KEY_NAME##VALUE_NAME##Dictionary
  4808. //%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
  4809. //%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
  4810. //%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
  4811. //%#pragma mark - KEY_NAME -> VALUE_NAME
  4812. //%
  4813. //%/**
  4814. //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
  4815. //% * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4816. //% *
  4817. //% * @note This class is not meant to be subclassed.
  4818. //% **/
  4819. //%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
  4820. //%
  4821. //%/** Number of entries stored in this dictionary. */
  4822. //%@property(nonatomic, readonly) NSUInteger count;
  4823. //%
  4824. //%/**
  4825. //% * Initializes this dictionary, copying the given values and keys.
  4826. //% *
  4827. //% * @param ##VNAME_VAR##s The values to be placed in this dictionary.
  4828. //% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
  4829. //% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
  4830. //% *
  4831. //% * @return A newly initialized dictionary with a copy of the values and keys.
  4832. //% **/
  4833. //%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
  4834. //% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
  4835. //% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4836. //%
  4837. //%/**
  4838. //% * Initializes this dictionary, copying the entries from the given dictionary.
  4839. //% *
  4840. //% * @param dictionary Dictionary containing the entries to add to this dictionary.
  4841. //% *
  4842. //% * @return A newly initialized dictionary with the entries of the given dictionary.
  4843. //% **/
  4844. //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  4845. //%
  4846. //%/**
  4847. //% * Initializes this dictionary with the requested capacity.
  4848. //% *
  4849. //% * @param numItems Number of items needed for this dictionary.
  4850. //% *
  4851. //% * @return A newly initialized dictionary with the requested capacity.
  4852. //% **/
  4853. //%- (instancetype)initWithCapacity:(NSUInteger)numItems;
  4854. //%
  4855. //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
  4856. //%
  4857. //%/**
  4858. //% * Adds the keys and values from another dictionary.
  4859. //% *
  4860. //% * @param otherDictionary Dictionary containing entries to be added to this
  4861. //% * dictionary.
  4862. //% **/
  4863. //%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
  4864. //%
  4865. //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
  4866. //%
  4867. //%@end
  4868. //%
  4869. //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
  4870. //%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum)
  4871. //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
  4872. //%#pragma mark - KEY_NAME -> VALUE_NAME
  4873. //%
  4874. //%/**
  4875. //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
  4876. //% * values. This performs better than boxing into NSNumbers in NSDictionaries.
  4877. //% *
  4878. //% * @note This class is not meant to be subclassed.
  4879. //% **/
  4880. //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
  4881. //%
  4882. //%/** Number of entries stored in this dictionary. */
  4883. //%@property(nonatomic, readonly) NSUInteger count;
  4884. //%/** The validation function to check if the enums are valid. */
  4885. //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  4886. //%
  4887. //%/**
  4888. //% * Initializes a dictionary with the given validation function.
  4889. //% *
  4890. //% * @param func The enum validation function for the dictionary.
  4891. //% *
  4892. //% * @return A newly initialized dictionary.
  4893. //% **/
  4894. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  4895. //%
  4896. //%/**
  4897. //% * Initializes a dictionary with the entries given.
  4898. //% *
  4899. //% * @param func The enum validation function for the dictionary.
  4900. //% * @param values The raw enum values values to be placed in the dictionary.
  4901. //% * @param keys The keys under which to store the values.
  4902. //% * @param count The number of entries to store in the dictionary.
  4903. //% *
  4904. //% * @return A newly initialized dictionary with the keys and values in it.
  4905. //% **/
  4906. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  4907. //% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
  4908. //% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
  4909. //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  4910. //%
  4911. //%/**
  4912. //% * Initializes a dictionary with the entries from the given.
  4913. //% * dictionary.
  4914. //% *
  4915. //% * @param dictionary Dictionary containing the entries to add to the dictionary.
  4916. //% *
  4917. //% * @return A newly initialized dictionary with the entries from the given
  4918. //% * dictionary in it.
  4919. //% **/
  4920. //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
  4921. //%
  4922. //%/**
  4923. //% * Initializes a dictionary with the given capacity.
  4924. //% *
  4925. //% * @param func The enum validation function for the dictionary.
  4926. //% * @param numItems Capacity needed for the dictionary.
  4927. //% *
  4928. //% * @return A newly initialized dictionary with the given capacity.
  4929. //% **/
  4930. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  4931. //% capacity:(NSUInteger)numItems;
  4932. //%
  4933. //%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
  4934. //%// is not a valid enumerator as defined by validationFunc. If the actual value is
  4935. //%// desired, use "raw" version of the method.
  4936. //%
  4937. //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
  4938. //%
  4939. //%/**
  4940. //% * Gets the raw enum value for the given key.
  4941. //% *
  4942. //% * @note This method bypass the validationFunc to enable the access of values that
  4943. //% * were not known at the time the binary was compiled.
  4944. //% *
  4945. //% * @param rawValue Pointer into which the value will be set, if found.
  4946. //% * @param key Key under which the value is stored, if present.
  4947. //% *
  4948. //% * @return YES if the key was found and the value was copied, NO otherwise.
  4949. //% **/
  4950. //%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
  4951. //%
  4952. //%/**
  4953. //% * Enumerates the keys and values on this dictionary with the given block.
  4954. //% *
  4955. //% * @note This method bypass the validationFunc to enable the access of values that
  4956. //% * were not known at the time the binary was compiled.
  4957. //% *
  4958. //% * @param block The block to enumerate with.
  4959. //% * **key**: The key for the current entry.
  4960. //% * **rawValue**: The value for the current entry
  4961. //% * **stop**: A pointer to a boolean that when set stops the enumeration.
  4962. //% **/
  4963. //%- (void)enumerateKeysAndRawValuesUsingBlock:
  4964. //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
  4965. //%
  4966. //%/**
  4967. //% * Adds the keys and raw enum values from another dictionary.
  4968. //% *
  4969. //% * @note This method bypass the validationFunc to enable the setting of values that
  4970. //% * were not known at the time the binary was compiled.
  4971. //% *
  4972. //% * @param otherDictionary Dictionary containing entries to be added to this
  4973. //% * dictionary.
  4974. //% **/
  4975. //%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
  4976. //%
  4977. //%// If value is not a valid enumerator as defined by validationFunc, these
  4978. //%// methods will assert in debug, and will log in release and assign the value
  4979. //%// to the default value. Use the rawValue methods below to assign non enumerator
  4980. //%// values.
  4981. //%
  4982. //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
  4983. //%
  4984. //%@end
  4985. //%
  4986. //%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
  4987. //%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME)
  4988. //%
  4989. //%/**
  4990. //% * Enumerates the keys and values on this dictionary with the given block.
  4991. //% *
  4992. //% * @param block The block to enumerate with.
  4993. //% * **key**: ##VNAME_VAR$S## The key for the current entry.
  4994. //% * **VNAME_VAR**: The value for the current entry
  4995. //% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration.
  4996. //% **/
  4997. //%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
  4998. //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block;
  4999. //%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
  5000. //%/**
  5001. //% * Sets the value for the given key.
  5002. //% *
  5003. //% * @param ##VNAME_VAR The value to set.
  5004. //% * @param key ##VNAME_VAR$S## The key under which to store the value.
  5005. //% **/
  5006. //%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key;
  5007. //%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  5008. //%/**
  5009. //% * Removes the entry for the given key.
  5010. //% *
  5011. //% * @param aKey Key to be removed from this dictionary.
  5012. //% **/
  5013. //%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
  5014. //%
  5015. //%/**
  5016. //% * Removes all entries in this dictionary.
  5017. //% **/
  5018. //%- (void)removeAll;
  5019. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  5020. // Empty
  5021. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  5022. // Empty
  5023. //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
  5024. //%
  5025. //%/**
  5026. //% * Sets the raw enum value for the given key.
  5027. //% *
  5028. //% * @note This method bypass the validationFunc to enable the setting of values that
  5029. //% * were not known at the time the binary was compiled.
  5030. //% *
  5031. //% * @param rawValue The raw enum value to set.
  5032. //% * @param key The key under which to store the raw enum value.
  5033. //% **/
  5034. //%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
  5035. //%