Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GPBDictionary.h 186KB

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