GPBDictionary.h 188 KB

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