暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FixedString.gen.cs 326KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163
  1. 
  2. //------------------------------------------------------------------------------
  3. // <auto-generated>
  4. // This code was generated by a tool.
  5. //
  6. // TextTransform Samples/Packages/com.unity.collections/Unity.Collections/FixedString.tt
  7. //
  8. // Changes to this file may cause incorrect behavior and will be lost if
  9. // the code is regenerated.
  10. // </auto-generated>
  11. //------------------------------------------------------------------------------
  12. using System.Collections.Generic;
  13. using System.Collections;
  14. using System.Diagnostics;
  15. using System.Runtime.CompilerServices;
  16. using System.Runtime.InteropServices;
  17. using System;
  18. using Unity.Collections.LowLevel.Unsafe;
  19. using Unity.Mathematics;
  20. using UnityEngine.Internal;
  21. using UnityEngine;
  22. using Unity.Properties;
  23. namespace Unity.Collections
  24. {
  25. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  26. // However, only the first element of data members with names is copied at this time.
  27. // Therefore, it's important that all data visible in the debugger, has a name
  28. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  29. /// <summary>
  30. /// For internal use only. This type is 8 byte aligned
  31. /// </summary>
  32. [Serializable]
  33. [StructLayout(LayoutKind.Explicit, Size=16)]
  34. [GenerateTestsForBurstCompatibility]
  35. internal struct FixedBytes16Align8
  36. {
  37. /// <summary>
  38. /// For internal use only.
  39. /// </summary>
  40. [SerializeField] [FieldOffset(0)] public ulong byte0000;
  41. /// <summary>
  42. /// For internal use only.
  43. /// </summary>
  44. [SerializeField] [FieldOffset(8)] public ulong byte0008;
  45. }
  46. /// <summary>
  47. /// For internal use only.
  48. /// </summary>
  49. [Serializable]
  50. [StructLayout(LayoutKind.Explicit, Size=16)]
  51. [GenerateTestsForBurstCompatibility]
  52. public struct FixedBytes16
  53. {
  54. /// <summary>
  55. /// For internal use only.
  56. /// </summary>
  57. [FieldOffset(0)] public byte byte0000;
  58. /// <summary>
  59. /// For internal use only.
  60. /// </summary>
  61. [FieldOffset(1)] public byte byte0001;
  62. /// <summary>
  63. /// For internal use only.
  64. /// </summary>
  65. [FieldOffset(2)] public byte byte0002;
  66. /// <summary>
  67. /// For internal use only.
  68. /// </summary>
  69. [FieldOffset(3)] public byte byte0003;
  70. /// <summary>
  71. /// For internal use only.
  72. /// </summary>
  73. [FieldOffset(4)] public byte byte0004;
  74. /// <summary>
  75. /// For internal use only.
  76. /// </summary>
  77. [FieldOffset(5)] public byte byte0005;
  78. /// <summary>
  79. /// For internal use only.
  80. /// </summary>
  81. [FieldOffset(6)] public byte byte0006;
  82. /// <summary>
  83. /// For internal use only.
  84. /// </summary>
  85. [FieldOffset(7)] public byte byte0007;
  86. /// <summary>
  87. /// For internal use only.
  88. /// </summary>
  89. [FieldOffset(8)] public byte byte0008;
  90. /// <summary>
  91. /// For internal use only.
  92. /// </summary>
  93. [FieldOffset(9)] public byte byte0009;
  94. /// <summary>
  95. /// For internal use only.
  96. /// </summary>
  97. [FieldOffset(10)] public byte byte0010;
  98. /// <summary>
  99. /// For internal use only.
  100. /// </summary>
  101. [FieldOffset(11)] public byte byte0011;
  102. /// <summary>
  103. /// For internal use only.
  104. /// </summary>
  105. [FieldOffset(12)] public byte byte0012;
  106. /// <summary>
  107. /// For internal use only.
  108. /// </summary>
  109. [FieldOffset(13)] public byte byte0013;
  110. /// <summary>
  111. /// For internal use only.
  112. /// </summary>
  113. [FieldOffset(14)] public byte byte0014;
  114. /// <summary>
  115. /// For internal use only.
  116. /// </summary>
  117. [FieldOffset(15)] public byte byte0015;
  118. }
  119. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  120. // However, only the first element of data members with names is copied at this time.
  121. // Therefore, it's important that all data visible in the debugger, has a name
  122. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  123. /// <summary>
  124. /// For internal use only.
  125. /// </summary>
  126. [Serializable]
  127. [StructLayout(LayoutKind.Explicit, Size=32)]
  128. [GenerateTestsForBurstCompatibility]
  129. internal struct FixedBytes32Align8
  130. {
  131. /// <summary>
  132. /// For internal use only.
  133. /// </summary>
  134. [SerializeField] [FieldOffset(0)] internal FixedBytes16Align8 offset0000;
  135. /// <summary>
  136. /// For internal use only.
  137. /// </summary>
  138. [SerializeField] [FieldOffset(16)] internal FixedBytes16Align8 offset0016;
  139. }
  140. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  141. // However, only the first element of data members with names is copied at this time.
  142. // Therefore, it's important that all data visible in the debugger, has a name
  143. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  144. /// <summary>
  145. /// For internal use only.
  146. /// </summary>
  147. [Serializable]
  148. [StructLayout(LayoutKind.Explicit, Size=64)]
  149. [GenerateTestsForBurstCompatibility]
  150. internal struct FixedBytes64Align8
  151. {
  152. /// <summary>
  153. /// For internal use only.
  154. /// </summary>
  155. [SerializeField] [FieldOffset(0)] internal FixedBytes16Align8 offset0000;
  156. /// <summary>
  157. /// For internal use only.
  158. /// </summary>
  159. [SerializeField] [FieldOffset(16)] internal FixedBytes16Align8 offset0016;
  160. /// <summary>
  161. /// For internal use only.
  162. /// </summary>
  163. [SerializeField] [FieldOffset(32)] internal FixedBytes16Align8 offset0032;
  164. /// <summary>
  165. /// For internal use only.
  166. /// </summary>
  167. [SerializeField] [FieldOffset(48)] internal FixedBytes16Align8 offset0048;
  168. }
  169. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  170. // However, only the first element of data members with names is copied at this time.
  171. // Therefore, it's important that all data visible in the debugger, has a name
  172. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  173. /// <summary>
  174. /// For internal use only.
  175. /// </summary>
  176. [Serializable]
  177. [StructLayout(LayoutKind.Explicit, Size=128)]
  178. [GenerateTestsForBurstCompatibility]
  179. internal struct FixedBytes128Align8
  180. {
  181. /// <summary>
  182. /// For internal use only.
  183. /// </summary>
  184. [SerializeField] [FieldOffset(0)] internal FixedBytes16Align8 offset0000;
  185. /// <summary>
  186. /// For internal use only.
  187. /// </summary>
  188. [SerializeField] [FieldOffset(16)] internal FixedBytes16Align8 offset0016;
  189. /// <summary>
  190. /// For internal use only.
  191. /// </summary>
  192. [SerializeField] [FieldOffset(32)] internal FixedBytes16Align8 offset0032;
  193. /// <summary>
  194. /// For internal use only.
  195. /// </summary>
  196. [SerializeField] [FieldOffset(48)] internal FixedBytes16Align8 offset0048;
  197. /// <summary>
  198. /// For internal use only.
  199. /// </summary>
  200. [SerializeField] [FieldOffset(64)] internal FixedBytes16Align8 offset0064;
  201. /// <summary>
  202. /// For internal use only.
  203. /// </summary>
  204. [SerializeField] [FieldOffset(80)] internal FixedBytes16Align8 offset0080;
  205. /// <summary>
  206. /// For internal use only.
  207. /// </summary>
  208. [SerializeField] [FieldOffset(96)] internal FixedBytes16Align8 offset0096;
  209. /// <summary>
  210. /// For internal use only.
  211. /// </summary>
  212. [SerializeField] [FieldOffset(112)] internal FixedBytes16Align8 offset0112;
  213. }
  214. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  215. // However, only the first element of data members with names is copied at this time.
  216. // Therefore, it's important that all data visible in the debugger, has a name
  217. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  218. /// <summary>
  219. /// For internal use only.
  220. /// </summary>
  221. [Serializable]
  222. [StructLayout(LayoutKind.Explicit, Size=512)]
  223. [GenerateTestsForBurstCompatibility]
  224. internal struct FixedBytes512Align8
  225. {
  226. /// <summary>
  227. /// For internal use only.
  228. /// </summary>
  229. [SerializeField] [FieldOffset(0)] internal FixedBytes16Align8 offset0000;
  230. /// <summary>
  231. /// For internal use only.
  232. /// </summary>
  233. [SerializeField] [FieldOffset(16)] internal FixedBytes16Align8 offset0016;
  234. /// <summary>
  235. /// For internal use only.
  236. /// </summary>
  237. [SerializeField] [FieldOffset(32)] internal FixedBytes16Align8 offset0032;
  238. /// <summary>
  239. /// For internal use only.
  240. /// </summary>
  241. [SerializeField] [FieldOffset(48)] internal FixedBytes16Align8 offset0048;
  242. /// <summary>
  243. /// For internal use only.
  244. /// </summary>
  245. [SerializeField] [FieldOffset(64)] internal FixedBytes16Align8 offset0064;
  246. /// <summary>
  247. /// For internal use only.
  248. /// </summary>
  249. [SerializeField] [FieldOffset(80)] internal FixedBytes16Align8 offset0080;
  250. /// <summary>
  251. /// For internal use only.
  252. /// </summary>
  253. [SerializeField] [FieldOffset(96)] internal FixedBytes16Align8 offset0096;
  254. /// <summary>
  255. /// For internal use only.
  256. /// </summary>
  257. [SerializeField] [FieldOffset(112)] internal FixedBytes16Align8 offset0112;
  258. /// <summary>
  259. /// For internal use only.
  260. /// </summary>
  261. [SerializeField] [FieldOffset(128)] internal FixedBytes16Align8 offset0128;
  262. /// <summary>
  263. /// For internal use only.
  264. /// </summary>
  265. [SerializeField] [FieldOffset(144)] internal FixedBytes16Align8 offset0144;
  266. /// <summary>
  267. /// For internal use only.
  268. /// </summary>
  269. [SerializeField] [FieldOffset(160)] internal FixedBytes16Align8 offset0160;
  270. /// <summary>
  271. /// For internal use only.
  272. /// </summary>
  273. [SerializeField] [FieldOffset(176)] internal FixedBytes16Align8 offset0176;
  274. /// <summary>
  275. /// For internal use only.
  276. /// </summary>
  277. [SerializeField] [FieldOffset(192)] internal FixedBytes16Align8 offset0192;
  278. /// <summary>
  279. /// For internal use only.
  280. /// </summary>
  281. [SerializeField] [FieldOffset(208)] internal FixedBytes16Align8 offset0208;
  282. /// <summary>
  283. /// For internal use only.
  284. /// </summary>
  285. [SerializeField] [FieldOffset(224)] internal FixedBytes16Align8 offset0224;
  286. /// <summary>
  287. /// For internal use only.
  288. /// </summary>
  289. [SerializeField] [FieldOffset(240)] internal FixedBytes16Align8 offset0240;
  290. /// <summary>
  291. /// For internal use only.
  292. /// </summary>
  293. [SerializeField] [FieldOffset(256)] internal FixedBytes16Align8 offset0256;
  294. /// <summary>
  295. /// For internal use only.
  296. /// </summary>
  297. [SerializeField] [FieldOffset(272)] internal FixedBytes16Align8 offset0272;
  298. /// <summary>
  299. /// For internal use only.
  300. /// </summary>
  301. [SerializeField] [FieldOffset(288)] internal FixedBytes16Align8 offset0288;
  302. /// <summary>
  303. /// For internal use only.
  304. /// </summary>
  305. [SerializeField] [FieldOffset(304)] internal FixedBytes16Align8 offset0304;
  306. /// <summary>
  307. /// For internal use only.
  308. /// </summary>
  309. [SerializeField] [FieldOffset(320)] internal FixedBytes16Align8 offset0320;
  310. /// <summary>
  311. /// For internal use only.
  312. /// </summary>
  313. [SerializeField] [FieldOffset(336)] internal FixedBytes16Align8 offset0336;
  314. /// <summary>
  315. /// For internal use only.
  316. /// </summary>
  317. [SerializeField] [FieldOffset(352)] internal FixedBytes16Align8 offset0352;
  318. /// <summary>
  319. /// For internal use only.
  320. /// </summary>
  321. [SerializeField] [FieldOffset(368)] internal FixedBytes16Align8 offset0368;
  322. /// <summary>
  323. /// For internal use only.
  324. /// </summary>
  325. [SerializeField] [FieldOffset(384)] internal FixedBytes16Align8 offset0384;
  326. /// <summary>
  327. /// For internal use only.
  328. /// </summary>
  329. [SerializeField] [FieldOffset(400)] internal FixedBytes16Align8 offset0400;
  330. /// <summary>
  331. /// For internal use only.
  332. /// </summary>
  333. [SerializeField] [FieldOffset(416)] internal FixedBytes16Align8 offset0416;
  334. /// <summary>
  335. /// For internal use only.
  336. /// </summary>
  337. [SerializeField] [FieldOffset(432)] internal FixedBytes16Align8 offset0432;
  338. /// <summary>
  339. /// For internal use only.
  340. /// </summary>
  341. [SerializeField] [FieldOffset(448)] internal FixedBytes16Align8 offset0448;
  342. /// <summary>
  343. /// For internal use only.
  344. /// </summary>
  345. [SerializeField] [FieldOffset(464)] internal FixedBytes16Align8 offset0464;
  346. /// <summary>
  347. /// For internal use only.
  348. /// </summary>
  349. [SerializeField] [FieldOffset(480)] internal FixedBytes16Align8 offset0480;
  350. /// <summary>
  351. /// For internal use only.
  352. /// </summary>
  353. [SerializeField] [FieldOffset(496)] internal FixedBytes16Align8 offset0496;
  354. }
  355. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  356. // However, only the first element of data members with names is copied at this time.
  357. // Therefore, it's important that all data visible in the debugger, has a name
  358. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  359. /// <summary>
  360. /// For internal use only.
  361. /// </summary>
  362. [Serializable]
  363. [StructLayout(LayoutKind.Explicit, Size=4096)]
  364. [GenerateTestsForBurstCompatibility]
  365. internal struct FixedBytes4096Align8
  366. {
  367. /// <summary>
  368. /// For internal use only.
  369. /// </summary>
  370. [SerializeField] [FieldOffset(0)] internal FixedBytes16Align8 offset0000;
  371. /// <summary>
  372. /// For internal use only.
  373. /// </summary>
  374. [SerializeField] [FieldOffset(16)] internal FixedBytes16Align8 offset0016;
  375. /// <summary>
  376. /// For internal use only.
  377. /// </summary>
  378. [SerializeField] [FieldOffset(32)] internal FixedBytes16Align8 offset0032;
  379. /// <summary>
  380. /// For internal use only.
  381. /// </summary>
  382. [SerializeField] [FieldOffset(48)] internal FixedBytes16Align8 offset0048;
  383. /// <summary>
  384. /// For internal use only.
  385. /// </summary>
  386. [SerializeField] [FieldOffset(64)] internal FixedBytes16Align8 offset0064;
  387. /// <summary>
  388. /// For internal use only.
  389. /// </summary>
  390. [SerializeField] [FieldOffset(80)] internal FixedBytes16Align8 offset0080;
  391. /// <summary>
  392. /// For internal use only.
  393. /// </summary>
  394. [SerializeField] [FieldOffset(96)] internal FixedBytes16Align8 offset0096;
  395. /// <summary>
  396. /// For internal use only.
  397. /// </summary>
  398. [SerializeField] [FieldOffset(112)] internal FixedBytes16Align8 offset0112;
  399. /// <summary>
  400. /// For internal use only.
  401. /// </summary>
  402. [SerializeField] [FieldOffset(128)] internal FixedBytes16Align8 offset0128;
  403. /// <summary>
  404. /// For internal use only.
  405. /// </summary>
  406. [SerializeField] [FieldOffset(144)] internal FixedBytes16Align8 offset0144;
  407. /// <summary>
  408. /// For internal use only.
  409. /// </summary>
  410. [SerializeField] [FieldOffset(160)] internal FixedBytes16Align8 offset0160;
  411. /// <summary>
  412. /// For internal use only.
  413. /// </summary>
  414. [SerializeField] [FieldOffset(176)] internal FixedBytes16Align8 offset0176;
  415. /// <summary>
  416. /// For internal use only.
  417. /// </summary>
  418. [SerializeField] [FieldOffset(192)] internal FixedBytes16Align8 offset0192;
  419. /// <summary>
  420. /// For internal use only.
  421. /// </summary>
  422. [SerializeField] [FieldOffset(208)] internal FixedBytes16Align8 offset0208;
  423. /// <summary>
  424. /// For internal use only.
  425. /// </summary>
  426. [SerializeField] [FieldOffset(224)] internal FixedBytes16Align8 offset0224;
  427. /// <summary>
  428. /// For internal use only.
  429. /// </summary>
  430. [SerializeField] [FieldOffset(240)] internal FixedBytes16Align8 offset0240;
  431. /// <summary>
  432. /// For internal use only.
  433. /// </summary>
  434. [SerializeField] [FieldOffset(256)] internal FixedBytes16Align8 offset0256;
  435. /// <summary>
  436. /// For internal use only.
  437. /// </summary>
  438. [SerializeField] [FieldOffset(272)] internal FixedBytes16Align8 offset0272;
  439. /// <summary>
  440. /// For internal use only.
  441. /// </summary>
  442. [SerializeField] [FieldOffset(288)] internal FixedBytes16Align8 offset0288;
  443. /// <summary>
  444. /// For internal use only.
  445. /// </summary>
  446. [SerializeField] [FieldOffset(304)] internal FixedBytes16Align8 offset0304;
  447. /// <summary>
  448. /// For internal use only.
  449. /// </summary>
  450. [SerializeField] [FieldOffset(320)] internal FixedBytes16Align8 offset0320;
  451. /// <summary>
  452. /// For internal use only.
  453. /// </summary>
  454. [SerializeField] [FieldOffset(336)] internal FixedBytes16Align8 offset0336;
  455. /// <summary>
  456. /// For internal use only.
  457. /// </summary>
  458. [SerializeField] [FieldOffset(352)] internal FixedBytes16Align8 offset0352;
  459. /// <summary>
  460. /// For internal use only.
  461. /// </summary>
  462. [SerializeField] [FieldOffset(368)] internal FixedBytes16Align8 offset0368;
  463. /// <summary>
  464. /// For internal use only.
  465. /// </summary>
  466. [SerializeField] [FieldOffset(384)] internal FixedBytes16Align8 offset0384;
  467. /// <summary>
  468. /// For internal use only.
  469. /// </summary>
  470. [SerializeField] [FieldOffset(400)] internal FixedBytes16Align8 offset0400;
  471. /// <summary>
  472. /// For internal use only.
  473. /// </summary>
  474. [SerializeField] [FieldOffset(416)] internal FixedBytes16Align8 offset0416;
  475. /// <summary>
  476. /// For internal use only.
  477. /// </summary>
  478. [SerializeField] [FieldOffset(432)] internal FixedBytes16Align8 offset0432;
  479. /// <summary>
  480. /// For internal use only.
  481. /// </summary>
  482. [SerializeField] [FieldOffset(448)] internal FixedBytes16Align8 offset0448;
  483. /// <summary>
  484. /// For internal use only.
  485. /// </summary>
  486. [SerializeField] [FieldOffset(464)] internal FixedBytes16Align8 offset0464;
  487. /// <summary>
  488. /// For internal use only.
  489. /// </summary>
  490. [SerializeField] [FieldOffset(480)] internal FixedBytes16Align8 offset0480;
  491. /// <summary>
  492. /// For internal use only.
  493. /// </summary>
  494. [SerializeField] [FieldOffset(496)] internal FixedBytes16Align8 offset0496;
  495. /// <summary>
  496. /// For internal use only.
  497. /// </summary>
  498. [SerializeField] [FieldOffset(512)] internal FixedBytes16Align8 offset0512;
  499. /// <summary>
  500. /// For internal use only.
  501. /// </summary>
  502. [SerializeField] [FieldOffset(528)] internal FixedBytes16Align8 offset0528;
  503. /// <summary>
  504. /// For internal use only.
  505. /// </summary>
  506. [SerializeField] [FieldOffset(544)] internal FixedBytes16Align8 offset0544;
  507. /// <summary>
  508. /// For internal use only.
  509. /// </summary>
  510. [SerializeField] [FieldOffset(560)] internal FixedBytes16Align8 offset0560;
  511. /// <summary>
  512. /// For internal use only.
  513. /// </summary>
  514. [SerializeField] [FieldOffset(576)] internal FixedBytes16Align8 offset0576;
  515. /// <summary>
  516. /// For internal use only.
  517. /// </summary>
  518. [SerializeField] [FieldOffset(592)] internal FixedBytes16Align8 offset0592;
  519. /// <summary>
  520. /// For internal use only.
  521. /// </summary>
  522. [SerializeField] [FieldOffset(608)] internal FixedBytes16Align8 offset0608;
  523. /// <summary>
  524. /// For internal use only.
  525. /// </summary>
  526. [SerializeField] [FieldOffset(624)] internal FixedBytes16Align8 offset0624;
  527. /// <summary>
  528. /// For internal use only.
  529. /// </summary>
  530. [SerializeField] [FieldOffset(640)] internal FixedBytes16Align8 offset0640;
  531. /// <summary>
  532. /// For internal use only.
  533. /// </summary>
  534. [SerializeField] [FieldOffset(656)] internal FixedBytes16Align8 offset0656;
  535. /// <summary>
  536. /// For internal use only.
  537. /// </summary>
  538. [SerializeField] [FieldOffset(672)] internal FixedBytes16Align8 offset0672;
  539. /// <summary>
  540. /// For internal use only.
  541. /// </summary>
  542. [SerializeField] [FieldOffset(688)] internal FixedBytes16Align8 offset0688;
  543. /// <summary>
  544. /// For internal use only.
  545. /// </summary>
  546. [SerializeField] [FieldOffset(704)] internal FixedBytes16Align8 offset0704;
  547. /// <summary>
  548. /// For internal use only.
  549. /// </summary>
  550. [SerializeField] [FieldOffset(720)] internal FixedBytes16Align8 offset0720;
  551. /// <summary>
  552. /// For internal use only.
  553. /// </summary>
  554. [SerializeField] [FieldOffset(736)] internal FixedBytes16Align8 offset0736;
  555. /// <summary>
  556. /// For internal use only.
  557. /// </summary>
  558. [SerializeField] [FieldOffset(752)] internal FixedBytes16Align8 offset0752;
  559. /// <summary>
  560. /// For internal use only.
  561. /// </summary>
  562. [SerializeField] [FieldOffset(768)] internal FixedBytes16Align8 offset0768;
  563. /// <summary>
  564. /// For internal use only.
  565. /// </summary>
  566. [SerializeField] [FieldOffset(784)] internal FixedBytes16Align8 offset0784;
  567. /// <summary>
  568. /// For internal use only.
  569. /// </summary>
  570. [SerializeField] [FieldOffset(800)] internal FixedBytes16Align8 offset0800;
  571. /// <summary>
  572. /// For internal use only.
  573. /// </summary>
  574. [SerializeField] [FieldOffset(816)] internal FixedBytes16Align8 offset0816;
  575. /// <summary>
  576. /// For internal use only.
  577. /// </summary>
  578. [SerializeField] [FieldOffset(832)] internal FixedBytes16Align8 offset0832;
  579. /// <summary>
  580. /// For internal use only.
  581. /// </summary>
  582. [SerializeField] [FieldOffset(848)] internal FixedBytes16Align8 offset0848;
  583. /// <summary>
  584. /// For internal use only.
  585. /// </summary>
  586. [SerializeField] [FieldOffset(864)] internal FixedBytes16Align8 offset0864;
  587. /// <summary>
  588. /// For internal use only.
  589. /// </summary>
  590. [SerializeField] [FieldOffset(880)] internal FixedBytes16Align8 offset0880;
  591. /// <summary>
  592. /// For internal use only.
  593. /// </summary>
  594. [SerializeField] [FieldOffset(896)] internal FixedBytes16Align8 offset0896;
  595. /// <summary>
  596. /// For internal use only.
  597. /// </summary>
  598. [SerializeField] [FieldOffset(912)] internal FixedBytes16Align8 offset0912;
  599. /// <summary>
  600. /// For internal use only.
  601. /// </summary>
  602. [SerializeField] [FieldOffset(928)] internal FixedBytes16Align8 offset0928;
  603. /// <summary>
  604. /// For internal use only.
  605. /// </summary>
  606. [SerializeField] [FieldOffset(944)] internal FixedBytes16Align8 offset0944;
  607. /// <summary>
  608. /// For internal use only.
  609. /// </summary>
  610. [SerializeField] [FieldOffset(960)] internal FixedBytes16Align8 offset0960;
  611. /// <summary>
  612. /// For internal use only.
  613. /// </summary>
  614. [SerializeField] [FieldOffset(976)] internal FixedBytes16Align8 offset0976;
  615. /// <summary>
  616. /// For internal use only.
  617. /// </summary>
  618. [SerializeField] [FieldOffset(992)] internal FixedBytes16Align8 offset0992;
  619. /// <summary>
  620. /// For internal use only.
  621. /// </summary>
  622. [SerializeField] [FieldOffset(1008)] internal FixedBytes16Align8 offset1008;
  623. /// <summary>
  624. /// For internal use only.
  625. /// </summary>
  626. [SerializeField] [FieldOffset(1024)] internal FixedBytes16Align8 offset1024;
  627. /// <summary>
  628. /// For internal use only.
  629. /// </summary>
  630. [SerializeField] [FieldOffset(1040)] internal FixedBytes16Align8 offset1040;
  631. /// <summary>
  632. /// For internal use only.
  633. /// </summary>
  634. [SerializeField] [FieldOffset(1056)] internal FixedBytes16Align8 offset1056;
  635. /// <summary>
  636. /// For internal use only.
  637. /// </summary>
  638. [SerializeField] [FieldOffset(1072)] internal FixedBytes16Align8 offset1072;
  639. /// <summary>
  640. /// For internal use only.
  641. /// </summary>
  642. [SerializeField] [FieldOffset(1088)] internal FixedBytes16Align8 offset1088;
  643. /// <summary>
  644. /// For internal use only.
  645. /// </summary>
  646. [SerializeField] [FieldOffset(1104)] internal FixedBytes16Align8 offset1104;
  647. /// <summary>
  648. /// For internal use only.
  649. /// </summary>
  650. [SerializeField] [FieldOffset(1120)] internal FixedBytes16Align8 offset1120;
  651. /// <summary>
  652. /// For internal use only.
  653. /// </summary>
  654. [SerializeField] [FieldOffset(1136)] internal FixedBytes16Align8 offset1136;
  655. /// <summary>
  656. /// For internal use only.
  657. /// </summary>
  658. [SerializeField] [FieldOffset(1152)] internal FixedBytes16Align8 offset1152;
  659. /// <summary>
  660. /// For internal use only.
  661. /// </summary>
  662. [SerializeField] [FieldOffset(1168)] internal FixedBytes16Align8 offset1168;
  663. /// <summary>
  664. /// For internal use only.
  665. /// </summary>
  666. [SerializeField] [FieldOffset(1184)] internal FixedBytes16Align8 offset1184;
  667. /// <summary>
  668. /// For internal use only.
  669. /// </summary>
  670. [SerializeField] [FieldOffset(1200)] internal FixedBytes16Align8 offset1200;
  671. /// <summary>
  672. /// For internal use only.
  673. /// </summary>
  674. [SerializeField] [FieldOffset(1216)] internal FixedBytes16Align8 offset1216;
  675. /// <summary>
  676. /// For internal use only.
  677. /// </summary>
  678. [SerializeField] [FieldOffset(1232)] internal FixedBytes16Align8 offset1232;
  679. /// <summary>
  680. /// For internal use only.
  681. /// </summary>
  682. [SerializeField] [FieldOffset(1248)] internal FixedBytes16Align8 offset1248;
  683. /// <summary>
  684. /// For internal use only.
  685. /// </summary>
  686. [SerializeField] [FieldOffset(1264)] internal FixedBytes16Align8 offset1264;
  687. /// <summary>
  688. /// For internal use only.
  689. /// </summary>
  690. [SerializeField] [FieldOffset(1280)] internal FixedBytes16Align8 offset1280;
  691. /// <summary>
  692. /// For internal use only.
  693. /// </summary>
  694. [SerializeField] [FieldOffset(1296)] internal FixedBytes16Align8 offset1296;
  695. /// <summary>
  696. /// For internal use only.
  697. /// </summary>
  698. [SerializeField] [FieldOffset(1312)] internal FixedBytes16Align8 offset1312;
  699. /// <summary>
  700. /// For internal use only.
  701. /// </summary>
  702. [SerializeField] [FieldOffset(1328)] internal FixedBytes16Align8 offset1328;
  703. /// <summary>
  704. /// For internal use only.
  705. /// </summary>
  706. [SerializeField] [FieldOffset(1344)] internal FixedBytes16Align8 offset1344;
  707. /// <summary>
  708. /// For internal use only.
  709. /// </summary>
  710. [SerializeField] [FieldOffset(1360)] internal FixedBytes16Align8 offset1360;
  711. /// <summary>
  712. /// For internal use only.
  713. /// </summary>
  714. [SerializeField] [FieldOffset(1376)] internal FixedBytes16Align8 offset1376;
  715. /// <summary>
  716. /// For internal use only.
  717. /// </summary>
  718. [SerializeField] [FieldOffset(1392)] internal FixedBytes16Align8 offset1392;
  719. /// <summary>
  720. /// For internal use only.
  721. /// </summary>
  722. [SerializeField] [FieldOffset(1408)] internal FixedBytes16Align8 offset1408;
  723. /// <summary>
  724. /// For internal use only.
  725. /// </summary>
  726. [SerializeField] [FieldOffset(1424)] internal FixedBytes16Align8 offset1424;
  727. /// <summary>
  728. /// For internal use only.
  729. /// </summary>
  730. [SerializeField] [FieldOffset(1440)] internal FixedBytes16Align8 offset1440;
  731. /// <summary>
  732. /// For internal use only.
  733. /// </summary>
  734. [SerializeField] [FieldOffset(1456)] internal FixedBytes16Align8 offset1456;
  735. /// <summary>
  736. /// For internal use only.
  737. /// </summary>
  738. [SerializeField] [FieldOffset(1472)] internal FixedBytes16Align8 offset1472;
  739. /// <summary>
  740. /// For internal use only.
  741. /// </summary>
  742. [SerializeField] [FieldOffset(1488)] internal FixedBytes16Align8 offset1488;
  743. /// <summary>
  744. /// For internal use only.
  745. /// </summary>
  746. [SerializeField] [FieldOffset(1504)] internal FixedBytes16Align8 offset1504;
  747. /// <summary>
  748. /// For internal use only.
  749. /// </summary>
  750. [SerializeField] [FieldOffset(1520)] internal FixedBytes16Align8 offset1520;
  751. /// <summary>
  752. /// For internal use only.
  753. /// </summary>
  754. [SerializeField] [FieldOffset(1536)] internal FixedBytes16Align8 offset1536;
  755. /// <summary>
  756. /// For internal use only.
  757. /// </summary>
  758. [SerializeField] [FieldOffset(1552)] internal FixedBytes16Align8 offset1552;
  759. /// <summary>
  760. /// For internal use only.
  761. /// </summary>
  762. [SerializeField] [FieldOffset(1568)] internal FixedBytes16Align8 offset1568;
  763. /// <summary>
  764. /// For internal use only.
  765. /// </summary>
  766. [SerializeField] [FieldOffset(1584)] internal FixedBytes16Align8 offset1584;
  767. /// <summary>
  768. /// For internal use only.
  769. /// </summary>
  770. [SerializeField] [FieldOffset(1600)] internal FixedBytes16Align8 offset1600;
  771. /// <summary>
  772. /// For internal use only.
  773. /// </summary>
  774. [SerializeField] [FieldOffset(1616)] internal FixedBytes16Align8 offset1616;
  775. /// <summary>
  776. /// For internal use only.
  777. /// </summary>
  778. [SerializeField] [FieldOffset(1632)] internal FixedBytes16Align8 offset1632;
  779. /// <summary>
  780. /// For internal use only.
  781. /// </summary>
  782. [SerializeField] [FieldOffset(1648)] internal FixedBytes16Align8 offset1648;
  783. /// <summary>
  784. /// For internal use only.
  785. /// </summary>
  786. [SerializeField] [FieldOffset(1664)] internal FixedBytes16Align8 offset1664;
  787. /// <summary>
  788. /// For internal use only.
  789. /// </summary>
  790. [SerializeField] [FieldOffset(1680)] internal FixedBytes16Align8 offset1680;
  791. /// <summary>
  792. /// For internal use only.
  793. /// </summary>
  794. [SerializeField] [FieldOffset(1696)] internal FixedBytes16Align8 offset1696;
  795. /// <summary>
  796. /// For internal use only.
  797. /// </summary>
  798. [SerializeField] [FieldOffset(1712)] internal FixedBytes16Align8 offset1712;
  799. /// <summary>
  800. /// For internal use only.
  801. /// </summary>
  802. [SerializeField] [FieldOffset(1728)] internal FixedBytes16Align8 offset1728;
  803. /// <summary>
  804. /// For internal use only.
  805. /// </summary>
  806. [SerializeField] [FieldOffset(1744)] internal FixedBytes16Align8 offset1744;
  807. /// <summary>
  808. /// For internal use only.
  809. /// </summary>
  810. [SerializeField] [FieldOffset(1760)] internal FixedBytes16Align8 offset1760;
  811. /// <summary>
  812. /// For internal use only.
  813. /// </summary>
  814. [SerializeField] [FieldOffset(1776)] internal FixedBytes16Align8 offset1776;
  815. /// <summary>
  816. /// For internal use only.
  817. /// </summary>
  818. [SerializeField] [FieldOffset(1792)] internal FixedBytes16Align8 offset1792;
  819. /// <summary>
  820. /// For internal use only.
  821. /// </summary>
  822. [SerializeField] [FieldOffset(1808)] internal FixedBytes16Align8 offset1808;
  823. /// <summary>
  824. /// For internal use only.
  825. /// </summary>
  826. [SerializeField] [FieldOffset(1824)] internal FixedBytes16Align8 offset1824;
  827. /// <summary>
  828. /// For internal use only.
  829. /// </summary>
  830. [SerializeField] [FieldOffset(1840)] internal FixedBytes16Align8 offset1840;
  831. /// <summary>
  832. /// For internal use only.
  833. /// </summary>
  834. [SerializeField] [FieldOffset(1856)] internal FixedBytes16Align8 offset1856;
  835. /// <summary>
  836. /// For internal use only.
  837. /// </summary>
  838. [SerializeField] [FieldOffset(1872)] internal FixedBytes16Align8 offset1872;
  839. /// <summary>
  840. /// For internal use only.
  841. /// </summary>
  842. [SerializeField] [FieldOffset(1888)] internal FixedBytes16Align8 offset1888;
  843. /// <summary>
  844. /// For internal use only.
  845. /// </summary>
  846. [SerializeField] [FieldOffset(1904)] internal FixedBytes16Align8 offset1904;
  847. /// <summary>
  848. /// For internal use only.
  849. /// </summary>
  850. [SerializeField] [FieldOffset(1920)] internal FixedBytes16Align8 offset1920;
  851. /// <summary>
  852. /// For internal use only.
  853. /// </summary>
  854. [SerializeField] [FieldOffset(1936)] internal FixedBytes16Align8 offset1936;
  855. /// <summary>
  856. /// For internal use only.
  857. /// </summary>
  858. [SerializeField] [FieldOffset(1952)] internal FixedBytes16Align8 offset1952;
  859. /// <summary>
  860. /// For internal use only.
  861. /// </summary>
  862. [SerializeField] [FieldOffset(1968)] internal FixedBytes16Align8 offset1968;
  863. /// <summary>
  864. /// For internal use only.
  865. /// </summary>
  866. [SerializeField] [FieldOffset(1984)] internal FixedBytes16Align8 offset1984;
  867. /// <summary>
  868. /// For internal use only.
  869. /// </summary>
  870. [SerializeField] [FieldOffset(2000)] internal FixedBytes16Align8 offset2000;
  871. /// <summary>
  872. /// For internal use only.
  873. /// </summary>
  874. [SerializeField] [FieldOffset(2016)] internal FixedBytes16Align8 offset2016;
  875. /// <summary>
  876. /// For internal use only.
  877. /// </summary>
  878. [SerializeField] [FieldOffset(2032)] internal FixedBytes16Align8 offset2032;
  879. /// <summary>
  880. /// For internal use only.
  881. /// </summary>
  882. [SerializeField] [FieldOffset(2048)] internal FixedBytes16Align8 offset2048;
  883. /// <summary>
  884. /// For internal use only.
  885. /// </summary>
  886. [SerializeField] [FieldOffset(2064)] internal FixedBytes16Align8 offset2064;
  887. /// <summary>
  888. /// For internal use only.
  889. /// </summary>
  890. [SerializeField] [FieldOffset(2080)] internal FixedBytes16Align8 offset2080;
  891. /// <summary>
  892. /// For internal use only.
  893. /// </summary>
  894. [SerializeField] [FieldOffset(2096)] internal FixedBytes16Align8 offset2096;
  895. /// <summary>
  896. /// For internal use only.
  897. /// </summary>
  898. [SerializeField] [FieldOffset(2112)] internal FixedBytes16Align8 offset2112;
  899. /// <summary>
  900. /// For internal use only.
  901. /// </summary>
  902. [SerializeField] [FieldOffset(2128)] internal FixedBytes16Align8 offset2128;
  903. /// <summary>
  904. /// For internal use only.
  905. /// </summary>
  906. [SerializeField] [FieldOffset(2144)] internal FixedBytes16Align8 offset2144;
  907. /// <summary>
  908. /// For internal use only.
  909. /// </summary>
  910. [SerializeField] [FieldOffset(2160)] internal FixedBytes16Align8 offset2160;
  911. /// <summary>
  912. /// For internal use only.
  913. /// </summary>
  914. [SerializeField] [FieldOffset(2176)] internal FixedBytes16Align8 offset2176;
  915. /// <summary>
  916. /// For internal use only.
  917. /// </summary>
  918. [SerializeField] [FieldOffset(2192)] internal FixedBytes16Align8 offset2192;
  919. /// <summary>
  920. /// For internal use only.
  921. /// </summary>
  922. [SerializeField] [FieldOffset(2208)] internal FixedBytes16Align8 offset2208;
  923. /// <summary>
  924. /// For internal use only.
  925. /// </summary>
  926. [SerializeField] [FieldOffset(2224)] internal FixedBytes16Align8 offset2224;
  927. /// <summary>
  928. /// For internal use only.
  929. /// </summary>
  930. [SerializeField] [FieldOffset(2240)] internal FixedBytes16Align8 offset2240;
  931. /// <summary>
  932. /// For internal use only.
  933. /// </summary>
  934. [SerializeField] [FieldOffset(2256)] internal FixedBytes16Align8 offset2256;
  935. /// <summary>
  936. /// For internal use only.
  937. /// </summary>
  938. [SerializeField] [FieldOffset(2272)] internal FixedBytes16Align8 offset2272;
  939. /// <summary>
  940. /// For internal use only.
  941. /// </summary>
  942. [SerializeField] [FieldOffset(2288)] internal FixedBytes16Align8 offset2288;
  943. /// <summary>
  944. /// For internal use only.
  945. /// </summary>
  946. [SerializeField] [FieldOffset(2304)] internal FixedBytes16Align8 offset2304;
  947. /// <summary>
  948. /// For internal use only.
  949. /// </summary>
  950. [SerializeField] [FieldOffset(2320)] internal FixedBytes16Align8 offset2320;
  951. /// <summary>
  952. /// For internal use only.
  953. /// </summary>
  954. [SerializeField] [FieldOffset(2336)] internal FixedBytes16Align8 offset2336;
  955. /// <summary>
  956. /// For internal use only.
  957. /// </summary>
  958. [SerializeField] [FieldOffset(2352)] internal FixedBytes16Align8 offset2352;
  959. /// <summary>
  960. /// For internal use only.
  961. /// </summary>
  962. [SerializeField] [FieldOffset(2368)] internal FixedBytes16Align8 offset2368;
  963. /// <summary>
  964. /// For internal use only.
  965. /// </summary>
  966. [SerializeField] [FieldOffset(2384)] internal FixedBytes16Align8 offset2384;
  967. /// <summary>
  968. /// For internal use only.
  969. /// </summary>
  970. [SerializeField] [FieldOffset(2400)] internal FixedBytes16Align8 offset2400;
  971. /// <summary>
  972. /// For internal use only.
  973. /// </summary>
  974. [SerializeField] [FieldOffset(2416)] internal FixedBytes16Align8 offset2416;
  975. /// <summary>
  976. /// For internal use only.
  977. /// </summary>
  978. [SerializeField] [FieldOffset(2432)] internal FixedBytes16Align8 offset2432;
  979. /// <summary>
  980. /// For internal use only.
  981. /// </summary>
  982. [SerializeField] [FieldOffset(2448)] internal FixedBytes16Align8 offset2448;
  983. /// <summary>
  984. /// For internal use only.
  985. /// </summary>
  986. [SerializeField] [FieldOffset(2464)] internal FixedBytes16Align8 offset2464;
  987. /// <summary>
  988. /// For internal use only.
  989. /// </summary>
  990. [SerializeField] [FieldOffset(2480)] internal FixedBytes16Align8 offset2480;
  991. /// <summary>
  992. /// For internal use only.
  993. /// </summary>
  994. [SerializeField] [FieldOffset(2496)] internal FixedBytes16Align8 offset2496;
  995. /// <summary>
  996. /// For internal use only.
  997. /// </summary>
  998. [SerializeField] [FieldOffset(2512)] internal FixedBytes16Align8 offset2512;
  999. /// <summary>
  1000. /// For internal use only.
  1001. /// </summary>
  1002. [SerializeField] [FieldOffset(2528)] internal FixedBytes16Align8 offset2528;
  1003. /// <summary>
  1004. /// For internal use only.
  1005. /// </summary>
  1006. [SerializeField] [FieldOffset(2544)] internal FixedBytes16Align8 offset2544;
  1007. /// <summary>
  1008. /// For internal use only.
  1009. /// </summary>
  1010. [SerializeField] [FieldOffset(2560)] internal FixedBytes16Align8 offset2560;
  1011. /// <summary>
  1012. /// For internal use only.
  1013. /// </summary>
  1014. [SerializeField] [FieldOffset(2576)] internal FixedBytes16Align8 offset2576;
  1015. /// <summary>
  1016. /// For internal use only.
  1017. /// </summary>
  1018. [SerializeField] [FieldOffset(2592)] internal FixedBytes16Align8 offset2592;
  1019. /// <summary>
  1020. /// For internal use only.
  1021. /// </summary>
  1022. [SerializeField] [FieldOffset(2608)] internal FixedBytes16Align8 offset2608;
  1023. /// <summary>
  1024. /// For internal use only.
  1025. /// </summary>
  1026. [SerializeField] [FieldOffset(2624)] internal FixedBytes16Align8 offset2624;
  1027. /// <summary>
  1028. /// For internal use only.
  1029. /// </summary>
  1030. [SerializeField] [FieldOffset(2640)] internal FixedBytes16Align8 offset2640;
  1031. /// <summary>
  1032. /// For internal use only.
  1033. /// </summary>
  1034. [SerializeField] [FieldOffset(2656)] internal FixedBytes16Align8 offset2656;
  1035. /// <summary>
  1036. /// For internal use only.
  1037. /// </summary>
  1038. [SerializeField] [FieldOffset(2672)] internal FixedBytes16Align8 offset2672;
  1039. /// <summary>
  1040. /// For internal use only.
  1041. /// </summary>
  1042. [SerializeField] [FieldOffset(2688)] internal FixedBytes16Align8 offset2688;
  1043. /// <summary>
  1044. /// For internal use only.
  1045. /// </summary>
  1046. [SerializeField] [FieldOffset(2704)] internal FixedBytes16Align8 offset2704;
  1047. /// <summary>
  1048. /// For internal use only.
  1049. /// </summary>
  1050. [SerializeField] [FieldOffset(2720)] internal FixedBytes16Align8 offset2720;
  1051. /// <summary>
  1052. /// For internal use only.
  1053. /// </summary>
  1054. [SerializeField] [FieldOffset(2736)] internal FixedBytes16Align8 offset2736;
  1055. /// <summary>
  1056. /// For internal use only.
  1057. /// </summary>
  1058. [SerializeField] [FieldOffset(2752)] internal FixedBytes16Align8 offset2752;
  1059. /// <summary>
  1060. /// For internal use only.
  1061. /// </summary>
  1062. [SerializeField] [FieldOffset(2768)] internal FixedBytes16Align8 offset2768;
  1063. /// <summary>
  1064. /// For internal use only.
  1065. /// </summary>
  1066. [SerializeField] [FieldOffset(2784)] internal FixedBytes16Align8 offset2784;
  1067. /// <summary>
  1068. /// For internal use only.
  1069. /// </summary>
  1070. [SerializeField] [FieldOffset(2800)] internal FixedBytes16Align8 offset2800;
  1071. /// <summary>
  1072. /// For internal use only.
  1073. /// </summary>
  1074. [SerializeField] [FieldOffset(2816)] internal FixedBytes16Align8 offset2816;
  1075. /// <summary>
  1076. /// For internal use only.
  1077. /// </summary>
  1078. [SerializeField] [FieldOffset(2832)] internal FixedBytes16Align8 offset2832;
  1079. /// <summary>
  1080. /// For internal use only.
  1081. /// </summary>
  1082. [SerializeField] [FieldOffset(2848)] internal FixedBytes16Align8 offset2848;
  1083. /// <summary>
  1084. /// For internal use only.
  1085. /// </summary>
  1086. [SerializeField] [FieldOffset(2864)] internal FixedBytes16Align8 offset2864;
  1087. /// <summary>
  1088. /// For internal use only.
  1089. /// </summary>
  1090. [SerializeField] [FieldOffset(2880)] internal FixedBytes16Align8 offset2880;
  1091. /// <summary>
  1092. /// For internal use only.
  1093. /// </summary>
  1094. [SerializeField] [FieldOffset(2896)] internal FixedBytes16Align8 offset2896;
  1095. /// <summary>
  1096. /// For internal use only.
  1097. /// </summary>
  1098. [SerializeField] [FieldOffset(2912)] internal FixedBytes16Align8 offset2912;
  1099. /// <summary>
  1100. /// For internal use only.
  1101. /// </summary>
  1102. [SerializeField] [FieldOffset(2928)] internal FixedBytes16Align8 offset2928;
  1103. /// <summary>
  1104. /// For internal use only.
  1105. /// </summary>
  1106. [SerializeField] [FieldOffset(2944)] internal FixedBytes16Align8 offset2944;
  1107. /// <summary>
  1108. /// For internal use only.
  1109. /// </summary>
  1110. [SerializeField] [FieldOffset(2960)] internal FixedBytes16Align8 offset2960;
  1111. /// <summary>
  1112. /// For internal use only.
  1113. /// </summary>
  1114. [SerializeField] [FieldOffset(2976)] internal FixedBytes16Align8 offset2976;
  1115. /// <summary>
  1116. /// For internal use only.
  1117. /// </summary>
  1118. [SerializeField] [FieldOffset(2992)] internal FixedBytes16Align8 offset2992;
  1119. /// <summary>
  1120. /// For internal use only.
  1121. /// </summary>
  1122. [SerializeField] [FieldOffset(3008)] internal FixedBytes16Align8 offset3008;
  1123. /// <summary>
  1124. /// For internal use only.
  1125. /// </summary>
  1126. [SerializeField] [FieldOffset(3024)] internal FixedBytes16Align8 offset3024;
  1127. /// <summary>
  1128. /// For internal use only.
  1129. /// </summary>
  1130. [SerializeField] [FieldOffset(3040)] internal FixedBytes16Align8 offset3040;
  1131. /// <summary>
  1132. /// For internal use only.
  1133. /// </summary>
  1134. [SerializeField] [FieldOffset(3056)] internal FixedBytes16Align8 offset3056;
  1135. /// <summary>
  1136. /// For internal use only.
  1137. /// </summary>
  1138. [SerializeField] [FieldOffset(3072)] internal FixedBytes16Align8 offset3072;
  1139. /// <summary>
  1140. /// For internal use only.
  1141. /// </summary>
  1142. [SerializeField] [FieldOffset(3088)] internal FixedBytes16Align8 offset3088;
  1143. /// <summary>
  1144. /// For internal use only.
  1145. /// </summary>
  1146. [SerializeField] [FieldOffset(3104)] internal FixedBytes16Align8 offset3104;
  1147. /// <summary>
  1148. /// For internal use only.
  1149. /// </summary>
  1150. [SerializeField] [FieldOffset(3120)] internal FixedBytes16Align8 offset3120;
  1151. /// <summary>
  1152. /// For internal use only.
  1153. /// </summary>
  1154. [SerializeField] [FieldOffset(3136)] internal FixedBytes16Align8 offset3136;
  1155. /// <summary>
  1156. /// For internal use only.
  1157. /// </summary>
  1158. [SerializeField] [FieldOffset(3152)] internal FixedBytes16Align8 offset3152;
  1159. /// <summary>
  1160. /// For internal use only.
  1161. /// </summary>
  1162. [SerializeField] [FieldOffset(3168)] internal FixedBytes16Align8 offset3168;
  1163. /// <summary>
  1164. /// For internal use only.
  1165. /// </summary>
  1166. [SerializeField] [FieldOffset(3184)] internal FixedBytes16Align8 offset3184;
  1167. /// <summary>
  1168. /// For internal use only.
  1169. /// </summary>
  1170. [SerializeField] [FieldOffset(3200)] internal FixedBytes16Align8 offset3200;
  1171. /// <summary>
  1172. /// For internal use only.
  1173. /// </summary>
  1174. [SerializeField] [FieldOffset(3216)] internal FixedBytes16Align8 offset3216;
  1175. /// <summary>
  1176. /// For internal use only.
  1177. /// </summary>
  1178. [SerializeField] [FieldOffset(3232)] internal FixedBytes16Align8 offset3232;
  1179. /// <summary>
  1180. /// For internal use only.
  1181. /// </summary>
  1182. [SerializeField] [FieldOffset(3248)] internal FixedBytes16Align8 offset3248;
  1183. /// <summary>
  1184. /// For internal use only.
  1185. /// </summary>
  1186. [SerializeField] [FieldOffset(3264)] internal FixedBytes16Align8 offset3264;
  1187. /// <summary>
  1188. /// For internal use only.
  1189. /// </summary>
  1190. [SerializeField] [FieldOffset(3280)] internal FixedBytes16Align8 offset3280;
  1191. /// <summary>
  1192. /// For internal use only.
  1193. /// </summary>
  1194. [SerializeField] [FieldOffset(3296)] internal FixedBytes16Align8 offset3296;
  1195. /// <summary>
  1196. /// For internal use only.
  1197. /// </summary>
  1198. [SerializeField] [FieldOffset(3312)] internal FixedBytes16Align8 offset3312;
  1199. /// <summary>
  1200. /// For internal use only.
  1201. /// </summary>
  1202. [SerializeField] [FieldOffset(3328)] internal FixedBytes16Align8 offset3328;
  1203. /// <summary>
  1204. /// For internal use only.
  1205. /// </summary>
  1206. [SerializeField] [FieldOffset(3344)] internal FixedBytes16Align8 offset3344;
  1207. /// <summary>
  1208. /// For internal use only.
  1209. /// </summary>
  1210. [SerializeField] [FieldOffset(3360)] internal FixedBytes16Align8 offset3360;
  1211. /// <summary>
  1212. /// For internal use only.
  1213. /// </summary>
  1214. [SerializeField] [FieldOffset(3376)] internal FixedBytes16Align8 offset3376;
  1215. /// <summary>
  1216. /// For internal use only.
  1217. /// </summary>
  1218. [SerializeField] [FieldOffset(3392)] internal FixedBytes16Align8 offset3392;
  1219. /// <summary>
  1220. /// For internal use only.
  1221. /// </summary>
  1222. [SerializeField] [FieldOffset(3408)] internal FixedBytes16Align8 offset3408;
  1223. /// <summary>
  1224. /// For internal use only.
  1225. /// </summary>
  1226. [SerializeField] [FieldOffset(3424)] internal FixedBytes16Align8 offset3424;
  1227. /// <summary>
  1228. /// For internal use only.
  1229. /// </summary>
  1230. [SerializeField] [FieldOffset(3440)] internal FixedBytes16Align8 offset3440;
  1231. /// <summary>
  1232. /// For internal use only.
  1233. /// </summary>
  1234. [SerializeField] [FieldOffset(3456)] internal FixedBytes16Align8 offset3456;
  1235. /// <summary>
  1236. /// For internal use only.
  1237. /// </summary>
  1238. [SerializeField] [FieldOffset(3472)] internal FixedBytes16Align8 offset3472;
  1239. /// <summary>
  1240. /// For internal use only.
  1241. /// </summary>
  1242. [SerializeField] [FieldOffset(3488)] internal FixedBytes16Align8 offset3488;
  1243. /// <summary>
  1244. /// For internal use only.
  1245. /// </summary>
  1246. [SerializeField] [FieldOffset(3504)] internal FixedBytes16Align8 offset3504;
  1247. /// <summary>
  1248. /// For internal use only.
  1249. /// </summary>
  1250. [SerializeField] [FieldOffset(3520)] internal FixedBytes16Align8 offset3520;
  1251. /// <summary>
  1252. /// For internal use only.
  1253. /// </summary>
  1254. [SerializeField] [FieldOffset(3536)] internal FixedBytes16Align8 offset3536;
  1255. /// <summary>
  1256. /// For internal use only.
  1257. /// </summary>
  1258. [SerializeField] [FieldOffset(3552)] internal FixedBytes16Align8 offset3552;
  1259. /// <summary>
  1260. /// For internal use only.
  1261. /// </summary>
  1262. [SerializeField] [FieldOffset(3568)] internal FixedBytes16Align8 offset3568;
  1263. /// <summary>
  1264. /// For internal use only.
  1265. /// </summary>
  1266. [SerializeField] [FieldOffset(3584)] internal FixedBytes16Align8 offset3584;
  1267. /// <summary>
  1268. /// For internal use only.
  1269. /// </summary>
  1270. [SerializeField] [FieldOffset(3600)] internal FixedBytes16Align8 offset3600;
  1271. /// <summary>
  1272. /// For internal use only.
  1273. /// </summary>
  1274. [SerializeField] [FieldOffset(3616)] internal FixedBytes16Align8 offset3616;
  1275. /// <summary>
  1276. /// For internal use only.
  1277. /// </summary>
  1278. [SerializeField] [FieldOffset(3632)] internal FixedBytes16Align8 offset3632;
  1279. /// <summary>
  1280. /// For internal use only.
  1281. /// </summary>
  1282. [SerializeField] [FieldOffset(3648)] internal FixedBytes16Align8 offset3648;
  1283. /// <summary>
  1284. /// For internal use only.
  1285. /// </summary>
  1286. [SerializeField] [FieldOffset(3664)] internal FixedBytes16Align8 offset3664;
  1287. /// <summary>
  1288. /// For internal use only.
  1289. /// </summary>
  1290. [SerializeField] [FieldOffset(3680)] internal FixedBytes16Align8 offset3680;
  1291. /// <summary>
  1292. /// For internal use only.
  1293. /// </summary>
  1294. [SerializeField] [FieldOffset(3696)] internal FixedBytes16Align8 offset3696;
  1295. /// <summary>
  1296. /// For internal use only.
  1297. /// </summary>
  1298. [SerializeField] [FieldOffset(3712)] internal FixedBytes16Align8 offset3712;
  1299. /// <summary>
  1300. /// For internal use only.
  1301. /// </summary>
  1302. [SerializeField] [FieldOffset(3728)] internal FixedBytes16Align8 offset3728;
  1303. /// <summary>
  1304. /// For internal use only.
  1305. /// </summary>
  1306. [SerializeField] [FieldOffset(3744)] internal FixedBytes16Align8 offset3744;
  1307. /// <summary>
  1308. /// For internal use only.
  1309. /// </summary>
  1310. [SerializeField] [FieldOffset(3760)] internal FixedBytes16Align8 offset3760;
  1311. /// <summary>
  1312. /// For internal use only.
  1313. /// </summary>
  1314. [SerializeField] [FieldOffset(3776)] internal FixedBytes16Align8 offset3776;
  1315. /// <summary>
  1316. /// For internal use only.
  1317. /// </summary>
  1318. [SerializeField] [FieldOffset(3792)] internal FixedBytes16Align8 offset3792;
  1319. /// <summary>
  1320. /// For internal use only.
  1321. /// </summary>
  1322. [SerializeField] [FieldOffset(3808)] internal FixedBytes16Align8 offset3808;
  1323. /// <summary>
  1324. /// For internal use only.
  1325. /// </summary>
  1326. [SerializeField] [FieldOffset(3824)] internal FixedBytes16Align8 offset3824;
  1327. /// <summary>
  1328. /// For internal use only.
  1329. /// </summary>
  1330. [SerializeField] [FieldOffset(3840)] internal FixedBytes16Align8 offset3840;
  1331. /// <summary>
  1332. /// For internal use only.
  1333. /// </summary>
  1334. [SerializeField] [FieldOffset(3856)] internal FixedBytes16Align8 offset3856;
  1335. /// <summary>
  1336. /// For internal use only.
  1337. /// </summary>
  1338. [SerializeField] [FieldOffset(3872)] internal FixedBytes16Align8 offset3872;
  1339. /// <summary>
  1340. /// For internal use only.
  1341. /// </summary>
  1342. [SerializeField] [FieldOffset(3888)] internal FixedBytes16Align8 offset3888;
  1343. /// <summary>
  1344. /// For internal use only.
  1345. /// </summary>
  1346. [SerializeField] [FieldOffset(3904)] internal FixedBytes16Align8 offset3904;
  1347. /// <summary>
  1348. /// For internal use only.
  1349. /// </summary>
  1350. [SerializeField] [FieldOffset(3920)] internal FixedBytes16Align8 offset3920;
  1351. /// <summary>
  1352. /// For internal use only.
  1353. /// </summary>
  1354. [SerializeField] [FieldOffset(3936)] internal FixedBytes16Align8 offset3936;
  1355. /// <summary>
  1356. /// For internal use only.
  1357. /// </summary>
  1358. [SerializeField] [FieldOffset(3952)] internal FixedBytes16Align8 offset3952;
  1359. /// <summary>
  1360. /// For internal use only.
  1361. /// </summary>
  1362. [SerializeField] [FieldOffset(3968)] internal FixedBytes16Align8 offset3968;
  1363. /// <summary>
  1364. /// For internal use only.
  1365. /// </summary>
  1366. [SerializeField] [FieldOffset(3984)] internal FixedBytes16Align8 offset3984;
  1367. /// <summary>
  1368. /// For internal use only.
  1369. /// </summary>
  1370. [SerializeField] [FieldOffset(4000)] internal FixedBytes16Align8 offset4000;
  1371. /// <summary>
  1372. /// For internal use only.
  1373. /// </summary>
  1374. [SerializeField] [FieldOffset(4016)] internal FixedBytes16Align8 offset4016;
  1375. /// <summary>
  1376. /// For internal use only.
  1377. /// </summary>
  1378. [SerializeField] [FieldOffset(4032)] internal FixedBytes16Align8 offset4032;
  1379. /// <summary>
  1380. /// For internal use only.
  1381. /// </summary>
  1382. [SerializeField] [FieldOffset(4048)] internal FixedBytes16Align8 offset4048;
  1383. /// <summary>
  1384. /// For internal use only.
  1385. /// </summary>
  1386. [SerializeField] [FieldOffset(4064)] internal FixedBytes16Align8 offset4064;
  1387. /// <summary>
  1388. /// For internal use only.
  1389. /// </summary>
  1390. [SerializeField] [FieldOffset(4080)] internal FixedBytes16Align8 offset4080;
  1391. }
  1392. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  1393. // However, only the first element of data members with names is copied at this time.
  1394. // Therefore, it's important that all data visible in the debugger, has a name
  1395. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  1396. /// <summary>
  1397. /// For internal use only.
  1398. /// </summary>
  1399. [Serializable]
  1400. [StructLayout(LayoutKind.Explicit, Size=30)]
  1401. [GenerateTestsForBurstCompatibility]
  1402. public struct FixedBytes30
  1403. {
  1404. /// <summary>
  1405. /// For internal use only.
  1406. /// </summary>
  1407. [FieldOffset(0)] public FixedBytes16 offset0000;
  1408. /// <summary>
  1409. /// For internal use only.
  1410. /// </summary>
  1411. [FieldOffset(16)] public byte byte0016;
  1412. /// <summary>
  1413. /// For internal use only.
  1414. /// </summary>
  1415. [FieldOffset(17)] public byte byte0017;
  1416. /// <summary>
  1417. /// For internal use only.
  1418. /// </summary>
  1419. [FieldOffset(18)] public byte byte0018;
  1420. /// <summary>
  1421. /// For internal use only.
  1422. /// </summary>
  1423. [FieldOffset(19)] public byte byte0019;
  1424. /// <summary>
  1425. /// For internal use only.
  1426. /// </summary>
  1427. [FieldOffset(20)] public byte byte0020;
  1428. /// <summary>
  1429. /// For internal use only.
  1430. /// </summary>
  1431. [FieldOffset(21)] public byte byte0021;
  1432. /// <summary>
  1433. /// For internal use only.
  1434. /// </summary>
  1435. [FieldOffset(22)] public byte byte0022;
  1436. /// <summary>
  1437. /// For internal use only.
  1438. /// </summary>
  1439. [FieldOffset(23)] public byte byte0023;
  1440. /// <summary>
  1441. /// For internal use only.
  1442. /// </summary>
  1443. [FieldOffset(24)] public byte byte0024;
  1444. /// <summary>
  1445. /// For internal use only.
  1446. /// </summary>
  1447. [FieldOffset(25)] public byte byte0025;
  1448. /// <summary>
  1449. /// For internal use only.
  1450. /// </summary>
  1451. [FieldOffset(26)] public byte byte0026;
  1452. /// <summary>
  1453. /// For internal use only.
  1454. /// </summary>
  1455. [FieldOffset(27)] public byte byte0027;
  1456. /// <summary>
  1457. /// For internal use only.
  1458. /// </summary>
  1459. [FieldOffset(28)] public byte byte0028;
  1460. /// <summary>
  1461. /// For internal use only.
  1462. /// </summary>
  1463. [FieldOffset(29)] public byte byte0029;
  1464. }
  1465. /// <summary>
  1466. /// An unmanaged UTF-8 string whose content is stored directly in the 32-byte struct.
  1467. /// </summary>
  1468. /// <remarks>
  1469. /// The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer)
  1470. /// followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character.
  1471. /// Effectively, the number of bytes for storing characters is 3 less than 32 (two length bytes and one null byte).
  1472. ///
  1473. /// This layout is identical to a <see cref="FixedList32Bytes{T}"/> of bytes, thus allowing reinterpretation between FixedString32Bytes and FixedList32Bytes.
  1474. ///
  1475. /// By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation.
  1476. /// Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.
  1477. /// </remarks>
  1478. [Serializable]
  1479. [StructLayout(LayoutKind.Sequential, Size=32)]
  1480. [GenerateTestsForBurstCompatibility]
  1481. public partial struct FixedString32Bytes
  1482. : INativeList<byte>
  1483. , IUTF8Bytes
  1484. , IComparable<String>
  1485. , IEquatable<String>
  1486. , IComparable<FixedString32Bytes>
  1487. , IEquatable<FixedString32Bytes>
  1488. , IComparable<FixedString64Bytes>
  1489. , IEquatable<FixedString64Bytes>
  1490. , IComparable<FixedString128Bytes>
  1491. , IEquatable<FixedString128Bytes>
  1492. , IComparable<FixedString512Bytes>
  1493. , IEquatable<FixedString512Bytes>
  1494. , IComparable<FixedString4096Bytes>
  1495. , IEquatable<FixedString4096Bytes>
  1496. {
  1497. internal const ushort utf8MaxLengthInBytes = 29;
  1498. [SerializeField] internal ushort utf8LengthInBytes;
  1499. [SerializeField] internal FixedBytes30 bytes;
  1500. /// <summary>
  1501. /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
  1502. /// </summary>
  1503. /// <returns>
  1504. /// The maximum number of UTF-8 bytes that can be stored in this string.
  1505. /// </returns>
  1506. public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
  1507. /// <summary>
  1508. /// For internal use only. Use <see cref="ToString"/> instead.
  1509. /// </summary>
  1510. /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
  1511. [CreateProperty]
  1512. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  1513. [ExcludeFromBurstCompatTesting("Returns managed string")]
  1514. public string Value => ToString();
  1515. /// <summary>
  1516. /// Returns a pointer to the character bytes.
  1517. /// </summary>
  1518. /// <remarks>
  1519. /// The pointer returned by this method points into the internals of the target FixedString object. It is the
  1520. /// caller's responsibility to ensure that the pointer is not used after the FixedString object is destroyed or goes
  1521. /// out of scope.
  1522. /// </remarks>
  1523. /// <returns>A pointer to the character bytes.</returns>
  1524. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1525. public readonly unsafe byte* GetUnsafePtr()
  1526. {
  1527. fixed(void* b = &bytes)
  1528. return (byte*)b;
  1529. }
  1530. /// <summary>
  1531. /// The current length in bytes of this string's content.
  1532. /// </summary>
  1533. /// <remarks>
  1534. /// The length value does not include the null-terminator byte.
  1535. /// </remarks>
  1536. /// <param name="value">The new length in bytes of the string's content.</param>
  1537. /// <exception cref="ArgumentOutOfRangeException">Thrown if the new length is out of bounds.</exception>
  1538. /// <value>
  1539. /// The current length in bytes of this string's content.
  1540. /// </value>
  1541. public int Length
  1542. {
  1543. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1544. readonly get
  1545. {
  1546. return utf8LengthInBytes;
  1547. }
  1548. set
  1549. {
  1550. CheckLengthInRange(value);
  1551. utf8LengthInBytes = (ushort)value;
  1552. unsafe
  1553. {
  1554. GetUnsafePtr()[utf8LengthInBytes] = 0;
  1555. }
  1556. }
  1557. }
  1558. /// <summary>
  1559. /// The number of bytes this string has for storing UTF-8 characters.
  1560. /// </summary>
  1561. /// <value>The number of bytes this string has for storing UTF-8 characters.</value>
  1562. /// <remarks>
  1563. /// Does not include the null-terminator byte.
  1564. ///
  1565. /// A setter is included for conformity with <see cref="INativeList{T}"/>, but <see cref="Capacity"/> is fixed at 29.
  1566. /// Setting the value to anything other than 29 throws an exception.
  1567. ///
  1568. /// In UTF-8 encoding, each Unicode code point (character) requires 1 to 4 bytes,
  1569. /// so the number of characters that can be stored may be less than the capacity.
  1570. /// </remarks>
  1571. /// <exception cref="ArgumentOutOfRangeException">Thrown if attempting to set the capacity to anything other than 29.</exception>
  1572. public int Capacity
  1573. {
  1574. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1575. readonly get
  1576. {
  1577. return utf8MaxLengthInBytes;
  1578. }
  1579. set
  1580. {
  1581. CheckCapacityInRange(value);
  1582. }
  1583. }
  1584. /// <summary>
  1585. /// Attempts to set the length in bytes. Does nothing if the new length is invalid.
  1586. /// </summary>
  1587. /// <param name="newLength">The desired length.</param>
  1588. /// <param name="clearOptions">Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)</param>
  1589. /// <returns>True if the new length is valid.</returns>
  1590. public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
  1591. {
  1592. if (newLength < 0 || newLength > utf8MaxLengthInBytes)
  1593. return false;
  1594. if (newLength == utf8LengthInBytes)
  1595. return true;
  1596. unsafe
  1597. {
  1598. if (clearOptions == NativeArrayOptions.ClearMemory)
  1599. {
  1600. if (newLength > utf8LengthInBytes)
  1601. UnsafeUtility.MemClear(GetUnsafePtr() + utf8LengthInBytes, newLength - utf8LengthInBytes);
  1602. else
  1603. UnsafeUtility.MemClear(GetUnsafePtr() + newLength, utf8LengthInBytes - newLength);
  1604. }
  1605. utf8LengthInBytes = (ushort)newLength;
  1606. // always null terminate
  1607. GetUnsafePtr()[utf8LengthInBytes] = 0;
  1608. }
  1609. return true;
  1610. }
  1611. /// <summary>
  1612. /// Returns true if this string is empty (has no characters).
  1613. /// </summary>
  1614. /// <value>True if this string is empty (has no characters).</value>
  1615. public readonly bool IsEmpty
  1616. {
  1617. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1618. get => utf8LengthInBytes == 0;
  1619. }
  1620. /// <summary>
  1621. /// Returns the byte (not character) at an index.
  1622. /// </summary>
  1623. /// <param name="index">A byte index.</param>
  1624. /// <value>The byte at the index.</value>
  1625. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  1626. public byte this[int index]
  1627. {
  1628. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1629. readonly get
  1630. {
  1631. unsafe
  1632. {
  1633. CheckIndexInRange(index);
  1634. return GetUnsafePtr()[index];
  1635. }
  1636. }
  1637. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1638. set
  1639. {
  1640. unsafe
  1641. {
  1642. CheckIndexInRange(index);
  1643. GetUnsafePtr()[index] = value;
  1644. }
  1645. }
  1646. }
  1647. /// <summary>
  1648. /// Returns the reference to a byte (not character) at an index.
  1649. /// </summary>
  1650. /// <param name="index">A byte index.</param>
  1651. /// <returns>A reference to the byte at the index.</returns>
  1652. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  1653. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1654. public ref byte ElementAt(int index)
  1655. {
  1656. unsafe
  1657. {
  1658. CheckIndexInRange(index);
  1659. return ref GetUnsafePtr()[index];
  1660. }
  1661. }
  1662. /// <summary>
  1663. /// Sets the length to 0.
  1664. /// </summary>
  1665. public void Clear()
  1666. {
  1667. Length = 0;
  1668. }
  1669. /// <summary>
  1670. /// Appends a byte.
  1671. /// </summary>
  1672. /// <remarks>
  1673. /// A zero byte will always follow the newly appended byte.
  1674. ///
  1675. /// No validation is performed: it is your responsibility for the bytes of the string to form valid UTF-8 when you're done appending bytes.
  1676. /// </remarks>
  1677. /// <param name="value">A byte to append.</param>
  1678. public void Add(in byte value)
  1679. {
  1680. this[Length++] = value;
  1681. }
  1682. /// <summary>
  1683. /// An enumerator over the characters (not bytes) of a FixedString32Bytes.
  1684. /// </summary>
  1685. /// <remarks>
  1686. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  1687. /// The first <see cref="MoveNext"/> call advances the enumerator's index to the first character.
  1688. /// </remarks>
  1689. public struct Enumerator : IEnumerator
  1690. {
  1691. FixedString32Bytes target;
  1692. int offset;
  1693. Unicode.Rune current;
  1694. /// <summary>
  1695. /// Initializes and returns an instance of FixedString32Bytes.Enumerator.
  1696. /// </summary>
  1697. /// <param name="other">A FixeString32 for which to create an enumerator.</param>
  1698. public Enumerator(FixedString32Bytes other)
  1699. {
  1700. target = other;
  1701. offset = 0;
  1702. current = default;
  1703. }
  1704. /// <summary>
  1705. /// Does nothing.
  1706. /// </summary>
  1707. public void Dispose()
  1708. {
  1709. }
  1710. /// <summary>
  1711. /// Advances the enumerator to the next character.
  1712. /// </summary>
  1713. /// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
  1714. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1715. public bool MoveNext()
  1716. {
  1717. if (offset >= target.Length)
  1718. return false;
  1719. unsafe
  1720. {
  1721. Unicode.Utf8ToUcs(out current, target.GetUnsafePtr(), ref offset, target.Length);
  1722. }
  1723. return true;
  1724. }
  1725. /// <summary>
  1726. /// Resets the enumerator to its initial state.
  1727. /// </summary>
  1728. public void Reset()
  1729. {
  1730. offset = 0;
  1731. current = default;
  1732. }
  1733. /// <summary>
  1734. /// The current character.
  1735. /// </summary>
  1736. /// <remarks>
  1737. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  1738. /// </remarks>
  1739. /// <value>The current character.</value>
  1740. public Unicode.Rune Current
  1741. {
  1742. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1743. get => current;
  1744. }
  1745. object IEnumerator.Current => Current;
  1746. }
  1747. /// <summary>
  1748. /// Returns an enumerator for iterating over the characters of this string.
  1749. /// </summary>
  1750. /// <returns>An enumerator for iterating over the characters of the FixedString32Bytes.</returns>
  1751. public Enumerator GetEnumerator()
  1752. {
  1753. return new Enumerator(this);
  1754. }
  1755. /// <summary>
  1756. /// Returns the lexicographical sort order of this string relative to another.
  1757. /// </summary>
  1758. /// <param name="other">A `System.String` to compare with.</param>
  1759. /// <returns>An integer denoting the lexicographical sort order of this string relative to the other:
  1760. ///
  1761. /// 0 denotes both strings have the same sort position.<br/>
  1762. /// -1 denotes that this string should be sorted to precede the other string.<br/>
  1763. /// +1 denotes that this string should be sorted to follow the other string.<br/>
  1764. /// </returns>
  1765. [ExcludeFromBurstCompatTesting("Takes managed string")]
  1766. public int CompareTo(String other)
  1767. {
  1768. return ToString().CompareTo(other);
  1769. }
  1770. /// <summary>
  1771. /// Returns true if this string and another have the same length and all the same characters.
  1772. /// </summary>
  1773. /// <param name="other">A string to compare for equality.</param>
  1774. /// <returns>True if this string and the other have the same length and all the same characters.</returns>
  1775. [ExcludeFromBurstCompatTesting("Takes managed string")]
  1776. public bool Equals(String other)
  1777. {
  1778. unsafe {
  1779. int alen = utf8LengthInBytes;
  1780. int blen = other.Length;
  1781. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(bytes);
  1782. fixed(char* bptr = other)
  1783. {
  1784. return UTF8ArrayUnsafeUtility.StrCmp(aptr, alen, bptr, blen) == 0;
  1785. }
  1786. }
  1787. }
  1788. /// <summary>
  1789. /// Returns a reference to a FixedList32Bytes&lt;byte&gt; representation of this string.
  1790. /// </summary>
  1791. /// <remarks>
  1792. /// The referenced FixedListByte32 is the very same bytes as the original FixedString32Bytes,
  1793. /// so it is only valid as long as the original FixedString32Bytes is valid.
  1794. /// </remarks>
  1795. /// <returns>A ref to a FixedListByte32 representation of the FixedString32Bytes.</returns>
  1796. public unsafe ref FixedList32Bytes<byte> AsFixedList()
  1797. {
  1798. return ref UnsafeUtility.AsRef<FixedList32Bytes<byte>>(UnsafeUtility.AddressOf(ref this));
  1799. }
  1800. /// <summary>
  1801. /// Initializes and returns an instance of FixedString32Bytes with the characters copied from a string.
  1802. /// </summary>
  1803. /// <param name="source">The source string to copy.</param>
  1804. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  1805. [ExcludeFromBurstCompatTesting("Takes managed string")]
  1806. public FixedString32Bytes(String source)
  1807. {
  1808. this = default;
  1809. var error = Initialize(source);
  1810. CheckCopyError(error, source);
  1811. }
  1812. /// <summary>
  1813. /// Initializes an instance of FixedString32Bytes with the characters copied from a string.
  1814. /// </summary>
  1815. /// <param name="source">The source string to copy.</param>
  1816. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, only the portion that fits is copied in and CopyError.Truncation is returned.</returns>
  1817. [ExcludeFromBurstCompatTesting("Takes managed string")]
  1818. internal CopyError Initialize(String source)
  1819. {
  1820. return this.CopyFromTruncated(source);
  1821. }
  1822. /// <summary>
  1823. /// Initializes and returns an instance of FixedString32Bytes with a single character repeatedly appended some number of times.
  1824. /// </summary>
  1825. /// <param name="rune">The Unicode.Rune to repeat.</param>
  1826. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  1827. public FixedString32Bytes(Unicode.Rune rune, int count = 1)
  1828. {
  1829. this = default;
  1830. Initialize(rune, count);
  1831. }
  1832. /// <summary>
  1833. /// Initializes an instance of FixedString32Bytes with a single character repeatedly appended some number of times.
  1834. /// </summary>
  1835. /// <param name="rune">The Unicode.Rune to repeat.</param>
  1836. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  1837. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  1838. internal FormatError Initialize(Unicode.Rune rune, int count = 1)
  1839. {
  1840. this = default;
  1841. return this.Append(rune, count);
  1842. }
  1843. /// <summary>
  1844. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  1845. /// </summary>
  1846. /// <param name="srcBytes">The source buffer.</param>
  1847. /// <param name="srcLength">The number of bytes to read from the source.</param>
  1848. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  1849. unsafe internal FormatError Initialize(byte* srcBytes, int srcLength)
  1850. {
  1851. bytes = default;
  1852. utf8LengthInBytes = 0;
  1853. unsafe {
  1854. int len = 0;
  1855. byte* dstBytes = GetUnsafePtr();
  1856. var error = UTF8ArrayUnsafeUtility.AppendUTF8Bytes(dstBytes, ref len, utf8MaxLengthInBytes, srcBytes, srcLength);
  1857. if(error != FormatError.None)
  1858. return error;
  1859. this.Length = len;
  1860. }
  1861. return FormatError.None;
  1862. }
  1863. /// <summary>
  1864. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  1865. /// </summary>
  1866. /// <param name="other">The string to copy.</param>
  1867. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  1868. unsafe public FixedString32Bytes(NativeText.ReadOnly other)
  1869. {
  1870. this = default;
  1871. var error = Initialize(other.GetUnsafePtr(), other.Length);
  1872. CheckFormatError(error);
  1873. }
  1874. /// <summary>
  1875. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  1876. /// </summary>
  1877. /// <param name="other">The UnsafeText to copy.</param>
  1878. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  1879. unsafe public FixedString32Bytes(in UnsafeText other)
  1880. {
  1881. this = default;
  1882. var error = Initialize(other.GetUnsafePtr(), other.Length);
  1883. CheckFormatError(error);
  1884. }
  1885. /// <summary>
  1886. /// Returns the lexicographical sort order of this string relative to another.
  1887. /// </summary>
  1888. /// <param name="other">A string to compare with.</param>
  1889. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  1890. ///
  1891. /// 0 denotes that both strings have the same sort position.<br/>
  1892. /// -1 denotes that this string should be sorted to precede the other.<br/>
  1893. /// +1 denotes that this string should be sorted to follow the other.<br/>
  1894. /// </returns>
  1895. public int CompareTo(FixedString32Bytes other)
  1896. {
  1897. return FixedStringMethods.CompareTo(ref this, other);
  1898. }
  1899. /// <summary>
  1900. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  1901. /// </summary>
  1902. /// <param name="other">The string to copy.</param>
  1903. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  1904. public FixedString32Bytes(in FixedString32Bytes other)
  1905. {
  1906. this = default;
  1907. var error = Initialize(other);
  1908. CheckFormatError(error);
  1909. }
  1910. /// <summary>
  1911. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  1912. /// </summary>
  1913. /// <param name="other">The string to copy.</param>
  1914. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  1915. unsafe internal FormatError Initialize(in FixedString32Bytes other)
  1916. {
  1917. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  1918. }
  1919. /// <summary>
  1920. /// Returns true if a FixedString32Bytes and another string are equal.
  1921. /// </summary>
  1922. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  1923. /// <param name="a">A FixedString32Bytes to compare for equality.</param>
  1924. /// <param name="b">A FixedString32Bytes to compare for equality.</param>
  1925. /// <returns>True if the two strings are equal.</returns>
  1926. public static bool operator ==(in FixedString32Bytes a, in FixedString32Bytes b)
  1927. {
  1928. // this must not call any methods on 'a' or 'b'
  1929. unsafe {
  1930. int alen = a.utf8LengthInBytes;
  1931. int blen = b.utf8LengthInBytes;
  1932. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  1933. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  1934. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  1935. }
  1936. }
  1937. /// <summary>
  1938. /// Returns true if a FixedString32Bytes and another string are unequal.
  1939. /// </summary>
  1940. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  1941. /// <param name="a">A FixedString32Bytes to compare for inequality.</param>
  1942. /// <param name="b">A FixedString32Bytes to compare for inequality.</param>
  1943. /// <returns>True if the two strings are unequal.</returns>
  1944. public static bool operator !=(in FixedString32Bytes a, in FixedString32Bytes b)
  1945. {
  1946. return !(a == b);
  1947. }
  1948. /// <summary>
  1949. /// Returns true if this string and another string are equal.
  1950. /// </summary>
  1951. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  1952. /// <param name="other">A FixedString32Bytes to compare for equality.</param>
  1953. /// <returns>True if the two strings are equal.</returns>
  1954. public bool Equals(FixedString32Bytes other)
  1955. {
  1956. return this == other;
  1957. }
  1958. /// <summary>
  1959. /// Returns the lexicographical sort order of this string relative to another.
  1960. /// </summary>
  1961. /// <param name="other">A string to compare with.</param>
  1962. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  1963. ///
  1964. /// 0 denotes that both strings have the same sort position.<br/>
  1965. /// -1 denotes that this string should be sorted to precede the other.<br/>
  1966. /// +1 denotes that this string should be sorted to follow the other.<br/>
  1967. /// </returns>
  1968. public int CompareTo(FixedString64Bytes other)
  1969. {
  1970. return FixedStringMethods.CompareTo(ref this, other);
  1971. }
  1972. /// <summary>
  1973. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  1974. /// </summary>
  1975. /// <param name="other">The string to copy.</param>
  1976. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  1977. public FixedString32Bytes(in FixedString64Bytes other)
  1978. {
  1979. this = default;
  1980. var error = Initialize(other);
  1981. CheckFormatError(error);
  1982. }
  1983. /// <summary>
  1984. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  1985. /// </summary>
  1986. /// <param name="other">The string to copy.</param>
  1987. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  1988. unsafe internal FormatError Initialize(in FixedString64Bytes other)
  1989. {
  1990. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  1991. }
  1992. /// <summary>
  1993. /// Returns true if a FixedString32Bytes and another string are equal.
  1994. /// </summary>
  1995. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  1996. /// <param name="a">A FixedString32Bytes to compare for equality.</param>
  1997. /// <param name="b">A FixedString64Bytes to compare for equality.</param>
  1998. /// <returns>True if the two strings are equal.</returns>
  1999. public static bool operator ==(in FixedString32Bytes a, in FixedString64Bytes b)
  2000. {
  2001. // this must not call any methods on 'a' or 'b'
  2002. unsafe {
  2003. int alen = a.utf8LengthInBytes;
  2004. int blen = b.utf8LengthInBytes;
  2005. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2006. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2007. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2008. }
  2009. }
  2010. /// <summary>
  2011. /// Returns true if a FixedString32Bytes and another string are unequal.
  2012. /// </summary>
  2013. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2014. /// <param name="a">A FixedString32Bytes to compare for inequality.</param>
  2015. /// <param name="b">A FixedString64Bytes to compare for inequality.</param>
  2016. /// <returns>True if the two strings are unequal.</returns>
  2017. public static bool operator !=(in FixedString32Bytes a, in FixedString64Bytes b)
  2018. {
  2019. return !(a == b);
  2020. }
  2021. /// <summary>
  2022. /// Returns true if this string and another string are equal.
  2023. /// </summary>
  2024. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2025. /// <param name="other">A FixedString64Bytes to compare for equality.</param>
  2026. /// <returns>True if the two strings are equal.</returns>
  2027. public bool Equals(FixedString64Bytes other)
  2028. {
  2029. return this == other;
  2030. }
  2031. /// <summary>
  2032. /// Returns a new FixedString64Bytes that is a copy of another string.
  2033. /// </summary>
  2034. /// <param name="fs">A FixedString32Bytes to copy.</param>
  2035. /// <returns>A new FixedString64Bytes that is a copy of the other string.</returns>
  2036. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2037. public static implicit operator FixedString64Bytes(in FixedString32Bytes fs) => new FixedString64Bytes(in fs);
  2038. /// <summary>
  2039. /// Returns the lexicographical sort order of this string relative to another.
  2040. /// </summary>
  2041. /// <param name="other">A string to compare with.</param>
  2042. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  2043. ///
  2044. /// 0 denotes that both strings have the same sort position.<br/>
  2045. /// -1 denotes that this string should be sorted to precede the other.<br/>
  2046. /// +1 denotes that this string should be sorted to follow the other.<br/>
  2047. /// </returns>
  2048. public int CompareTo(FixedString128Bytes other)
  2049. {
  2050. return FixedStringMethods.CompareTo(ref this, other);
  2051. }
  2052. /// <summary>
  2053. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  2054. /// </summary>
  2055. /// <param name="other">The string to copy.</param>
  2056. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  2057. public FixedString32Bytes(in FixedString128Bytes other)
  2058. {
  2059. this = default;
  2060. var error = Initialize(other);
  2061. CheckFormatError(error);
  2062. }
  2063. /// <summary>
  2064. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  2065. /// </summary>
  2066. /// <param name="other">The string to copy.</param>
  2067. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2068. unsafe internal FormatError Initialize(in FixedString128Bytes other)
  2069. {
  2070. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  2071. }
  2072. /// <summary>
  2073. /// Returns true if a FixedString32Bytes and another string are equal.
  2074. /// </summary>
  2075. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2076. /// <param name="a">A FixedString32Bytes to compare for equality.</param>
  2077. /// <param name="b">A FixedString128Bytes to compare for equality.</param>
  2078. /// <returns>True if the two strings are equal.</returns>
  2079. public static bool operator ==(in FixedString32Bytes a, in FixedString128Bytes b)
  2080. {
  2081. // this must not call any methods on 'a' or 'b'
  2082. unsafe {
  2083. int alen = a.utf8LengthInBytes;
  2084. int blen = b.utf8LengthInBytes;
  2085. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2086. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2087. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2088. }
  2089. }
  2090. /// <summary>
  2091. /// Returns true if a FixedString32Bytes and another string are unequal.
  2092. /// </summary>
  2093. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2094. /// <param name="a">A FixedString32Bytes to compare for inequality.</param>
  2095. /// <param name="b">A FixedString128Bytes to compare for inequality.</param>
  2096. /// <returns>True if the two strings are unequal.</returns>
  2097. public static bool operator !=(in FixedString32Bytes a, in FixedString128Bytes b)
  2098. {
  2099. return !(a == b);
  2100. }
  2101. /// <summary>
  2102. /// Returns true if this string and another string are equal.
  2103. /// </summary>
  2104. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2105. /// <param name="other">A FixedString128Bytes to compare for equality.</param>
  2106. /// <returns>True if the two strings are equal.</returns>
  2107. public bool Equals(FixedString128Bytes other)
  2108. {
  2109. return this == other;
  2110. }
  2111. /// <summary>
  2112. /// Returns a new FixedString128Bytes that is a copy of another string.
  2113. /// </summary>
  2114. /// <param name="fs">A FixedString32Bytes to copy.</param>
  2115. /// <returns>A new FixedString128Bytes that is a copy of the other string.</returns>
  2116. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  2117. public static implicit operator FixedString128Bytes(in FixedString32Bytes fs) => new FixedString128Bytes(in fs);
  2118. /// <summary>
  2119. /// Returns the lexicographical sort order of this string relative to another.
  2120. /// </summary>
  2121. /// <param name="other">A string to compare with.</param>
  2122. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  2123. ///
  2124. /// 0 denotes that both strings have the same sort position.<br/>
  2125. /// -1 denotes that this string should be sorted to precede the other.<br/>
  2126. /// +1 denotes that this string should be sorted to follow the other.<br/>
  2127. /// </returns>
  2128. public int CompareTo(FixedString512Bytes other)
  2129. {
  2130. return FixedStringMethods.CompareTo(ref this, other);
  2131. }
  2132. /// <summary>
  2133. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  2134. /// </summary>
  2135. /// <param name="other">The string to copy.</param>
  2136. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  2137. public FixedString32Bytes(in FixedString512Bytes other)
  2138. {
  2139. this = default;
  2140. var error = Initialize(other);
  2141. CheckFormatError(error);
  2142. }
  2143. /// <summary>
  2144. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  2145. /// </summary>
  2146. /// <param name="other">The string to copy.</param>
  2147. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2148. unsafe internal FormatError Initialize(in FixedString512Bytes other)
  2149. {
  2150. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  2151. }
  2152. /// <summary>
  2153. /// Returns true if a FixedString32Bytes and another string are equal.
  2154. /// </summary>
  2155. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2156. /// <param name="a">A FixedString32Bytes to compare for equality.</param>
  2157. /// <param name="b">A FixedString512Bytes to compare for equality.</param>
  2158. /// <returns>True if the two strings are equal.</returns>
  2159. public static bool operator ==(in FixedString32Bytes a, in FixedString512Bytes b)
  2160. {
  2161. // this must not call any methods on 'a' or 'b'
  2162. unsafe {
  2163. int alen = a.utf8LengthInBytes;
  2164. int blen = b.utf8LengthInBytes;
  2165. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2166. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2167. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2168. }
  2169. }
  2170. /// <summary>
  2171. /// Returns true if a FixedString32Bytes and another string are unequal.
  2172. /// </summary>
  2173. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2174. /// <param name="a">A FixedString32Bytes to compare for inequality.</param>
  2175. /// <param name="b">A FixedString512Bytes to compare for inequality.</param>
  2176. /// <returns>True if the two strings are unequal.</returns>
  2177. public static bool operator !=(in FixedString32Bytes a, in FixedString512Bytes b)
  2178. {
  2179. return !(a == b);
  2180. }
  2181. /// <summary>
  2182. /// Returns true if this string and another string are equal.
  2183. /// </summary>
  2184. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2185. /// <param name="other">A FixedString512Bytes to compare for equality.</param>
  2186. /// <returns>True if the two strings are equal.</returns>
  2187. public bool Equals(FixedString512Bytes other)
  2188. {
  2189. return this == other;
  2190. }
  2191. /// <summary>
  2192. /// Returns a new FixedString512Bytes that is a copy of another string.
  2193. /// </summary>
  2194. /// <param name="fs">A FixedString32Bytes to copy.</param>
  2195. /// <returns>A new FixedString512Bytes that is a copy of the other string.</returns>
  2196. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  2197. public static implicit operator FixedString512Bytes(in FixedString32Bytes fs) => new FixedString512Bytes(in fs);
  2198. /// <summary>
  2199. /// Returns the lexicographical sort order of this string relative to another.
  2200. /// </summary>
  2201. /// <param name="other">A string to compare with.</param>
  2202. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  2203. ///
  2204. /// 0 denotes that both strings have the same sort position.<br/>
  2205. /// -1 denotes that this string should be sorted to precede the other.<br/>
  2206. /// +1 denotes that this string should be sorted to follow the other.<br/>
  2207. /// </returns>
  2208. public int CompareTo(FixedString4096Bytes other)
  2209. {
  2210. return FixedStringMethods.CompareTo(ref this, other);
  2211. }
  2212. /// <summary>
  2213. /// Initializes and returns an instance of FixedString32Bytes that is a copy of another string.
  2214. /// </summary>
  2215. /// <param name="other">The string to copy.</param>
  2216. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  2217. public FixedString32Bytes(in FixedString4096Bytes other)
  2218. {
  2219. this = default;
  2220. var error = Initialize(other);
  2221. CheckFormatError(error);
  2222. }
  2223. /// <summary>
  2224. /// Initializes an instance of FixedString32Bytes that is a copy of another string.
  2225. /// </summary>
  2226. /// <param name="other">The string to copy.</param>
  2227. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2228. unsafe internal FormatError Initialize(in FixedString4096Bytes other)
  2229. {
  2230. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  2231. }
  2232. /// <summary>
  2233. /// Returns true if a FixedString32Bytes and another string are equal.
  2234. /// </summary>
  2235. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2236. /// <param name="a">A FixedString32Bytes to compare for equality.</param>
  2237. /// <param name="b">A FixedString4096Bytes to compare for equality.</param>
  2238. /// <returns>True if the two strings are equal.</returns>
  2239. public static bool operator ==(in FixedString32Bytes a, in FixedString4096Bytes b)
  2240. {
  2241. // this must not call any methods on 'a' or 'b'
  2242. unsafe {
  2243. int alen = a.utf8LengthInBytes;
  2244. int blen = b.utf8LengthInBytes;
  2245. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2246. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2247. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2248. }
  2249. }
  2250. /// <summary>
  2251. /// Returns true if a FixedString32Bytes and another string are unequal.
  2252. /// </summary>
  2253. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2254. /// <param name="a">A FixedString32Bytes to compare for inequality.</param>
  2255. /// <param name="b">A FixedString4096Bytes to compare for inequality.</param>
  2256. /// <returns>True if the two strings are unequal.</returns>
  2257. public static bool operator !=(in FixedString32Bytes a, in FixedString4096Bytes b)
  2258. {
  2259. return !(a == b);
  2260. }
  2261. /// <summary>
  2262. /// Returns true if this string and another string are equal.
  2263. /// </summary>
  2264. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2265. /// <param name="other">A FixedString4096Bytes to compare for equality.</param>
  2266. /// <returns>True if the two strings are equal.</returns>
  2267. public bool Equals(FixedString4096Bytes other)
  2268. {
  2269. return this == other;
  2270. }
  2271. /// <summary>
  2272. /// Returns a new FixedString4096Bytes that is a copy of another string.
  2273. /// </summary>
  2274. /// <param name="fs">A FixedString32Bytes to copy.</param>
  2275. /// <returns>A new FixedString4096Bytes that is a copy of the other string.</returns>
  2276. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  2277. public static implicit operator FixedString4096Bytes(in FixedString32Bytes fs) => new FixedString4096Bytes(in fs);
  2278. /// <summary>
  2279. /// Returns a new FixedString32Bytes that is a copy of another string.
  2280. /// </summary>
  2281. /// <param name="b">A string to copy.</param>
  2282. /// <returns>A new FixedString32Bytes that is a copy of another string.</returns>
  2283. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString32Bytes.</exception>
  2284. [ExcludeFromBurstCompatTesting("Takes managed string")]
  2285. public static implicit operator FixedString32Bytes(string b) => new FixedString32Bytes(b);
  2286. /// <summary>
  2287. /// Returns a new managed string that is a copy of this string.
  2288. /// </summary>
  2289. /// <returns>A new managed string that is a copy of this string.</returns>
  2290. [ExcludeFromBurstCompatTesting("Returns managed string")]
  2291. public override String ToString()
  2292. {
  2293. return this.ConvertToString();
  2294. }
  2295. /// <summary>
  2296. /// Returns a hash code of this string.
  2297. /// </summary>
  2298. /// <remarks>Only the character bytes are included in the hash: any bytes beyond <see cref="Length"/> are not part of the hash.</remarks>
  2299. /// <returns>The hash code of this string.</returns>
  2300. public override int GetHashCode()
  2301. {
  2302. return this.ComputeHashCode();
  2303. }
  2304. /// <summary>
  2305. /// Returns true if this string and an object are equal.
  2306. /// </summary>
  2307. /// <remarks>
  2308. /// Returns false if the object is neither a System.String or a FixedString.
  2309. ///
  2310. /// Two strings are equal if they have equal length and all their characters match.</remarks>
  2311. /// <param name="obj">An object to compare for equality.</param>
  2312. /// <returns>True if this string and the object are equal.</returns>
  2313. [ExcludeFromBurstCompatTesting("Takes managed object")]
  2314. public override bool Equals(object obj)
  2315. {
  2316. if(ReferenceEquals(null, obj)) return false;
  2317. if(obj is String aString) return Equals(aString);
  2318. if(obj is FixedString32Bytes aFixedString32Bytes) return Equals(aFixedString32Bytes);
  2319. if(obj is FixedString64Bytes aFixedString64Bytes) return Equals(aFixedString64Bytes);
  2320. if(obj is FixedString128Bytes aFixedString128Bytes) return Equals(aFixedString128Bytes);
  2321. if(obj is FixedString512Bytes aFixedString512Bytes) return Equals(aFixedString512Bytes);
  2322. if(obj is FixedString4096Bytes aFixedString4096Bytes) return Equals(aFixedString4096Bytes);
  2323. return false;
  2324. }
  2325. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  2326. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2327. readonly void CheckIndexInRange(int index)
  2328. {
  2329. if (index < 0)
  2330. throw new IndexOutOfRangeException($"Index {index} must be positive.");
  2331. if (index >= utf8LengthInBytes)
  2332. throw new IndexOutOfRangeException($"Index {index} is out of range in FixedString32Bytes of '{utf8LengthInBytes}' Length.");
  2333. }
  2334. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  2335. void CheckLengthInRange(int length)
  2336. {
  2337. if (length < 0)
  2338. throw new ArgumentOutOfRangeException($"Length {length} must be positive.");
  2339. if (length > utf8MaxLengthInBytes)
  2340. throw new ArgumentOutOfRangeException($"Length {length} is out of range in FixedString32Bytes of '{utf8MaxLengthInBytes}' Capacity.");
  2341. }
  2342. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  2343. void CheckCapacityInRange(int capacity)
  2344. {
  2345. if (capacity > utf8MaxLengthInBytes)
  2346. throw new ArgumentOutOfRangeException($"Capacity {capacity} must be lower than {utf8MaxLengthInBytes}.");
  2347. }
  2348. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  2349. static void CheckCopyError(CopyError error, String source)
  2350. {
  2351. if (error != CopyError.None)
  2352. throw new ArgumentException($"FixedString32Bytes: {error} while copying \"{source}\"");
  2353. }
  2354. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  2355. static void CheckFormatError(FormatError error)
  2356. {
  2357. if (error != FormatError.None)
  2358. throw new ArgumentException("Source is too long to fit into fixed string of this size");
  2359. }
  2360. }
  2361. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  2362. // However, only the first element of data members with names is copied at this time.
  2363. // Therefore, it's important that all data visible in the debugger, has a name
  2364. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  2365. /// <summary>
  2366. /// For internal use only.
  2367. /// </summary>
  2368. [Serializable]
  2369. [StructLayout(LayoutKind.Explicit, Size=62)]
  2370. [GenerateTestsForBurstCompatibility]
  2371. public struct FixedBytes62
  2372. {
  2373. /// <summary>
  2374. /// For internal use only.
  2375. /// </summary>
  2376. [FieldOffset(0)] public FixedBytes16 offset0000;
  2377. /// <summary>
  2378. /// For internal use only.
  2379. /// </summary>
  2380. [FieldOffset(16)] public FixedBytes16 offset0016;
  2381. /// <summary>
  2382. /// For internal use only.
  2383. /// </summary>
  2384. [FieldOffset(32)] public FixedBytes16 offset0032;
  2385. /// <summary>
  2386. /// For internal use only.
  2387. /// </summary>
  2388. [FieldOffset(48)] public byte byte0048;
  2389. /// <summary>
  2390. /// For internal use only.
  2391. /// </summary>
  2392. [FieldOffset(49)] public byte byte0049;
  2393. /// <summary>
  2394. /// For internal use only.
  2395. /// </summary>
  2396. [FieldOffset(50)] public byte byte0050;
  2397. /// <summary>
  2398. /// For internal use only.
  2399. /// </summary>
  2400. [FieldOffset(51)] public byte byte0051;
  2401. /// <summary>
  2402. /// For internal use only.
  2403. /// </summary>
  2404. [FieldOffset(52)] public byte byte0052;
  2405. /// <summary>
  2406. /// For internal use only.
  2407. /// </summary>
  2408. [FieldOffset(53)] public byte byte0053;
  2409. /// <summary>
  2410. /// For internal use only.
  2411. /// </summary>
  2412. [FieldOffset(54)] public byte byte0054;
  2413. /// <summary>
  2414. /// For internal use only.
  2415. /// </summary>
  2416. [FieldOffset(55)] public byte byte0055;
  2417. /// <summary>
  2418. /// For internal use only.
  2419. /// </summary>
  2420. [FieldOffset(56)] public byte byte0056;
  2421. /// <summary>
  2422. /// For internal use only.
  2423. /// </summary>
  2424. [FieldOffset(57)] public byte byte0057;
  2425. /// <summary>
  2426. /// For internal use only.
  2427. /// </summary>
  2428. [FieldOffset(58)] public byte byte0058;
  2429. /// <summary>
  2430. /// For internal use only.
  2431. /// </summary>
  2432. [FieldOffset(59)] public byte byte0059;
  2433. /// <summary>
  2434. /// For internal use only.
  2435. /// </summary>
  2436. [FieldOffset(60)] public byte byte0060;
  2437. /// <summary>
  2438. /// For internal use only.
  2439. /// </summary>
  2440. [FieldOffset(61)] public byte byte0061;
  2441. }
  2442. /// <summary>
  2443. /// An unmanaged UTF-8 string whose content is stored directly in the 64-byte struct.
  2444. /// </summary>
  2445. /// <remarks>
  2446. /// The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer)
  2447. /// followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character.
  2448. /// Effectively, the number of bytes for storing characters is 3 less than 64 (two length bytes and one null byte).
  2449. ///
  2450. /// This layout is identical to a <see cref="FixedList64Bytes{T}"/> of bytes, thus allowing reinterpretation between FixedString64Bytes and FixedList64Bytes.
  2451. ///
  2452. /// By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation.
  2453. /// Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.
  2454. /// </remarks>
  2455. [Serializable]
  2456. [StructLayout(LayoutKind.Sequential, Size=64)]
  2457. [GenerateTestsForBurstCompatibility]
  2458. public partial struct FixedString64Bytes
  2459. : INativeList<byte>
  2460. , IUTF8Bytes
  2461. , IComparable<String>
  2462. , IEquatable<String>
  2463. , IComparable<FixedString32Bytes>
  2464. , IEquatable<FixedString32Bytes>
  2465. , IComparable<FixedString64Bytes>
  2466. , IEquatable<FixedString64Bytes>
  2467. , IComparable<FixedString128Bytes>
  2468. , IEquatable<FixedString128Bytes>
  2469. , IComparable<FixedString512Bytes>
  2470. , IEquatable<FixedString512Bytes>
  2471. , IComparable<FixedString4096Bytes>
  2472. , IEquatable<FixedString4096Bytes>
  2473. {
  2474. internal const ushort utf8MaxLengthInBytes = 61;
  2475. [SerializeField] internal ushort utf8LengthInBytes;
  2476. [SerializeField] internal FixedBytes62 bytes;
  2477. /// <summary>
  2478. /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
  2479. /// </summary>
  2480. /// <returns>
  2481. /// The maximum number of UTF-8 bytes that can be stored in this string.
  2482. /// </returns>
  2483. public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
  2484. /// <summary>
  2485. /// For internal use only. Use <see cref="ToString"/> instead.
  2486. /// </summary>
  2487. /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
  2488. [CreateProperty]
  2489. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  2490. [ExcludeFromBurstCompatTesting("Returns managed string")]
  2491. public string Value => ToString();
  2492. /// <summary>
  2493. /// Returns a pointer to the character bytes.
  2494. /// </summary>
  2495. /// <remarks>
  2496. /// The pointer returned by this method points into the internals of the target FixedString object. It is the
  2497. /// caller's responsibility to ensure that the pointer is not used after the FixedString object is destroyed or goes
  2498. /// out of scope.
  2499. /// </remarks>
  2500. /// <returns>A pointer to the character bytes.</returns>
  2501. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2502. public readonly unsafe byte* GetUnsafePtr()
  2503. {
  2504. fixed(void* b = &bytes)
  2505. return (byte*)b;
  2506. }
  2507. /// <summary>
  2508. /// The current length in bytes of this string's content.
  2509. /// </summary>
  2510. /// <remarks>
  2511. /// The length value does not include the null-terminator byte.
  2512. /// </remarks>
  2513. /// <param name="value">The new length in bytes of the string's content.</param>
  2514. /// <exception cref="ArgumentOutOfRangeException">Thrown if the new length is out of bounds.</exception>
  2515. /// <value>
  2516. /// The current length in bytes of this string's content.
  2517. /// </value>
  2518. public int Length
  2519. {
  2520. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2521. readonly get
  2522. {
  2523. return utf8LengthInBytes;
  2524. }
  2525. set
  2526. {
  2527. CheckLengthInRange(value);
  2528. utf8LengthInBytes = (ushort)value;
  2529. unsafe
  2530. {
  2531. GetUnsafePtr()[utf8LengthInBytes] = 0;
  2532. }
  2533. }
  2534. }
  2535. /// <summary>
  2536. /// The number of bytes this string has for storing UTF-8 characters.
  2537. /// </summary>
  2538. /// <value>The number of bytes this string has for storing UTF-8 characters.</value>
  2539. /// <remarks>
  2540. /// Does not include the null-terminator byte.
  2541. ///
  2542. /// A setter is included for conformity with <see cref="INativeList{T}"/>, but <see cref="Capacity"/> is fixed at 61.
  2543. /// Setting the value to anything other than 61 throws an exception.
  2544. ///
  2545. /// In UTF-8 encoding, each Unicode code point (character) requires 1 to 4 bytes,
  2546. /// so the number of characters that can be stored may be less than the capacity.
  2547. /// </remarks>
  2548. /// <exception cref="ArgumentOutOfRangeException">Thrown if attempting to set the capacity to anything other than 61.</exception>
  2549. public int Capacity
  2550. {
  2551. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2552. readonly get
  2553. {
  2554. return utf8MaxLengthInBytes;
  2555. }
  2556. set
  2557. {
  2558. CheckCapacityInRange(value);
  2559. }
  2560. }
  2561. /// <summary>
  2562. /// Attempts to set the length in bytes. Does nothing if the new length is invalid.
  2563. /// </summary>
  2564. /// <param name="newLength">The desired length.</param>
  2565. /// <param name="clearOptions">Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)</param>
  2566. /// <returns>True if the new length is valid.</returns>
  2567. public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
  2568. {
  2569. if (newLength < 0 || newLength > utf8MaxLengthInBytes)
  2570. return false;
  2571. if (newLength == utf8LengthInBytes)
  2572. return true;
  2573. unsafe
  2574. {
  2575. if (clearOptions == NativeArrayOptions.ClearMemory)
  2576. {
  2577. if (newLength > utf8LengthInBytes)
  2578. UnsafeUtility.MemClear(GetUnsafePtr() + utf8LengthInBytes, newLength - utf8LengthInBytes);
  2579. else
  2580. UnsafeUtility.MemClear(GetUnsafePtr() + newLength, utf8LengthInBytes - newLength);
  2581. }
  2582. utf8LengthInBytes = (ushort)newLength;
  2583. // always null terminate
  2584. GetUnsafePtr()[utf8LengthInBytes] = 0;
  2585. }
  2586. return true;
  2587. }
  2588. /// <summary>
  2589. /// Returns true if this string is empty (has no characters).
  2590. /// </summary>
  2591. /// <value>True if this string is empty (has no characters).</value>
  2592. public readonly bool IsEmpty
  2593. {
  2594. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2595. get => utf8LengthInBytes == 0;
  2596. }
  2597. /// <summary>
  2598. /// Returns the byte (not character) at an index.
  2599. /// </summary>
  2600. /// <param name="index">A byte index.</param>
  2601. /// <value>The byte at the index.</value>
  2602. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  2603. public byte this[int index]
  2604. {
  2605. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2606. readonly get
  2607. {
  2608. unsafe
  2609. {
  2610. CheckIndexInRange(index);
  2611. return GetUnsafePtr()[index];
  2612. }
  2613. }
  2614. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2615. set
  2616. {
  2617. unsafe
  2618. {
  2619. CheckIndexInRange(index);
  2620. GetUnsafePtr()[index] = value;
  2621. }
  2622. }
  2623. }
  2624. /// <summary>
  2625. /// Returns the reference to a byte (not character) at an index.
  2626. /// </summary>
  2627. /// <param name="index">A byte index.</param>
  2628. /// <returns>A reference to the byte at the index.</returns>
  2629. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  2630. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2631. public ref byte ElementAt(int index)
  2632. {
  2633. unsafe
  2634. {
  2635. CheckIndexInRange(index);
  2636. return ref GetUnsafePtr()[index];
  2637. }
  2638. }
  2639. /// <summary>
  2640. /// Sets the length to 0.
  2641. /// </summary>
  2642. public void Clear()
  2643. {
  2644. Length = 0;
  2645. }
  2646. /// <summary>
  2647. /// Appends a byte.
  2648. /// </summary>
  2649. /// <remarks>
  2650. /// A zero byte will always follow the newly appended byte.
  2651. ///
  2652. /// No validation is performed: it is your responsibility for the bytes of the string to form valid UTF-8 when you're done appending bytes.
  2653. /// </remarks>
  2654. /// <param name="value">A byte to append.</param>
  2655. public void Add(in byte value)
  2656. {
  2657. this[Length++] = value;
  2658. }
  2659. /// <summary>
  2660. /// An enumerator over the characters (not bytes) of a FixedString64Bytes.
  2661. /// </summary>
  2662. /// <remarks>
  2663. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  2664. /// The first <see cref="MoveNext"/> call advances the enumerator's index to the first character.
  2665. /// </remarks>
  2666. public struct Enumerator : IEnumerator
  2667. {
  2668. FixedString64Bytes target;
  2669. int offset;
  2670. Unicode.Rune current;
  2671. /// <summary>
  2672. /// Initializes and returns an instance of FixedString64Bytes.Enumerator.
  2673. /// </summary>
  2674. /// <param name="other">A FixeString64 for which to create an enumerator.</param>
  2675. public Enumerator(FixedString64Bytes other)
  2676. {
  2677. target = other;
  2678. offset = 0;
  2679. current = default;
  2680. }
  2681. /// <summary>
  2682. /// Does nothing.
  2683. /// </summary>
  2684. public void Dispose()
  2685. {
  2686. }
  2687. /// <summary>
  2688. /// Advances the enumerator to the next character.
  2689. /// </summary>
  2690. /// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
  2691. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2692. public bool MoveNext()
  2693. {
  2694. if (offset >= target.Length)
  2695. return false;
  2696. unsafe
  2697. {
  2698. Unicode.Utf8ToUcs(out current, target.GetUnsafePtr(), ref offset, target.Length);
  2699. }
  2700. return true;
  2701. }
  2702. /// <summary>
  2703. /// Resets the enumerator to its initial state.
  2704. /// </summary>
  2705. public void Reset()
  2706. {
  2707. offset = 0;
  2708. current = default;
  2709. }
  2710. /// <summary>
  2711. /// The current character.
  2712. /// </summary>
  2713. /// <remarks>
  2714. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  2715. /// </remarks>
  2716. /// <value>The current character.</value>
  2717. public Unicode.Rune Current
  2718. {
  2719. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  2720. get => current;
  2721. }
  2722. object IEnumerator.Current => Current;
  2723. }
  2724. /// <summary>
  2725. /// Returns an enumerator for iterating over the characters of this string.
  2726. /// </summary>
  2727. /// <returns>An enumerator for iterating over the characters of the FixedString64Bytes.</returns>
  2728. public Enumerator GetEnumerator()
  2729. {
  2730. return new Enumerator(this);
  2731. }
  2732. /// <summary>
  2733. /// Returns the lexicographical sort order of this string relative to another.
  2734. /// </summary>
  2735. /// <param name="other">A `System.String` to compare with.</param>
  2736. /// <returns>An integer denoting the lexicographical sort order of this string relative to the other:
  2737. ///
  2738. /// 0 denotes both strings have the same sort position.<br/>
  2739. /// -1 denotes that this string should be sorted to precede the other string.<br/>
  2740. /// +1 denotes that this string should be sorted to follow the other string.<br/>
  2741. /// </returns>
  2742. [ExcludeFromBurstCompatTesting("Takes managed string")]
  2743. public int CompareTo(String other)
  2744. {
  2745. return ToString().CompareTo(other);
  2746. }
  2747. /// <summary>
  2748. /// Returns true if this string and another have the same length and all the same characters.
  2749. /// </summary>
  2750. /// <param name="other">A string to compare for equality.</param>
  2751. /// <returns>True if this string and the other have the same length and all the same characters.</returns>
  2752. [ExcludeFromBurstCompatTesting("Takes managed string")]
  2753. public bool Equals(String other)
  2754. {
  2755. unsafe {
  2756. int alen = utf8LengthInBytes;
  2757. int blen = other.Length;
  2758. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(bytes);
  2759. fixed(char* bptr = other)
  2760. {
  2761. return UTF8ArrayUnsafeUtility.StrCmp(aptr, alen, bptr, blen) == 0;
  2762. }
  2763. }
  2764. }
  2765. /// <summary>
  2766. /// Returns a reference to a FixedList64Bytes&lt;byte&gt; representation of this string.
  2767. /// </summary>
  2768. /// <remarks>
  2769. /// The referenced FixedListByte64 is the very same bytes as the original FixedString64Bytes,
  2770. /// so it is only valid as long as the original FixedString64Bytes is valid.
  2771. /// </remarks>
  2772. /// <returns>A ref to a FixedListByte64 representation of the FixedString64Bytes.</returns>
  2773. public unsafe ref FixedList64Bytes<byte> AsFixedList()
  2774. {
  2775. return ref UnsafeUtility.AsRef<FixedList64Bytes<byte>>(UnsafeUtility.AddressOf(ref this));
  2776. }
  2777. /// <summary>
  2778. /// Initializes and returns an instance of FixedString64Bytes with the characters copied from a string.
  2779. /// </summary>
  2780. /// <param name="source">The source string to copy.</param>
  2781. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2782. [ExcludeFromBurstCompatTesting("Takes managed string")]
  2783. public FixedString64Bytes(String source)
  2784. {
  2785. this = default;
  2786. var error = Initialize(source);
  2787. CheckCopyError(error, source);
  2788. }
  2789. /// <summary>
  2790. /// Initializes an instance of FixedString64Bytes with the characters copied from a string.
  2791. /// </summary>
  2792. /// <param name="source">The source string to copy.</param>
  2793. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, only the portion that fits is copied in and CopyError.Truncation is returned.</returns>
  2794. [ExcludeFromBurstCompatTesting("Takes managed string")]
  2795. internal CopyError Initialize(String source)
  2796. {
  2797. return this.CopyFromTruncated(source);
  2798. }
  2799. /// <summary>
  2800. /// Initializes and returns an instance of FixedString64Bytes with a single character repeatedly appended some number of times.
  2801. /// </summary>
  2802. /// <param name="rune">The Unicode.Rune to repeat.</param>
  2803. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  2804. public FixedString64Bytes(Unicode.Rune rune, int count = 1)
  2805. {
  2806. this = default;
  2807. Initialize(rune, count);
  2808. }
  2809. /// <summary>
  2810. /// Initializes an instance of FixedString64Bytes with a single character repeatedly appended some number of times.
  2811. /// </summary>
  2812. /// <param name="rune">The Unicode.Rune to repeat.</param>
  2813. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  2814. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2815. internal FormatError Initialize(Unicode.Rune rune, int count = 1)
  2816. {
  2817. this = default;
  2818. return this.Append(rune, count);
  2819. }
  2820. /// <summary>
  2821. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  2822. /// </summary>
  2823. /// <param name="srcBytes">The source buffer.</param>
  2824. /// <param name="srcLength">The number of bytes to read from the source.</param>
  2825. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2826. unsafe internal FormatError Initialize(byte* srcBytes, int srcLength)
  2827. {
  2828. bytes = default;
  2829. utf8LengthInBytes = 0;
  2830. unsafe {
  2831. int len = 0;
  2832. byte* dstBytes = GetUnsafePtr();
  2833. var error = UTF8ArrayUnsafeUtility.AppendUTF8Bytes(dstBytes, ref len, utf8MaxLengthInBytes, srcBytes, srcLength);
  2834. if(error != FormatError.None)
  2835. return error;
  2836. this.Length = len;
  2837. }
  2838. return FormatError.None;
  2839. }
  2840. /// <summary>
  2841. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  2842. /// </summary>
  2843. /// <param name="other">The string to copy.</param>
  2844. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2845. unsafe public FixedString64Bytes(NativeText.ReadOnly other)
  2846. {
  2847. this = default;
  2848. var error = Initialize(other.GetUnsafePtr(), other.Length);
  2849. CheckFormatError(error);
  2850. }
  2851. /// <summary>
  2852. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  2853. /// </summary>
  2854. /// <param name="other">The UnsafeText to copy.</param>
  2855. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2856. unsafe public FixedString64Bytes(in UnsafeText other)
  2857. {
  2858. this = default;
  2859. var error = Initialize(other.GetUnsafePtr(), other.Length);
  2860. CheckFormatError(error);
  2861. }
  2862. /// <summary>
  2863. /// Returns the lexicographical sort order of this string relative to another.
  2864. /// </summary>
  2865. /// <param name="other">A string to compare with.</param>
  2866. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  2867. ///
  2868. /// 0 denotes that both strings have the same sort position.<br/>
  2869. /// -1 denotes that this string should be sorted to precede the other.<br/>
  2870. /// +1 denotes that this string should be sorted to follow the other.<br/>
  2871. /// </returns>
  2872. public int CompareTo(FixedString32Bytes other)
  2873. {
  2874. return FixedStringMethods.CompareTo(ref this, other);
  2875. }
  2876. /// <summary>
  2877. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  2878. /// </summary>
  2879. /// <param name="other">The string to copy.</param>
  2880. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2881. public FixedString64Bytes(in FixedString32Bytes other)
  2882. {
  2883. this = default;
  2884. var error = Initialize(other);
  2885. CheckFormatError(error);
  2886. }
  2887. /// <summary>
  2888. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  2889. /// </summary>
  2890. /// <param name="other">The string to copy.</param>
  2891. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2892. unsafe internal FormatError Initialize(in FixedString32Bytes other)
  2893. {
  2894. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  2895. }
  2896. /// <summary>
  2897. /// Returns true if a FixedString64Bytes and another string are equal.
  2898. /// </summary>
  2899. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2900. /// <param name="a">A FixedString64Bytes to compare for equality.</param>
  2901. /// <param name="b">A FixedString32Bytes to compare for equality.</param>
  2902. /// <returns>True if the two strings are equal.</returns>
  2903. public static bool operator ==(in FixedString64Bytes a, in FixedString32Bytes b)
  2904. {
  2905. // this must not call any methods on 'a' or 'b'
  2906. unsafe {
  2907. int alen = a.utf8LengthInBytes;
  2908. int blen = b.utf8LengthInBytes;
  2909. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2910. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2911. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2912. }
  2913. }
  2914. /// <summary>
  2915. /// Returns true if a FixedString64Bytes and another string are unequal.
  2916. /// </summary>
  2917. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2918. /// <param name="a">A FixedString64Bytes to compare for inequality.</param>
  2919. /// <param name="b">A FixedString32Bytes to compare for inequality.</param>
  2920. /// <returns>True if the two strings are unequal.</returns>
  2921. public static bool operator !=(in FixedString64Bytes a, in FixedString32Bytes b)
  2922. {
  2923. return !(a == b);
  2924. }
  2925. /// <summary>
  2926. /// Returns true if this string and another string are equal.
  2927. /// </summary>
  2928. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2929. /// <param name="other">A FixedString32Bytes to compare for equality.</param>
  2930. /// <returns>True if the two strings are equal.</returns>
  2931. public bool Equals(FixedString32Bytes other)
  2932. {
  2933. return this == other;
  2934. }
  2935. /// <summary>
  2936. /// Returns the lexicographical sort order of this string relative to another.
  2937. /// </summary>
  2938. /// <param name="other">A string to compare with.</param>
  2939. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  2940. ///
  2941. /// 0 denotes that both strings have the same sort position.<br/>
  2942. /// -1 denotes that this string should be sorted to precede the other.<br/>
  2943. /// +1 denotes that this string should be sorted to follow the other.<br/>
  2944. /// </returns>
  2945. public int CompareTo(FixedString64Bytes other)
  2946. {
  2947. return FixedStringMethods.CompareTo(ref this, other);
  2948. }
  2949. /// <summary>
  2950. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  2951. /// </summary>
  2952. /// <param name="other">The string to copy.</param>
  2953. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  2954. public FixedString64Bytes(in FixedString64Bytes other)
  2955. {
  2956. this = default;
  2957. var error = Initialize(other);
  2958. CheckFormatError(error);
  2959. }
  2960. /// <summary>
  2961. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  2962. /// </summary>
  2963. /// <param name="other">The string to copy.</param>
  2964. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  2965. unsafe internal FormatError Initialize(in FixedString64Bytes other)
  2966. {
  2967. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  2968. }
  2969. /// <summary>
  2970. /// Returns true if a FixedString64Bytes and another string are equal.
  2971. /// </summary>
  2972. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2973. /// <param name="a">A FixedString64Bytes to compare for equality.</param>
  2974. /// <param name="b">A FixedString64Bytes to compare for equality.</param>
  2975. /// <returns>True if the two strings are equal.</returns>
  2976. public static bool operator ==(in FixedString64Bytes a, in FixedString64Bytes b)
  2977. {
  2978. // this must not call any methods on 'a' or 'b'
  2979. unsafe {
  2980. int alen = a.utf8LengthInBytes;
  2981. int blen = b.utf8LengthInBytes;
  2982. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  2983. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  2984. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  2985. }
  2986. }
  2987. /// <summary>
  2988. /// Returns true if a FixedString64Bytes and another string are unequal.
  2989. /// </summary>
  2990. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  2991. /// <param name="a">A FixedString64Bytes to compare for inequality.</param>
  2992. /// <param name="b">A FixedString64Bytes to compare for inequality.</param>
  2993. /// <returns>True if the two strings are unequal.</returns>
  2994. public static bool operator !=(in FixedString64Bytes a, in FixedString64Bytes b)
  2995. {
  2996. return !(a == b);
  2997. }
  2998. /// <summary>
  2999. /// Returns true if this string and another string are equal.
  3000. /// </summary>
  3001. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3002. /// <param name="other">A FixedString64Bytes to compare for equality.</param>
  3003. /// <returns>True if the two strings are equal.</returns>
  3004. public bool Equals(FixedString64Bytes other)
  3005. {
  3006. return this == other;
  3007. }
  3008. /// <summary>
  3009. /// Returns the lexicographical sort order of this string relative to another.
  3010. /// </summary>
  3011. /// <param name="other">A string to compare with.</param>
  3012. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3013. ///
  3014. /// 0 denotes that both strings have the same sort position.<br/>
  3015. /// -1 denotes that this string should be sorted to precede the other.<br/>
  3016. /// +1 denotes that this string should be sorted to follow the other.<br/>
  3017. /// </returns>
  3018. public int CompareTo(FixedString128Bytes other)
  3019. {
  3020. return FixedStringMethods.CompareTo(ref this, other);
  3021. }
  3022. /// <summary>
  3023. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  3024. /// </summary>
  3025. /// <param name="other">The string to copy.</param>
  3026. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  3027. public FixedString64Bytes(in FixedString128Bytes other)
  3028. {
  3029. this = default;
  3030. var error = Initialize(other);
  3031. CheckFormatError(error);
  3032. }
  3033. /// <summary>
  3034. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  3035. /// </summary>
  3036. /// <param name="other">The string to copy.</param>
  3037. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3038. unsafe internal FormatError Initialize(in FixedString128Bytes other)
  3039. {
  3040. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  3041. }
  3042. /// <summary>
  3043. /// Returns true if a FixedString64Bytes and another string are equal.
  3044. /// </summary>
  3045. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3046. /// <param name="a">A FixedString64Bytes to compare for equality.</param>
  3047. /// <param name="b">A FixedString128Bytes to compare for equality.</param>
  3048. /// <returns>True if the two strings are equal.</returns>
  3049. public static bool operator ==(in FixedString64Bytes a, in FixedString128Bytes b)
  3050. {
  3051. // this must not call any methods on 'a' or 'b'
  3052. unsafe {
  3053. int alen = a.utf8LengthInBytes;
  3054. int blen = b.utf8LengthInBytes;
  3055. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  3056. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  3057. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  3058. }
  3059. }
  3060. /// <summary>
  3061. /// Returns true if a FixedString64Bytes and another string are unequal.
  3062. /// </summary>
  3063. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3064. /// <param name="a">A FixedString64Bytes to compare for inequality.</param>
  3065. /// <param name="b">A FixedString128Bytes to compare for inequality.</param>
  3066. /// <returns>True if the two strings are unequal.</returns>
  3067. public static bool operator !=(in FixedString64Bytes a, in FixedString128Bytes b)
  3068. {
  3069. return !(a == b);
  3070. }
  3071. /// <summary>
  3072. /// Returns true if this string and another string are equal.
  3073. /// </summary>
  3074. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3075. /// <param name="other">A FixedString128Bytes to compare for equality.</param>
  3076. /// <returns>True if the two strings are equal.</returns>
  3077. public bool Equals(FixedString128Bytes other)
  3078. {
  3079. return this == other;
  3080. }
  3081. /// <summary>
  3082. /// Returns a new FixedString128Bytes that is a copy of another string.
  3083. /// </summary>
  3084. /// <param name="fs">A FixedString64Bytes to copy.</param>
  3085. /// <returns>A new FixedString128Bytes that is a copy of the other string.</returns>
  3086. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3087. public static implicit operator FixedString128Bytes(in FixedString64Bytes fs) => new FixedString128Bytes(in fs);
  3088. /// <summary>
  3089. /// Returns the lexicographical sort order of this string relative to another.
  3090. /// </summary>
  3091. /// <param name="other">A string to compare with.</param>
  3092. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3093. ///
  3094. /// 0 denotes that both strings have the same sort position.<br/>
  3095. /// -1 denotes that this string should be sorted to precede the other.<br/>
  3096. /// +1 denotes that this string should be sorted to follow the other.<br/>
  3097. /// </returns>
  3098. public int CompareTo(FixedString512Bytes other)
  3099. {
  3100. return FixedStringMethods.CompareTo(ref this, other);
  3101. }
  3102. /// <summary>
  3103. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  3104. /// </summary>
  3105. /// <param name="other">The string to copy.</param>
  3106. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  3107. public FixedString64Bytes(in FixedString512Bytes other)
  3108. {
  3109. this = default;
  3110. var error = Initialize(other);
  3111. CheckFormatError(error);
  3112. }
  3113. /// <summary>
  3114. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  3115. /// </summary>
  3116. /// <param name="other">The string to copy.</param>
  3117. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3118. unsafe internal FormatError Initialize(in FixedString512Bytes other)
  3119. {
  3120. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  3121. }
  3122. /// <summary>
  3123. /// Returns true if a FixedString64Bytes and another string are equal.
  3124. /// </summary>
  3125. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3126. /// <param name="a">A FixedString64Bytes to compare for equality.</param>
  3127. /// <param name="b">A FixedString512Bytes to compare for equality.</param>
  3128. /// <returns>True if the two strings are equal.</returns>
  3129. public static bool operator ==(in FixedString64Bytes a, in FixedString512Bytes b)
  3130. {
  3131. // this must not call any methods on 'a' or 'b'
  3132. unsafe {
  3133. int alen = a.utf8LengthInBytes;
  3134. int blen = b.utf8LengthInBytes;
  3135. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  3136. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  3137. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  3138. }
  3139. }
  3140. /// <summary>
  3141. /// Returns true if a FixedString64Bytes and another string are unequal.
  3142. /// </summary>
  3143. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3144. /// <param name="a">A FixedString64Bytes to compare for inequality.</param>
  3145. /// <param name="b">A FixedString512Bytes to compare for inequality.</param>
  3146. /// <returns>True if the two strings are unequal.</returns>
  3147. public static bool operator !=(in FixedString64Bytes a, in FixedString512Bytes b)
  3148. {
  3149. return !(a == b);
  3150. }
  3151. /// <summary>
  3152. /// Returns true if this string and another string are equal.
  3153. /// </summary>
  3154. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3155. /// <param name="other">A FixedString512Bytes to compare for equality.</param>
  3156. /// <returns>True if the two strings are equal.</returns>
  3157. public bool Equals(FixedString512Bytes other)
  3158. {
  3159. return this == other;
  3160. }
  3161. /// <summary>
  3162. /// Returns a new FixedString512Bytes that is a copy of another string.
  3163. /// </summary>
  3164. /// <param name="fs">A FixedString64Bytes to copy.</param>
  3165. /// <returns>A new FixedString512Bytes that is a copy of the other string.</returns>
  3166. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  3167. public static implicit operator FixedString512Bytes(in FixedString64Bytes fs) => new FixedString512Bytes(in fs);
  3168. /// <summary>
  3169. /// Returns the lexicographical sort order of this string relative to another.
  3170. /// </summary>
  3171. /// <param name="other">A string to compare with.</param>
  3172. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3173. ///
  3174. /// 0 denotes that both strings have the same sort position.<br/>
  3175. /// -1 denotes that this string should be sorted to precede the other.<br/>
  3176. /// +1 denotes that this string should be sorted to follow the other.<br/>
  3177. /// </returns>
  3178. public int CompareTo(FixedString4096Bytes other)
  3179. {
  3180. return FixedStringMethods.CompareTo(ref this, other);
  3181. }
  3182. /// <summary>
  3183. /// Initializes and returns an instance of FixedString64Bytes that is a copy of another string.
  3184. /// </summary>
  3185. /// <param name="other">The string to copy.</param>
  3186. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  3187. public FixedString64Bytes(in FixedString4096Bytes other)
  3188. {
  3189. this = default;
  3190. var error = Initialize(other);
  3191. CheckFormatError(error);
  3192. }
  3193. /// <summary>
  3194. /// Initializes an instance of FixedString64Bytes that is a copy of another string.
  3195. /// </summary>
  3196. /// <param name="other">The string to copy.</param>
  3197. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3198. unsafe internal FormatError Initialize(in FixedString4096Bytes other)
  3199. {
  3200. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  3201. }
  3202. /// <summary>
  3203. /// Returns true if a FixedString64Bytes and another string are equal.
  3204. /// </summary>
  3205. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3206. /// <param name="a">A FixedString64Bytes to compare for equality.</param>
  3207. /// <param name="b">A FixedString4096Bytes to compare for equality.</param>
  3208. /// <returns>True if the two strings are equal.</returns>
  3209. public static bool operator ==(in FixedString64Bytes a, in FixedString4096Bytes b)
  3210. {
  3211. // this must not call any methods on 'a' or 'b'
  3212. unsafe {
  3213. int alen = a.utf8LengthInBytes;
  3214. int blen = b.utf8LengthInBytes;
  3215. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  3216. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  3217. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  3218. }
  3219. }
  3220. /// <summary>
  3221. /// Returns true if a FixedString64Bytes and another string are unequal.
  3222. /// </summary>
  3223. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3224. /// <param name="a">A FixedString64Bytes to compare for inequality.</param>
  3225. /// <param name="b">A FixedString4096Bytes to compare for inequality.</param>
  3226. /// <returns>True if the two strings are unequal.</returns>
  3227. public static bool operator !=(in FixedString64Bytes a, in FixedString4096Bytes b)
  3228. {
  3229. return !(a == b);
  3230. }
  3231. /// <summary>
  3232. /// Returns true if this string and another string are equal.
  3233. /// </summary>
  3234. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3235. /// <param name="other">A FixedString4096Bytes to compare for equality.</param>
  3236. /// <returns>True if the two strings are equal.</returns>
  3237. public bool Equals(FixedString4096Bytes other)
  3238. {
  3239. return this == other;
  3240. }
  3241. /// <summary>
  3242. /// Returns a new FixedString4096Bytes that is a copy of another string.
  3243. /// </summary>
  3244. /// <param name="fs">A FixedString64Bytes to copy.</param>
  3245. /// <returns>A new FixedString4096Bytes that is a copy of the other string.</returns>
  3246. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  3247. public static implicit operator FixedString4096Bytes(in FixedString64Bytes fs) => new FixedString4096Bytes(in fs);
  3248. /// <summary>
  3249. /// Returns a new FixedString64Bytes that is a copy of another string.
  3250. /// </summary>
  3251. /// <param name="b">A string to copy.</param>
  3252. /// <returns>A new FixedString64Bytes that is a copy of another string.</returns>
  3253. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString64Bytes.</exception>
  3254. [ExcludeFromBurstCompatTesting("Takes managed string")]
  3255. public static implicit operator FixedString64Bytes(string b) => new FixedString64Bytes(b);
  3256. /// <summary>
  3257. /// Returns a new managed string that is a copy of this string.
  3258. /// </summary>
  3259. /// <returns>A new managed string that is a copy of this string.</returns>
  3260. [ExcludeFromBurstCompatTesting("Returns managed string")]
  3261. public override String ToString()
  3262. {
  3263. return this.ConvertToString();
  3264. }
  3265. /// <summary>
  3266. /// Returns a hash code of this string.
  3267. /// </summary>
  3268. /// <remarks>Only the character bytes are included in the hash: any bytes beyond <see cref="Length"/> are not part of the hash.</remarks>
  3269. /// <returns>The hash code of this string.</returns>
  3270. public override int GetHashCode()
  3271. {
  3272. return this.ComputeHashCode();
  3273. }
  3274. /// <summary>
  3275. /// Returns true if this string and an object are equal.
  3276. /// </summary>
  3277. /// <remarks>
  3278. /// Returns false if the object is neither a System.String or a FixedString.
  3279. ///
  3280. /// Two strings are equal if they have equal length and all their characters match.</remarks>
  3281. /// <param name="obj">An object to compare for equality.</param>
  3282. /// <returns>True if this string and the object are equal.</returns>
  3283. [ExcludeFromBurstCompatTesting("Takes managed object")]
  3284. public override bool Equals(object obj)
  3285. {
  3286. if(ReferenceEquals(null, obj)) return false;
  3287. if(obj is String aString) return Equals(aString);
  3288. if(obj is FixedString32Bytes aFixedString32Bytes) return Equals(aFixedString32Bytes);
  3289. if(obj is FixedString64Bytes aFixedString64Bytes) return Equals(aFixedString64Bytes);
  3290. if(obj is FixedString128Bytes aFixedString128Bytes) return Equals(aFixedString128Bytes);
  3291. if(obj is FixedString512Bytes aFixedString512Bytes) return Equals(aFixedString512Bytes);
  3292. if(obj is FixedString4096Bytes aFixedString4096Bytes) return Equals(aFixedString4096Bytes);
  3293. return false;
  3294. }
  3295. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  3296. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3297. readonly void CheckIndexInRange(int index)
  3298. {
  3299. if (index < 0)
  3300. throw new IndexOutOfRangeException($"Index {index} must be positive.");
  3301. if (index >= utf8LengthInBytes)
  3302. throw new IndexOutOfRangeException($"Index {index} is out of range in FixedString64Bytes of '{utf8LengthInBytes}' Length.");
  3303. }
  3304. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  3305. void CheckLengthInRange(int length)
  3306. {
  3307. if (length < 0)
  3308. throw new ArgumentOutOfRangeException($"Length {length} must be positive.");
  3309. if (length > utf8MaxLengthInBytes)
  3310. throw new ArgumentOutOfRangeException($"Length {length} is out of range in FixedString64Bytes of '{utf8MaxLengthInBytes}' Capacity.");
  3311. }
  3312. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  3313. void CheckCapacityInRange(int capacity)
  3314. {
  3315. if (capacity > utf8MaxLengthInBytes)
  3316. throw new ArgumentOutOfRangeException($"Capacity {capacity} must be lower than {utf8MaxLengthInBytes}.");
  3317. }
  3318. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  3319. static void CheckCopyError(CopyError error, String source)
  3320. {
  3321. if (error != CopyError.None)
  3322. throw new ArgumentException($"FixedString64Bytes: {error} while copying \"{source}\"");
  3323. }
  3324. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  3325. static void CheckFormatError(FormatError error)
  3326. {
  3327. if (error != FormatError.None)
  3328. throw new ArgumentException("Source is too long to fit into fixed string of this size");
  3329. }
  3330. }
  3331. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  3332. // However, only the first element of data members with names is copied at this time.
  3333. // Therefore, it's important that all data visible in the debugger, has a name
  3334. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  3335. /// <summary>
  3336. /// For internal use only.
  3337. /// </summary>
  3338. [Serializable]
  3339. [StructLayout(LayoutKind.Explicit, Size=126)]
  3340. [GenerateTestsForBurstCompatibility]
  3341. public struct FixedBytes126
  3342. {
  3343. /// <summary>
  3344. /// For internal use only.
  3345. /// </summary>
  3346. [FieldOffset(0)] public FixedBytes16 offset0000;
  3347. /// <summary>
  3348. /// For internal use only.
  3349. /// </summary>
  3350. [FieldOffset(16)] public FixedBytes16 offset0016;
  3351. /// <summary>
  3352. /// For internal use only.
  3353. /// </summary>
  3354. [FieldOffset(32)] public FixedBytes16 offset0032;
  3355. /// <summary>
  3356. /// For internal use only.
  3357. /// </summary>
  3358. [FieldOffset(48)] public FixedBytes16 offset0048;
  3359. /// <summary>
  3360. /// For internal use only.
  3361. /// </summary>
  3362. [FieldOffset(64)] public FixedBytes16 offset0064;
  3363. /// <summary>
  3364. /// For internal use only.
  3365. /// </summary>
  3366. [FieldOffset(80)] public FixedBytes16 offset0080;
  3367. /// <summary>
  3368. /// For internal use only.
  3369. /// </summary>
  3370. [FieldOffset(96)] public FixedBytes16 offset0096;
  3371. /// <summary>
  3372. /// For internal use only.
  3373. /// </summary>
  3374. [FieldOffset(112)] public byte byte0112;
  3375. /// <summary>
  3376. /// For internal use only.
  3377. /// </summary>
  3378. [FieldOffset(113)] public byte byte0113;
  3379. /// <summary>
  3380. /// For internal use only.
  3381. /// </summary>
  3382. [FieldOffset(114)] public byte byte0114;
  3383. /// <summary>
  3384. /// For internal use only.
  3385. /// </summary>
  3386. [FieldOffset(115)] public byte byte0115;
  3387. /// <summary>
  3388. /// For internal use only.
  3389. /// </summary>
  3390. [FieldOffset(116)] public byte byte0116;
  3391. /// <summary>
  3392. /// For internal use only.
  3393. /// </summary>
  3394. [FieldOffset(117)] public byte byte0117;
  3395. /// <summary>
  3396. /// For internal use only.
  3397. /// </summary>
  3398. [FieldOffset(118)] public byte byte0118;
  3399. /// <summary>
  3400. /// For internal use only.
  3401. /// </summary>
  3402. [FieldOffset(119)] public byte byte0119;
  3403. /// <summary>
  3404. /// For internal use only.
  3405. /// </summary>
  3406. [FieldOffset(120)] public byte byte0120;
  3407. /// <summary>
  3408. /// For internal use only.
  3409. /// </summary>
  3410. [FieldOffset(121)] public byte byte0121;
  3411. /// <summary>
  3412. /// For internal use only.
  3413. /// </summary>
  3414. [FieldOffset(122)] public byte byte0122;
  3415. /// <summary>
  3416. /// For internal use only.
  3417. /// </summary>
  3418. [FieldOffset(123)] public byte byte0123;
  3419. /// <summary>
  3420. /// For internal use only.
  3421. /// </summary>
  3422. [FieldOffset(124)] public byte byte0124;
  3423. /// <summary>
  3424. /// For internal use only.
  3425. /// </summary>
  3426. [FieldOffset(125)] public byte byte0125;
  3427. }
  3428. /// <summary>
  3429. /// An unmanaged UTF-8 string whose content is stored directly in the 128-byte struct.
  3430. /// </summary>
  3431. /// <remarks>
  3432. /// The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer)
  3433. /// followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character.
  3434. /// Effectively, the number of bytes for storing characters is 3 less than 128 (two length bytes and one null byte).
  3435. ///
  3436. /// This layout is identical to a <see cref="FixedList128Bytes{T}"/> of bytes, thus allowing reinterpretation between FixedString128Bytes and FixedList128Bytes.
  3437. ///
  3438. /// By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation.
  3439. /// Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.
  3440. /// </remarks>
  3441. [Serializable]
  3442. [StructLayout(LayoutKind.Sequential, Size=128)]
  3443. [GenerateTestsForBurstCompatibility]
  3444. public partial struct FixedString128Bytes
  3445. : INativeList<byte>
  3446. , IUTF8Bytes
  3447. , IComparable<String>
  3448. , IEquatable<String>
  3449. , IComparable<FixedString32Bytes>
  3450. , IEquatable<FixedString32Bytes>
  3451. , IComparable<FixedString64Bytes>
  3452. , IEquatable<FixedString64Bytes>
  3453. , IComparable<FixedString128Bytes>
  3454. , IEquatable<FixedString128Bytes>
  3455. , IComparable<FixedString512Bytes>
  3456. , IEquatable<FixedString512Bytes>
  3457. , IComparable<FixedString4096Bytes>
  3458. , IEquatable<FixedString4096Bytes>
  3459. {
  3460. internal const ushort utf8MaxLengthInBytes = 125;
  3461. [SerializeField] internal ushort utf8LengthInBytes;
  3462. [SerializeField] internal FixedBytes126 bytes;
  3463. /// <summary>
  3464. /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
  3465. /// </summary>
  3466. /// <returns>
  3467. /// The maximum number of UTF-8 bytes that can be stored in this string.
  3468. /// </returns>
  3469. public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
  3470. /// <summary>
  3471. /// For internal use only. Use <see cref="ToString"/> instead.
  3472. /// </summary>
  3473. /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
  3474. [CreateProperty]
  3475. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  3476. [ExcludeFromBurstCompatTesting("Returns managed string")]
  3477. public string Value => ToString();
  3478. /// <summary>
  3479. /// Returns a pointer to the character bytes.
  3480. /// </summary>
  3481. /// <remarks>
  3482. /// The pointer returned by this method points into the internals of the target FixedString object. It is the
  3483. /// caller's responsibility to ensure that the pointer is not used after the FixedString object is destroyed or goes
  3484. /// out of scope.
  3485. /// </remarks>
  3486. /// <returns>A pointer to the character bytes.</returns>
  3487. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3488. public readonly unsafe byte* GetUnsafePtr()
  3489. {
  3490. fixed(void* b = &bytes)
  3491. return (byte*)b;
  3492. }
  3493. /// <summary>
  3494. /// The current length in bytes of this string's content.
  3495. /// </summary>
  3496. /// <remarks>
  3497. /// The length value does not include the null-terminator byte.
  3498. /// </remarks>
  3499. /// <param name="value">The new length in bytes of the string's content.</param>
  3500. /// <exception cref="ArgumentOutOfRangeException">Thrown if the new length is out of bounds.</exception>
  3501. /// <value>
  3502. /// The current length in bytes of this string's content.
  3503. /// </value>
  3504. public int Length
  3505. {
  3506. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3507. readonly get
  3508. {
  3509. return utf8LengthInBytes;
  3510. }
  3511. set
  3512. {
  3513. CheckLengthInRange(value);
  3514. utf8LengthInBytes = (ushort)value;
  3515. unsafe
  3516. {
  3517. GetUnsafePtr()[utf8LengthInBytes] = 0;
  3518. }
  3519. }
  3520. }
  3521. /// <summary>
  3522. /// The number of bytes this string has for storing UTF-8 characters.
  3523. /// </summary>
  3524. /// <value>The number of bytes this string has for storing UTF-8 characters.</value>
  3525. /// <remarks>
  3526. /// Does not include the null-terminator byte.
  3527. ///
  3528. /// A setter is included for conformity with <see cref="INativeList{T}"/>, but <see cref="Capacity"/> is fixed at 125.
  3529. /// Setting the value to anything other than 125 throws an exception.
  3530. ///
  3531. /// In UTF-8 encoding, each Unicode code point (character) requires 1 to 4 bytes,
  3532. /// so the number of characters that can be stored may be less than the capacity.
  3533. /// </remarks>
  3534. /// <exception cref="ArgumentOutOfRangeException">Thrown if attempting to set the capacity to anything other than 125.</exception>
  3535. public int Capacity
  3536. {
  3537. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3538. readonly get
  3539. {
  3540. return utf8MaxLengthInBytes;
  3541. }
  3542. set
  3543. {
  3544. CheckCapacityInRange(value);
  3545. }
  3546. }
  3547. /// <summary>
  3548. /// Attempts to set the length in bytes. Does nothing if the new length is invalid.
  3549. /// </summary>
  3550. /// <param name="newLength">The desired length.</param>
  3551. /// <param name="clearOptions">Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)</param>
  3552. /// <returns>True if the new length is valid.</returns>
  3553. public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
  3554. {
  3555. if (newLength < 0 || newLength > utf8MaxLengthInBytes)
  3556. return false;
  3557. if (newLength == utf8LengthInBytes)
  3558. return true;
  3559. unsafe
  3560. {
  3561. if (clearOptions == NativeArrayOptions.ClearMemory)
  3562. {
  3563. if (newLength > utf8LengthInBytes)
  3564. UnsafeUtility.MemClear(GetUnsafePtr() + utf8LengthInBytes, newLength - utf8LengthInBytes);
  3565. else
  3566. UnsafeUtility.MemClear(GetUnsafePtr() + newLength, utf8LengthInBytes - newLength);
  3567. }
  3568. utf8LengthInBytes = (ushort)newLength;
  3569. // always null terminate
  3570. GetUnsafePtr()[utf8LengthInBytes] = 0;
  3571. }
  3572. return true;
  3573. }
  3574. /// <summary>
  3575. /// Returns true if this string is empty (has no characters).
  3576. /// </summary>
  3577. /// <value>True if this string is empty (has no characters).</value>
  3578. public readonly bool IsEmpty
  3579. {
  3580. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3581. get => utf8LengthInBytes == 0;
  3582. }
  3583. /// <summary>
  3584. /// Returns the byte (not character) at an index.
  3585. /// </summary>
  3586. /// <param name="index">A byte index.</param>
  3587. /// <value>The byte at the index.</value>
  3588. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  3589. public byte this[int index]
  3590. {
  3591. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3592. readonly get
  3593. {
  3594. unsafe
  3595. {
  3596. CheckIndexInRange(index);
  3597. return GetUnsafePtr()[index];
  3598. }
  3599. }
  3600. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3601. set
  3602. {
  3603. unsafe
  3604. {
  3605. CheckIndexInRange(index);
  3606. GetUnsafePtr()[index] = value;
  3607. }
  3608. }
  3609. }
  3610. /// <summary>
  3611. /// Returns the reference to a byte (not character) at an index.
  3612. /// </summary>
  3613. /// <param name="index">A byte index.</param>
  3614. /// <returns>A reference to the byte at the index.</returns>
  3615. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  3616. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3617. public ref byte ElementAt(int index)
  3618. {
  3619. unsafe
  3620. {
  3621. CheckIndexInRange(index);
  3622. return ref GetUnsafePtr()[index];
  3623. }
  3624. }
  3625. /// <summary>
  3626. /// Sets the length to 0.
  3627. /// </summary>
  3628. public void Clear()
  3629. {
  3630. Length = 0;
  3631. }
  3632. /// <summary>
  3633. /// Appends a byte.
  3634. /// </summary>
  3635. /// <remarks>
  3636. /// A zero byte will always follow the newly appended byte.
  3637. ///
  3638. /// No validation is performed: it is your responsibility for the bytes of the string to form valid UTF-8 when you're done appending bytes.
  3639. /// </remarks>
  3640. /// <param name="value">A byte to append.</param>
  3641. public void Add(in byte value)
  3642. {
  3643. this[Length++] = value;
  3644. }
  3645. /// <summary>
  3646. /// An enumerator over the characters (not bytes) of a FixedString128Bytes.
  3647. /// </summary>
  3648. /// <remarks>
  3649. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  3650. /// The first <see cref="MoveNext"/> call advances the enumerator's index to the first character.
  3651. /// </remarks>
  3652. public struct Enumerator : IEnumerator
  3653. {
  3654. FixedString128Bytes target;
  3655. int offset;
  3656. Unicode.Rune current;
  3657. /// <summary>
  3658. /// Initializes and returns an instance of FixedString128Bytes.Enumerator.
  3659. /// </summary>
  3660. /// <param name="other">A FixeString128 for which to create an enumerator.</param>
  3661. public Enumerator(FixedString128Bytes other)
  3662. {
  3663. target = other;
  3664. offset = 0;
  3665. current = default;
  3666. }
  3667. /// <summary>
  3668. /// Does nothing.
  3669. /// </summary>
  3670. public void Dispose()
  3671. {
  3672. }
  3673. /// <summary>
  3674. /// Advances the enumerator to the next character.
  3675. /// </summary>
  3676. /// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
  3677. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3678. public bool MoveNext()
  3679. {
  3680. if (offset >= target.Length)
  3681. return false;
  3682. unsafe
  3683. {
  3684. Unicode.Utf8ToUcs(out current, target.GetUnsafePtr(), ref offset, target.Length);
  3685. }
  3686. return true;
  3687. }
  3688. /// <summary>
  3689. /// Resets the enumerator to its initial state.
  3690. /// </summary>
  3691. public void Reset()
  3692. {
  3693. offset = 0;
  3694. current = default;
  3695. }
  3696. /// <summary>
  3697. /// The current character.
  3698. /// </summary>
  3699. /// <remarks>
  3700. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  3701. /// </remarks>
  3702. /// <value>The current character.</value>
  3703. public Unicode.Rune Current
  3704. {
  3705. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3706. get => current;
  3707. }
  3708. object IEnumerator.Current => Current;
  3709. }
  3710. /// <summary>
  3711. /// Returns an enumerator for iterating over the characters of this string.
  3712. /// </summary>
  3713. /// <returns>An enumerator for iterating over the characters of the FixedString128Bytes.</returns>
  3714. public Enumerator GetEnumerator()
  3715. {
  3716. return new Enumerator(this);
  3717. }
  3718. /// <summary>
  3719. /// Returns the lexicographical sort order of this string relative to another.
  3720. /// </summary>
  3721. /// <param name="other">A `System.String` to compare with.</param>
  3722. /// <returns>An integer denoting the lexicographical sort order of this string relative to the other:
  3723. ///
  3724. /// 0 denotes both strings have the same sort position.<br/>
  3725. /// -1 denotes that this string should be sorted to precede the other string.<br/>
  3726. /// +1 denotes that this string should be sorted to follow the other string.<br/>
  3727. /// </returns>
  3728. [ExcludeFromBurstCompatTesting("Takes managed string")]
  3729. public int CompareTo(String other)
  3730. {
  3731. return ToString().CompareTo(other);
  3732. }
  3733. /// <summary>
  3734. /// Returns true if this string and another have the same length and all the same characters.
  3735. /// </summary>
  3736. /// <param name="other">A string to compare for equality.</param>
  3737. /// <returns>True if this string and the other have the same length and all the same characters.</returns>
  3738. [ExcludeFromBurstCompatTesting("Takes managed string")]
  3739. public bool Equals(String other)
  3740. {
  3741. unsafe {
  3742. int alen = utf8LengthInBytes;
  3743. int blen = other.Length;
  3744. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(bytes);
  3745. fixed(char* bptr = other)
  3746. {
  3747. return UTF8ArrayUnsafeUtility.StrCmp(aptr, alen, bptr, blen) == 0;
  3748. }
  3749. }
  3750. }
  3751. /// <summary>
  3752. /// Returns a reference to a FixedList128Bytes&lt;byte&gt; representation of this string.
  3753. /// </summary>
  3754. /// <remarks>
  3755. /// The referenced FixedListByte128 is the very same bytes as the original FixedString128Bytes,
  3756. /// so it is only valid as long as the original FixedString128Bytes is valid.
  3757. /// </remarks>
  3758. /// <returns>A ref to a FixedListByte128 representation of the FixedString128Bytes.</returns>
  3759. public unsafe ref FixedList128Bytes<byte> AsFixedList()
  3760. {
  3761. return ref UnsafeUtility.AsRef<FixedList128Bytes<byte>>(UnsafeUtility.AddressOf(ref this));
  3762. }
  3763. /// <summary>
  3764. /// Initializes and returns an instance of FixedString128Bytes with the characters copied from a string.
  3765. /// </summary>
  3766. /// <param name="source">The source string to copy.</param>
  3767. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3768. [ExcludeFromBurstCompatTesting("Takes managed string")]
  3769. public FixedString128Bytes(String source)
  3770. {
  3771. this = default;
  3772. var error = Initialize(source);
  3773. CheckCopyError(error, source);
  3774. }
  3775. /// <summary>
  3776. /// Initializes an instance of FixedString128Bytes with the characters copied from a string.
  3777. /// </summary>
  3778. /// <param name="source">The source string to copy.</param>
  3779. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, only the portion that fits is copied in and CopyError.Truncation is returned.</returns>
  3780. [ExcludeFromBurstCompatTesting("Takes managed string")]
  3781. internal CopyError Initialize(String source)
  3782. {
  3783. return this.CopyFromTruncated(source);
  3784. }
  3785. /// <summary>
  3786. /// Initializes and returns an instance of FixedString128Bytes with a single character repeatedly appended some number of times.
  3787. /// </summary>
  3788. /// <param name="rune">The Unicode.Rune to repeat.</param>
  3789. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  3790. public FixedString128Bytes(Unicode.Rune rune, int count = 1)
  3791. {
  3792. this = default;
  3793. Initialize(rune, count);
  3794. }
  3795. /// <summary>
  3796. /// Initializes an instance of FixedString128Bytes with a single character repeatedly appended some number of times.
  3797. /// </summary>
  3798. /// <param name="rune">The Unicode.Rune to repeat.</param>
  3799. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  3800. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3801. internal FormatError Initialize(Unicode.Rune rune, int count = 1)
  3802. {
  3803. this = default;
  3804. return this.Append(rune, count);
  3805. }
  3806. /// <summary>
  3807. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  3808. /// </summary>
  3809. /// <param name="srcBytes">The source buffer.</param>
  3810. /// <param name="srcLength">The number of bytes to read from the source.</param>
  3811. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3812. unsafe internal FormatError Initialize(byte* srcBytes, int srcLength)
  3813. {
  3814. bytes = default;
  3815. utf8LengthInBytes = 0;
  3816. unsafe {
  3817. int len = 0;
  3818. byte* dstBytes = GetUnsafePtr();
  3819. var error = UTF8ArrayUnsafeUtility.AppendUTF8Bytes(dstBytes, ref len, utf8MaxLengthInBytes, srcBytes, srcLength);
  3820. if(error != FormatError.None)
  3821. return error;
  3822. this.Length = len;
  3823. }
  3824. return FormatError.None;
  3825. }
  3826. /// <summary>
  3827. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  3828. /// </summary>
  3829. /// <param name="other">The string to copy.</param>
  3830. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3831. unsafe public FixedString128Bytes(NativeText.ReadOnly other)
  3832. {
  3833. this = default;
  3834. var error = Initialize(other.GetUnsafePtr(), other.Length);
  3835. CheckFormatError(error);
  3836. }
  3837. /// <summary>
  3838. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  3839. /// </summary>
  3840. /// <param name="other">The UnsafeText to copy.</param>
  3841. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3842. unsafe public FixedString128Bytes(in UnsafeText other)
  3843. {
  3844. this = default;
  3845. var error = Initialize(other.GetUnsafePtr(), other.Length);
  3846. CheckFormatError(error);
  3847. }
  3848. /// <summary>
  3849. /// Returns the lexicographical sort order of this string relative to another.
  3850. /// </summary>
  3851. /// <param name="other">A string to compare with.</param>
  3852. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3853. ///
  3854. /// 0 denotes that both strings have the same sort position.<br/>
  3855. /// -1 denotes that this string should be sorted to precede the other.<br/>
  3856. /// +1 denotes that this string should be sorted to follow the other.<br/>
  3857. /// </returns>
  3858. public int CompareTo(FixedString32Bytes other)
  3859. {
  3860. return FixedStringMethods.CompareTo(ref this, other);
  3861. }
  3862. /// <summary>
  3863. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  3864. /// </summary>
  3865. /// <param name="other">The string to copy.</param>
  3866. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3867. public FixedString128Bytes(in FixedString32Bytes other)
  3868. {
  3869. this = default;
  3870. var error = Initialize(other);
  3871. CheckFormatError(error);
  3872. }
  3873. /// <summary>
  3874. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  3875. /// </summary>
  3876. /// <param name="other">The string to copy.</param>
  3877. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3878. unsafe internal FormatError Initialize(in FixedString32Bytes other)
  3879. {
  3880. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  3881. }
  3882. /// <summary>
  3883. /// Returns true if a FixedString128Bytes and another string are equal.
  3884. /// </summary>
  3885. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3886. /// <param name="a">A FixedString128Bytes to compare for equality.</param>
  3887. /// <param name="b">A FixedString32Bytes to compare for equality.</param>
  3888. /// <returns>True if the two strings are equal.</returns>
  3889. public static bool operator ==(in FixedString128Bytes a, in FixedString32Bytes b)
  3890. {
  3891. // this must not call any methods on 'a' or 'b'
  3892. unsafe {
  3893. int alen = a.utf8LengthInBytes;
  3894. int blen = b.utf8LengthInBytes;
  3895. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  3896. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  3897. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  3898. }
  3899. }
  3900. /// <summary>
  3901. /// Returns true if a FixedString128Bytes and another string are unequal.
  3902. /// </summary>
  3903. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3904. /// <param name="a">A FixedString128Bytes to compare for inequality.</param>
  3905. /// <param name="b">A FixedString32Bytes to compare for inequality.</param>
  3906. /// <returns>True if the two strings are unequal.</returns>
  3907. public static bool operator !=(in FixedString128Bytes a, in FixedString32Bytes b)
  3908. {
  3909. return !(a == b);
  3910. }
  3911. /// <summary>
  3912. /// Returns true if this string and another string are equal.
  3913. /// </summary>
  3914. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3915. /// <param name="other">A FixedString32Bytes to compare for equality.</param>
  3916. /// <returns>True if the two strings are equal.</returns>
  3917. public bool Equals(FixedString32Bytes other)
  3918. {
  3919. return this == other;
  3920. }
  3921. /// <summary>
  3922. /// Returns the lexicographical sort order of this string relative to another.
  3923. /// </summary>
  3924. /// <param name="other">A string to compare with.</param>
  3925. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3926. ///
  3927. /// 0 denotes that both strings have the same sort position.<br/>
  3928. /// -1 denotes that this string should be sorted to precede the other.<br/>
  3929. /// +1 denotes that this string should be sorted to follow the other.<br/>
  3930. /// </returns>
  3931. public int CompareTo(FixedString64Bytes other)
  3932. {
  3933. return FixedStringMethods.CompareTo(ref this, other);
  3934. }
  3935. /// <summary>
  3936. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  3937. /// </summary>
  3938. /// <param name="other">The string to copy.</param>
  3939. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  3940. public FixedString128Bytes(in FixedString64Bytes other)
  3941. {
  3942. this = default;
  3943. var error = Initialize(other);
  3944. CheckFormatError(error);
  3945. }
  3946. /// <summary>
  3947. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  3948. /// </summary>
  3949. /// <param name="other">The string to copy.</param>
  3950. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  3951. unsafe internal FormatError Initialize(in FixedString64Bytes other)
  3952. {
  3953. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  3954. }
  3955. /// <summary>
  3956. /// Returns true if a FixedString128Bytes and another string are equal.
  3957. /// </summary>
  3958. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3959. /// <param name="a">A FixedString128Bytes to compare for equality.</param>
  3960. /// <param name="b">A FixedString64Bytes to compare for equality.</param>
  3961. /// <returns>True if the two strings are equal.</returns>
  3962. public static bool operator ==(in FixedString128Bytes a, in FixedString64Bytes b)
  3963. {
  3964. // this must not call any methods on 'a' or 'b'
  3965. unsafe {
  3966. int alen = a.utf8LengthInBytes;
  3967. int blen = b.utf8LengthInBytes;
  3968. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  3969. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  3970. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  3971. }
  3972. }
  3973. /// <summary>
  3974. /// Returns true if a FixedString128Bytes and another string are unequal.
  3975. /// </summary>
  3976. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3977. /// <param name="a">A FixedString128Bytes to compare for inequality.</param>
  3978. /// <param name="b">A FixedString64Bytes to compare for inequality.</param>
  3979. /// <returns>True if the two strings are unequal.</returns>
  3980. public static bool operator !=(in FixedString128Bytes a, in FixedString64Bytes b)
  3981. {
  3982. return !(a == b);
  3983. }
  3984. /// <summary>
  3985. /// Returns true if this string and another string are equal.
  3986. /// </summary>
  3987. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  3988. /// <param name="other">A FixedString64Bytes to compare for equality.</param>
  3989. /// <returns>True if the two strings are equal.</returns>
  3990. public bool Equals(FixedString64Bytes other)
  3991. {
  3992. return this == other;
  3993. }
  3994. /// <summary>
  3995. /// Returns the lexicographical sort order of this string relative to another.
  3996. /// </summary>
  3997. /// <param name="other">A string to compare with.</param>
  3998. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  3999. ///
  4000. /// 0 denotes that both strings have the same sort position.<br/>
  4001. /// -1 denotes that this string should be sorted to precede the other.<br/>
  4002. /// +1 denotes that this string should be sorted to follow the other.<br/>
  4003. /// </returns>
  4004. public int CompareTo(FixedString128Bytes other)
  4005. {
  4006. return FixedStringMethods.CompareTo(ref this, other);
  4007. }
  4008. /// <summary>
  4009. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  4010. /// </summary>
  4011. /// <param name="other">The string to copy.</param>
  4012. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  4013. public FixedString128Bytes(in FixedString128Bytes other)
  4014. {
  4015. this = default;
  4016. var error = Initialize(other);
  4017. CheckFormatError(error);
  4018. }
  4019. /// <summary>
  4020. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  4021. /// </summary>
  4022. /// <param name="other">The string to copy.</param>
  4023. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4024. unsafe internal FormatError Initialize(in FixedString128Bytes other)
  4025. {
  4026. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  4027. }
  4028. /// <summary>
  4029. /// Returns true if a FixedString128Bytes and another string are equal.
  4030. /// </summary>
  4031. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4032. /// <param name="a">A FixedString128Bytes to compare for equality.</param>
  4033. /// <param name="b">A FixedString128Bytes to compare for equality.</param>
  4034. /// <returns>True if the two strings are equal.</returns>
  4035. public static bool operator ==(in FixedString128Bytes a, in FixedString128Bytes b)
  4036. {
  4037. // this must not call any methods on 'a' or 'b'
  4038. unsafe {
  4039. int alen = a.utf8LengthInBytes;
  4040. int blen = b.utf8LengthInBytes;
  4041. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  4042. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  4043. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  4044. }
  4045. }
  4046. /// <summary>
  4047. /// Returns true if a FixedString128Bytes and another string are unequal.
  4048. /// </summary>
  4049. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4050. /// <param name="a">A FixedString128Bytes to compare for inequality.</param>
  4051. /// <param name="b">A FixedString128Bytes to compare for inequality.</param>
  4052. /// <returns>True if the two strings are unequal.</returns>
  4053. public static bool operator !=(in FixedString128Bytes a, in FixedString128Bytes b)
  4054. {
  4055. return !(a == b);
  4056. }
  4057. /// <summary>
  4058. /// Returns true if this string and another string are equal.
  4059. /// </summary>
  4060. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4061. /// <param name="other">A FixedString128Bytes to compare for equality.</param>
  4062. /// <returns>True if the two strings are equal.</returns>
  4063. public bool Equals(FixedString128Bytes other)
  4064. {
  4065. return this == other;
  4066. }
  4067. /// <summary>
  4068. /// Returns the lexicographical sort order of this string relative to another.
  4069. /// </summary>
  4070. /// <param name="other">A string to compare with.</param>
  4071. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  4072. ///
  4073. /// 0 denotes that both strings have the same sort position.<br/>
  4074. /// -1 denotes that this string should be sorted to precede the other.<br/>
  4075. /// +1 denotes that this string should be sorted to follow the other.<br/>
  4076. /// </returns>
  4077. public int CompareTo(FixedString512Bytes other)
  4078. {
  4079. return FixedStringMethods.CompareTo(ref this, other);
  4080. }
  4081. /// <summary>
  4082. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  4083. /// </summary>
  4084. /// <param name="other">The string to copy.</param>
  4085. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  4086. public FixedString128Bytes(in FixedString512Bytes other)
  4087. {
  4088. this = default;
  4089. var error = Initialize(other);
  4090. CheckFormatError(error);
  4091. }
  4092. /// <summary>
  4093. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  4094. /// </summary>
  4095. /// <param name="other">The string to copy.</param>
  4096. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4097. unsafe internal FormatError Initialize(in FixedString512Bytes other)
  4098. {
  4099. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  4100. }
  4101. /// <summary>
  4102. /// Returns true if a FixedString128Bytes and another string are equal.
  4103. /// </summary>
  4104. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4105. /// <param name="a">A FixedString128Bytes to compare for equality.</param>
  4106. /// <param name="b">A FixedString512Bytes to compare for equality.</param>
  4107. /// <returns>True if the two strings are equal.</returns>
  4108. public static bool operator ==(in FixedString128Bytes a, in FixedString512Bytes b)
  4109. {
  4110. // this must not call any methods on 'a' or 'b'
  4111. unsafe {
  4112. int alen = a.utf8LengthInBytes;
  4113. int blen = b.utf8LengthInBytes;
  4114. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  4115. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  4116. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  4117. }
  4118. }
  4119. /// <summary>
  4120. /// Returns true if a FixedString128Bytes and another string are unequal.
  4121. /// </summary>
  4122. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4123. /// <param name="a">A FixedString128Bytes to compare for inequality.</param>
  4124. /// <param name="b">A FixedString512Bytes to compare for inequality.</param>
  4125. /// <returns>True if the two strings are unequal.</returns>
  4126. public static bool operator !=(in FixedString128Bytes a, in FixedString512Bytes b)
  4127. {
  4128. return !(a == b);
  4129. }
  4130. /// <summary>
  4131. /// Returns true if this string and another string are equal.
  4132. /// </summary>
  4133. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4134. /// <param name="other">A FixedString512Bytes to compare for equality.</param>
  4135. /// <returns>True if the two strings are equal.</returns>
  4136. public bool Equals(FixedString512Bytes other)
  4137. {
  4138. return this == other;
  4139. }
  4140. /// <summary>
  4141. /// Returns a new FixedString512Bytes that is a copy of another string.
  4142. /// </summary>
  4143. /// <param name="fs">A FixedString128Bytes to copy.</param>
  4144. /// <returns>A new FixedString512Bytes that is a copy of the other string.</returns>
  4145. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  4146. public static implicit operator FixedString512Bytes(in FixedString128Bytes fs) => new FixedString512Bytes(in fs);
  4147. /// <summary>
  4148. /// Returns the lexicographical sort order of this string relative to another.
  4149. /// </summary>
  4150. /// <param name="other">A string to compare with.</param>
  4151. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  4152. ///
  4153. /// 0 denotes that both strings have the same sort position.<br/>
  4154. /// -1 denotes that this string should be sorted to precede the other.<br/>
  4155. /// +1 denotes that this string should be sorted to follow the other.<br/>
  4156. /// </returns>
  4157. public int CompareTo(FixedString4096Bytes other)
  4158. {
  4159. return FixedStringMethods.CompareTo(ref this, other);
  4160. }
  4161. /// <summary>
  4162. /// Initializes and returns an instance of FixedString128Bytes that is a copy of another string.
  4163. /// </summary>
  4164. /// <param name="other">The string to copy.</param>
  4165. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  4166. public FixedString128Bytes(in FixedString4096Bytes other)
  4167. {
  4168. this = default;
  4169. var error = Initialize(other);
  4170. CheckFormatError(error);
  4171. }
  4172. /// <summary>
  4173. /// Initializes an instance of FixedString128Bytes that is a copy of another string.
  4174. /// </summary>
  4175. /// <param name="other">The string to copy.</param>
  4176. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4177. unsafe internal FormatError Initialize(in FixedString4096Bytes other)
  4178. {
  4179. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  4180. }
  4181. /// <summary>
  4182. /// Returns true if a FixedString128Bytes and another string are equal.
  4183. /// </summary>
  4184. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4185. /// <param name="a">A FixedString128Bytes to compare for equality.</param>
  4186. /// <param name="b">A FixedString4096Bytes to compare for equality.</param>
  4187. /// <returns>True if the two strings are equal.</returns>
  4188. public static bool operator ==(in FixedString128Bytes a, in FixedString4096Bytes b)
  4189. {
  4190. // this must not call any methods on 'a' or 'b'
  4191. unsafe {
  4192. int alen = a.utf8LengthInBytes;
  4193. int blen = b.utf8LengthInBytes;
  4194. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  4195. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  4196. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  4197. }
  4198. }
  4199. /// <summary>
  4200. /// Returns true if a FixedString128Bytes and another string are unequal.
  4201. /// </summary>
  4202. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4203. /// <param name="a">A FixedString128Bytes to compare for inequality.</param>
  4204. /// <param name="b">A FixedString4096Bytes to compare for inequality.</param>
  4205. /// <returns>True if the two strings are unequal.</returns>
  4206. public static bool operator !=(in FixedString128Bytes a, in FixedString4096Bytes b)
  4207. {
  4208. return !(a == b);
  4209. }
  4210. /// <summary>
  4211. /// Returns true if this string and another string are equal.
  4212. /// </summary>
  4213. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4214. /// <param name="other">A FixedString4096Bytes to compare for equality.</param>
  4215. /// <returns>True if the two strings are equal.</returns>
  4216. public bool Equals(FixedString4096Bytes other)
  4217. {
  4218. return this == other;
  4219. }
  4220. /// <summary>
  4221. /// Returns a new FixedString4096Bytes that is a copy of another string.
  4222. /// </summary>
  4223. /// <param name="fs">A FixedString128Bytes to copy.</param>
  4224. /// <returns>A new FixedString4096Bytes that is a copy of the other string.</returns>
  4225. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  4226. public static implicit operator FixedString4096Bytes(in FixedString128Bytes fs) => new FixedString4096Bytes(in fs);
  4227. /// <summary>
  4228. /// Returns a new FixedString128Bytes that is a copy of another string.
  4229. /// </summary>
  4230. /// <param name="b">A string to copy.</param>
  4231. /// <returns>A new FixedString128Bytes that is a copy of another string.</returns>
  4232. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString128Bytes.</exception>
  4233. [ExcludeFromBurstCompatTesting("Takes managed string")]
  4234. public static implicit operator FixedString128Bytes(string b) => new FixedString128Bytes(b);
  4235. /// <summary>
  4236. /// Returns a new managed string that is a copy of this string.
  4237. /// </summary>
  4238. /// <returns>A new managed string that is a copy of this string.</returns>
  4239. [ExcludeFromBurstCompatTesting("Returns managed string")]
  4240. public override String ToString()
  4241. {
  4242. return this.ConvertToString();
  4243. }
  4244. /// <summary>
  4245. /// Returns a hash code of this string.
  4246. /// </summary>
  4247. /// <remarks>Only the character bytes are included in the hash: any bytes beyond <see cref="Length"/> are not part of the hash.</remarks>
  4248. /// <returns>The hash code of this string.</returns>
  4249. public override int GetHashCode()
  4250. {
  4251. return this.ComputeHashCode();
  4252. }
  4253. /// <summary>
  4254. /// Returns true if this string and an object are equal.
  4255. /// </summary>
  4256. /// <remarks>
  4257. /// Returns false if the object is neither a System.String or a FixedString.
  4258. ///
  4259. /// Two strings are equal if they have equal length and all their characters match.</remarks>
  4260. /// <param name="obj">An object to compare for equality.</param>
  4261. /// <returns>True if this string and the object are equal.</returns>
  4262. [ExcludeFromBurstCompatTesting("Takes managed object")]
  4263. public override bool Equals(object obj)
  4264. {
  4265. if(ReferenceEquals(null, obj)) return false;
  4266. if(obj is String aString) return Equals(aString);
  4267. if(obj is FixedString32Bytes aFixedString32Bytes) return Equals(aFixedString32Bytes);
  4268. if(obj is FixedString64Bytes aFixedString64Bytes) return Equals(aFixedString64Bytes);
  4269. if(obj is FixedString128Bytes aFixedString128Bytes) return Equals(aFixedString128Bytes);
  4270. if(obj is FixedString512Bytes aFixedString512Bytes) return Equals(aFixedString512Bytes);
  4271. if(obj is FixedString4096Bytes aFixedString4096Bytes) return Equals(aFixedString4096Bytes);
  4272. return false;
  4273. }
  4274. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  4275. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4276. readonly void CheckIndexInRange(int index)
  4277. {
  4278. if (index < 0)
  4279. throw new IndexOutOfRangeException($"Index {index} must be positive.");
  4280. if (index >= utf8LengthInBytes)
  4281. throw new IndexOutOfRangeException($"Index {index} is out of range in FixedString128Bytes of '{utf8LengthInBytes}' Length.");
  4282. }
  4283. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  4284. void CheckLengthInRange(int length)
  4285. {
  4286. if (length < 0)
  4287. throw new ArgumentOutOfRangeException($"Length {length} must be positive.");
  4288. if (length > utf8MaxLengthInBytes)
  4289. throw new ArgumentOutOfRangeException($"Length {length} is out of range in FixedString128Bytes of '{utf8MaxLengthInBytes}' Capacity.");
  4290. }
  4291. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  4292. void CheckCapacityInRange(int capacity)
  4293. {
  4294. if (capacity > utf8MaxLengthInBytes)
  4295. throw new ArgumentOutOfRangeException($"Capacity {capacity} must be lower than {utf8MaxLengthInBytes}.");
  4296. }
  4297. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  4298. static void CheckCopyError(CopyError error, String source)
  4299. {
  4300. if (error != CopyError.None)
  4301. throw new ArgumentException($"FixedString128Bytes: {error} while copying \"{source}\"");
  4302. }
  4303. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  4304. static void CheckFormatError(FormatError error)
  4305. {
  4306. if (error != FormatError.None)
  4307. throw new ArgumentException("Source is too long to fit into fixed string of this size");
  4308. }
  4309. }
  4310. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  4311. // However, only the first element of data members with names is copied at this time.
  4312. // Therefore, it's important that all data visible in the debugger, has a name
  4313. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  4314. /// <summary>
  4315. /// For internal use only.
  4316. /// </summary>
  4317. [Serializable]
  4318. [StructLayout(LayoutKind.Explicit, Size=510)]
  4319. [GenerateTestsForBurstCompatibility]
  4320. public struct FixedBytes510
  4321. {
  4322. /// <summary>
  4323. /// For internal use only.
  4324. /// </summary>
  4325. [FieldOffset(0)] public FixedBytes16 offset0000;
  4326. /// <summary>
  4327. /// For internal use only.
  4328. /// </summary>
  4329. [FieldOffset(16)] public FixedBytes16 offset0016;
  4330. /// <summary>
  4331. /// For internal use only.
  4332. /// </summary>
  4333. [FieldOffset(32)] public FixedBytes16 offset0032;
  4334. /// <summary>
  4335. /// For internal use only.
  4336. /// </summary>
  4337. [FieldOffset(48)] public FixedBytes16 offset0048;
  4338. /// <summary>
  4339. /// For internal use only.
  4340. /// </summary>
  4341. [FieldOffset(64)] public FixedBytes16 offset0064;
  4342. /// <summary>
  4343. /// For internal use only.
  4344. /// </summary>
  4345. [FieldOffset(80)] public FixedBytes16 offset0080;
  4346. /// <summary>
  4347. /// For internal use only.
  4348. /// </summary>
  4349. [FieldOffset(96)] public FixedBytes16 offset0096;
  4350. /// <summary>
  4351. /// For internal use only.
  4352. /// </summary>
  4353. [FieldOffset(112)] public FixedBytes16 offset0112;
  4354. /// <summary>
  4355. /// For internal use only.
  4356. /// </summary>
  4357. [FieldOffset(128)] public FixedBytes16 offset0128;
  4358. /// <summary>
  4359. /// For internal use only.
  4360. /// </summary>
  4361. [FieldOffset(144)] public FixedBytes16 offset0144;
  4362. /// <summary>
  4363. /// For internal use only.
  4364. /// </summary>
  4365. [FieldOffset(160)] public FixedBytes16 offset0160;
  4366. /// <summary>
  4367. /// For internal use only.
  4368. /// </summary>
  4369. [FieldOffset(176)] public FixedBytes16 offset0176;
  4370. /// <summary>
  4371. /// For internal use only.
  4372. /// </summary>
  4373. [FieldOffset(192)] public FixedBytes16 offset0192;
  4374. /// <summary>
  4375. /// For internal use only.
  4376. /// </summary>
  4377. [FieldOffset(208)] public FixedBytes16 offset0208;
  4378. /// <summary>
  4379. /// For internal use only.
  4380. /// </summary>
  4381. [FieldOffset(224)] public FixedBytes16 offset0224;
  4382. /// <summary>
  4383. /// For internal use only.
  4384. /// </summary>
  4385. [FieldOffset(240)] public FixedBytes16 offset0240;
  4386. /// <summary>
  4387. /// For internal use only.
  4388. /// </summary>
  4389. [FieldOffset(256)] public FixedBytes16 offset0256;
  4390. /// <summary>
  4391. /// For internal use only.
  4392. /// </summary>
  4393. [FieldOffset(272)] public FixedBytes16 offset0272;
  4394. /// <summary>
  4395. /// For internal use only.
  4396. /// </summary>
  4397. [FieldOffset(288)] public FixedBytes16 offset0288;
  4398. /// <summary>
  4399. /// For internal use only.
  4400. /// </summary>
  4401. [FieldOffset(304)] public FixedBytes16 offset0304;
  4402. /// <summary>
  4403. /// For internal use only.
  4404. /// </summary>
  4405. [FieldOffset(320)] public FixedBytes16 offset0320;
  4406. /// <summary>
  4407. /// For internal use only.
  4408. /// </summary>
  4409. [FieldOffset(336)] public FixedBytes16 offset0336;
  4410. /// <summary>
  4411. /// For internal use only.
  4412. /// </summary>
  4413. [FieldOffset(352)] public FixedBytes16 offset0352;
  4414. /// <summary>
  4415. /// For internal use only.
  4416. /// </summary>
  4417. [FieldOffset(368)] public FixedBytes16 offset0368;
  4418. /// <summary>
  4419. /// For internal use only.
  4420. /// </summary>
  4421. [FieldOffset(384)] public FixedBytes16 offset0384;
  4422. /// <summary>
  4423. /// For internal use only.
  4424. /// </summary>
  4425. [FieldOffset(400)] public FixedBytes16 offset0400;
  4426. /// <summary>
  4427. /// For internal use only.
  4428. /// </summary>
  4429. [FieldOffset(416)] public FixedBytes16 offset0416;
  4430. /// <summary>
  4431. /// For internal use only.
  4432. /// </summary>
  4433. [FieldOffset(432)] public FixedBytes16 offset0432;
  4434. /// <summary>
  4435. /// For internal use only.
  4436. /// </summary>
  4437. [FieldOffset(448)] public FixedBytes16 offset0448;
  4438. /// <summary>
  4439. /// For internal use only.
  4440. /// </summary>
  4441. [FieldOffset(464)] public FixedBytes16 offset0464;
  4442. /// <summary>
  4443. /// For internal use only.
  4444. /// </summary>
  4445. [FieldOffset(480)] public FixedBytes16 offset0480;
  4446. /// <summary>
  4447. /// For internal use only.
  4448. /// </summary>
  4449. [FieldOffset(496)] public byte byte0496;
  4450. /// <summary>
  4451. /// For internal use only.
  4452. /// </summary>
  4453. [FieldOffset(497)] public byte byte0497;
  4454. /// <summary>
  4455. /// For internal use only.
  4456. /// </summary>
  4457. [FieldOffset(498)] public byte byte0498;
  4458. /// <summary>
  4459. /// For internal use only.
  4460. /// </summary>
  4461. [FieldOffset(499)] public byte byte0499;
  4462. /// <summary>
  4463. /// For internal use only.
  4464. /// </summary>
  4465. [FieldOffset(500)] public byte byte0500;
  4466. /// <summary>
  4467. /// For internal use only.
  4468. /// </summary>
  4469. [FieldOffset(501)] public byte byte0501;
  4470. /// <summary>
  4471. /// For internal use only.
  4472. /// </summary>
  4473. [FieldOffset(502)] public byte byte0502;
  4474. /// <summary>
  4475. /// For internal use only.
  4476. /// </summary>
  4477. [FieldOffset(503)] public byte byte0503;
  4478. /// <summary>
  4479. /// For internal use only.
  4480. /// </summary>
  4481. [FieldOffset(504)] public byte byte0504;
  4482. /// <summary>
  4483. /// For internal use only.
  4484. /// </summary>
  4485. [FieldOffset(505)] public byte byte0505;
  4486. /// <summary>
  4487. /// For internal use only.
  4488. /// </summary>
  4489. [FieldOffset(506)] public byte byte0506;
  4490. /// <summary>
  4491. /// For internal use only.
  4492. /// </summary>
  4493. [FieldOffset(507)] public byte byte0507;
  4494. /// <summary>
  4495. /// For internal use only.
  4496. /// </summary>
  4497. [FieldOffset(508)] public byte byte0508;
  4498. /// <summary>
  4499. /// For internal use only.
  4500. /// </summary>
  4501. [FieldOffset(509)] public byte byte0509;
  4502. }
  4503. /// <summary>
  4504. /// An unmanaged UTF-8 string whose content is stored directly in the 512-byte struct.
  4505. /// </summary>
  4506. /// <remarks>
  4507. /// The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer)
  4508. /// followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character.
  4509. /// Effectively, the number of bytes for storing characters is 3 less than 512 (two length bytes and one null byte).
  4510. ///
  4511. /// This layout is identical to a <see cref="FixedList512Bytes{T}"/> of bytes, thus allowing reinterpretation between FixedString512Bytes and FixedList512Bytes.
  4512. ///
  4513. /// By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation.
  4514. /// Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.
  4515. /// </remarks>
  4516. [Serializable]
  4517. [StructLayout(LayoutKind.Sequential, Size=512)]
  4518. [GenerateTestsForBurstCompatibility]
  4519. public partial struct FixedString512Bytes
  4520. : INativeList<byte>
  4521. , IUTF8Bytes
  4522. , IComparable<String>
  4523. , IEquatable<String>
  4524. , IComparable<FixedString32Bytes>
  4525. , IEquatable<FixedString32Bytes>
  4526. , IComparable<FixedString64Bytes>
  4527. , IEquatable<FixedString64Bytes>
  4528. , IComparable<FixedString128Bytes>
  4529. , IEquatable<FixedString128Bytes>
  4530. , IComparable<FixedString512Bytes>
  4531. , IEquatable<FixedString512Bytes>
  4532. , IComparable<FixedString4096Bytes>
  4533. , IEquatable<FixedString4096Bytes>
  4534. {
  4535. internal const ushort utf8MaxLengthInBytes = 509;
  4536. [SerializeField] internal ushort utf8LengthInBytes;
  4537. [SerializeField] internal FixedBytes510 bytes;
  4538. /// <summary>
  4539. /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
  4540. /// </summary>
  4541. /// <returns>
  4542. /// The maximum number of UTF-8 bytes that can be stored in this string.
  4543. /// </returns>
  4544. public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
  4545. /// <summary>
  4546. /// For internal use only. Use <see cref="ToString"/> instead.
  4547. /// </summary>
  4548. /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
  4549. [CreateProperty]
  4550. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  4551. [ExcludeFromBurstCompatTesting("Returns managed string")]
  4552. public string Value => ToString();
  4553. /// <summary>
  4554. /// Returns a pointer to the character bytes.
  4555. /// </summary>
  4556. /// <remarks>
  4557. /// The pointer returned by this method points into the internals of the target FixedString object. It is the
  4558. /// caller's responsibility to ensure that the pointer is not used after the FixedString object is destroyed or goes
  4559. /// out of scope.
  4560. /// </remarks>
  4561. /// <returns>A pointer to the character bytes.</returns>
  4562. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4563. public readonly unsafe byte* GetUnsafePtr()
  4564. {
  4565. fixed(void* b = &bytes)
  4566. return (byte*)b;
  4567. }
  4568. /// <summary>
  4569. /// The current length in bytes of this string's content.
  4570. /// </summary>
  4571. /// <remarks>
  4572. /// The length value does not include the null-terminator byte.
  4573. /// </remarks>
  4574. /// <param name="value">The new length in bytes of the string's content.</param>
  4575. /// <exception cref="ArgumentOutOfRangeException">Thrown if the new length is out of bounds.</exception>
  4576. /// <value>
  4577. /// The current length in bytes of this string's content.
  4578. /// </value>
  4579. public int Length
  4580. {
  4581. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4582. readonly get
  4583. {
  4584. return utf8LengthInBytes;
  4585. }
  4586. set
  4587. {
  4588. CheckLengthInRange(value);
  4589. utf8LengthInBytes = (ushort)value;
  4590. unsafe
  4591. {
  4592. GetUnsafePtr()[utf8LengthInBytes] = 0;
  4593. }
  4594. }
  4595. }
  4596. /// <summary>
  4597. /// The number of bytes this string has for storing UTF-8 characters.
  4598. /// </summary>
  4599. /// <value>The number of bytes this string has for storing UTF-8 characters.</value>
  4600. /// <remarks>
  4601. /// Does not include the null-terminator byte.
  4602. ///
  4603. /// A setter is included for conformity with <see cref="INativeList{T}"/>, but <see cref="Capacity"/> is fixed at 509.
  4604. /// Setting the value to anything other than 509 throws an exception.
  4605. ///
  4606. /// In UTF-8 encoding, each Unicode code point (character) requires 1 to 4 bytes,
  4607. /// so the number of characters that can be stored may be less than the capacity.
  4608. /// </remarks>
  4609. /// <exception cref="ArgumentOutOfRangeException">Thrown if attempting to set the capacity to anything other than 509.</exception>
  4610. public int Capacity
  4611. {
  4612. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4613. readonly get
  4614. {
  4615. return utf8MaxLengthInBytes;
  4616. }
  4617. set
  4618. {
  4619. CheckCapacityInRange(value);
  4620. }
  4621. }
  4622. /// <summary>
  4623. /// Attempts to set the length in bytes. Does nothing if the new length is invalid.
  4624. /// </summary>
  4625. /// <param name="newLength">The desired length.</param>
  4626. /// <param name="clearOptions">Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)</param>
  4627. /// <returns>True if the new length is valid.</returns>
  4628. public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
  4629. {
  4630. if (newLength < 0 || newLength > utf8MaxLengthInBytes)
  4631. return false;
  4632. if (newLength == utf8LengthInBytes)
  4633. return true;
  4634. unsafe
  4635. {
  4636. if (clearOptions == NativeArrayOptions.ClearMemory)
  4637. {
  4638. if (newLength > utf8LengthInBytes)
  4639. UnsafeUtility.MemClear(GetUnsafePtr() + utf8LengthInBytes, newLength - utf8LengthInBytes);
  4640. else
  4641. UnsafeUtility.MemClear(GetUnsafePtr() + newLength, utf8LengthInBytes - newLength);
  4642. }
  4643. utf8LengthInBytes = (ushort)newLength;
  4644. // always null terminate
  4645. GetUnsafePtr()[utf8LengthInBytes] = 0;
  4646. }
  4647. return true;
  4648. }
  4649. /// <summary>
  4650. /// Returns true if this string is empty (has no characters).
  4651. /// </summary>
  4652. /// <value>True if this string is empty (has no characters).</value>
  4653. public readonly bool IsEmpty
  4654. {
  4655. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4656. get => utf8LengthInBytes == 0;
  4657. }
  4658. /// <summary>
  4659. /// Returns the byte (not character) at an index.
  4660. /// </summary>
  4661. /// <param name="index">A byte index.</param>
  4662. /// <value>The byte at the index.</value>
  4663. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  4664. public byte this[int index]
  4665. {
  4666. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4667. readonly get
  4668. {
  4669. unsafe
  4670. {
  4671. CheckIndexInRange(index);
  4672. return GetUnsafePtr()[index];
  4673. }
  4674. }
  4675. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4676. set
  4677. {
  4678. unsafe
  4679. {
  4680. CheckIndexInRange(index);
  4681. GetUnsafePtr()[index] = value;
  4682. }
  4683. }
  4684. }
  4685. /// <summary>
  4686. /// Returns the reference to a byte (not character) at an index.
  4687. /// </summary>
  4688. /// <param name="index">A byte index.</param>
  4689. /// <returns>A reference to the byte at the index.</returns>
  4690. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  4691. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4692. public ref byte ElementAt(int index)
  4693. {
  4694. unsafe
  4695. {
  4696. CheckIndexInRange(index);
  4697. return ref GetUnsafePtr()[index];
  4698. }
  4699. }
  4700. /// <summary>
  4701. /// Sets the length to 0.
  4702. /// </summary>
  4703. public void Clear()
  4704. {
  4705. Length = 0;
  4706. }
  4707. /// <summary>
  4708. /// Appends a byte.
  4709. /// </summary>
  4710. /// <remarks>
  4711. /// A zero byte will always follow the newly appended byte.
  4712. ///
  4713. /// No validation is performed: it is your responsibility for the bytes of the string to form valid UTF-8 when you're done appending bytes.
  4714. /// </remarks>
  4715. /// <param name="value">A byte to append.</param>
  4716. public void Add(in byte value)
  4717. {
  4718. this[Length++] = value;
  4719. }
  4720. /// <summary>
  4721. /// An enumerator over the characters (not bytes) of a FixedString512Bytes.
  4722. /// </summary>
  4723. /// <remarks>
  4724. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  4725. /// The first <see cref="MoveNext"/> call advances the enumerator's index to the first character.
  4726. /// </remarks>
  4727. public struct Enumerator : IEnumerator
  4728. {
  4729. FixedString512Bytes target;
  4730. int offset;
  4731. Unicode.Rune current;
  4732. /// <summary>
  4733. /// Initializes and returns an instance of FixedString512Bytes.Enumerator.
  4734. /// </summary>
  4735. /// <param name="other">A FixeString512 for which to create an enumerator.</param>
  4736. public Enumerator(FixedString512Bytes other)
  4737. {
  4738. target = other;
  4739. offset = 0;
  4740. current = default;
  4741. }
  4742. /// <summary>
  4743. /// Does nothing.
  4744. /// </summary>
  4745. public void Dispose()
  4746. {
  4747. }
  4748. /// <summary>
  4749. /// Advances the enumerator to the next character.
  4750. /// </summary>
  4751. /// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
  4752. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4753. public bool MoveNext()
  4754. {
  4755. if (offset >= target.Length)
  4756. return false;
  4757. unsafe
  4758. {
  4759. Unicode.Utf8ToUcs(out current, target.GetUnsafePtr(), ref offset, target.Length);
  4760. }
  4761. return true;
  4762. }
  4763. /// <summary>
  4764. /// Resets the enumerator to its initial state.
  4765. /// </summary>
  4766. public void Reset()
  4767. {
  4768. offset = 0;
  4769. current = default;
  4770. }
  4771. /// <summary>
  4772. /// The current character.
  4773. /// </summary>
  4774. /// <remarks>
  4775. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  4776. /// </remarks>
  4777. /// <value>The current character.</value>
  4778. public Unicode.Rune Current
  4779. {
  4780. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  4781. get => current;
  4782. }
  4783. object IEnumerator.Current => Current;
  4784. }
  4785. /// <summary>
  4786. /// Returns an enumerator for iterating over the characters of this string.
  4787. /// </summary>
  4788. /// <returns>An enumerator for iterating over the characters of the FixedString512Bytes.</returns>
  4789. public Enumerator GetEnumerator()
  4790. {
  4791. return new Enumerator(this);
  4792. }
  4793. /// <summary>
  4794. /// Returns the lexicographical sort order of this string relative to another.
  4795. /// </summary>
  4796. /// <param name="other">A `System.String` to compare with.</param>
  4797. /// <returns>An integer denoting the lexicographical sort order of this string relative to the other:
  4798. ///
  4799. /// 0 denotes both strings have the same sort position.<br/>
  4800. /// -1 denotes that this string should be sorted to precede the other string.<br/>
  4801. /// +1 denotes that this string should be sorted to follow the other string.<br/>
  4802. /// </returns>
  4803. [ExcludeFromBurstCompatTesting("Takes managed string")]
  4804. public int CompareTo(String other)
  4805. {
  4806. return ToString().CompareTo(other);
  4807. }
  4808. /// <summary>
  4809. /// Returns true if this string and another have the same length and all the same characters.
  4810. /// </summary>
  4811. /// <param name="other">A string to compare for equality.</param>
  4812. /// <returns>True if this string and the other have the same length and all the same characters.</returns>
  4813. [ExcludeFromBurstCompatTesting("Takes managed string")]
  4814. public bool Equals(String other)
  4815. {
  4816. unsafe {
  4817. int alen = utf8LengthInBytes;
  4818. int blen = other.Length;
  4819. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(bytes);
  4820. fixed(char* bptr = other)
  4821. {
  4822. return UTF8ArrayUnsafeUtility.StrCmp(aptr, alen, bptr, blen) == 0;
  4823. }
  4824. }
  4825. }
  4826. /// <summary>
  4827. /// Returns a reference to a FixedList512Bytes&lt;byte&gt; representation of this string.
  4828. /// </summary>
  4829. /// <remarks>
  4830. /// The referenced FixedListByte512 is the very same bytes as the original FixedString512Bytes,
  4831. /// so it is only valid as long as the original FixedString512Bytes is valid.
  4832. /// </remarks>
  4833. /// <returns>A ref to a FixedListByte512 representation of the FixedString512Bytes.</returns>
  4834. public unsafe ref FixedList512Bytes<byte> AsFixedList()
  4835. {
  4836. return ref UnsafeUtility.AsRef<FixedList512Bytes<byte>>(UnsafeUtility.AddressOf(ref this));
  4837. }
  4838. /// <summary>
  4839. /// Initializes and returns an instance of FixedString512Bytes with the characters copied from a string.
  4840. /// </summary>
  4841. /// <param name="source">The source string to copy.</param>
  4842. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  4843. [ExcludeFromBurstCompatTesting("Takes managed string")]
  4844. public FixedString512Bytes(String source)
  4845. {
  4846. this = default;
  4847. var error = Initialize(source);
  4848. CheckCopyError(error, source);
  4849. }
  4850. /// <summary>
  4851. /// Initializes an instance of FixedString512Bytes with the characters copied from a string.
  4852. /// </summary>
  4853. /// <param name="source">The source string to copy.</param>
  4854. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, only the portion that fits is copied in and CopyError.Truncation is returned.</returns>
  4855. [ExcludeFromBurstCompatTesting("Takes managed string")]
  4856. internal CopyError Initialize(String source)
  4857. {
  4858. return this.CopyFromTruncated(source);
  4859. }
  4860. /// <summary>
  4861. /// Initializes and returns an instance of FixedString512Bytes with a single character repeatedly appended some number of times.
  4862. /// </summary>
  4863. /// <param name="rune">The Unicode.Rune to repeat.</param>
  4864. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  4865. public FixedString512Bytes(Unicode.Rune rune, int count = 1)
  4866. {
  4867. this = default;
  4868. Initialize(rune, count);
  4869. }
  4870. /// <summary>
  4871. /// Initializes an instance of FixedString512Bytes with a single character repeatedly appended some number of times.
  4872. /// </summary>
  4873. /// <param name="rune">The Unicode.Rune to repeat.</param>
  4874. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  4875. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4876. internal FormatError Initialize(Unicode.Rune rune, int count = 1)
  4877. {
  4878. this = default;
  4879. return this.Append(rune, count);
  4880. }
  4881. /// <summary>
  4882. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  4883. /// </summary>
  4884. /// <param name="srcBytes">The source buffer.</param>
  4885. /// <param name="srcLength">The number of bytes to read from the source.</param>
  4886. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4887. unsafe internal FormatError Initialize(byte* srcBytes, int srcLength)
  4888. {
  4889. bytes = default;
  4890. utf8LengthInBytes = 0;
  4891. unsafe {
  4892. int len = 0;
  4893. byte* dstBytes = GetUnsafePtr();
  4894. var error = UTF8ArrayUnsafeUtility.AppendUTF8Bytes(dstBytes, ref len, utf8MaxLengthInBytes, srcBytes, srcLength);
  4895. if(error != FormatError.None)
  4896. return error;
  4897. this.Length = len;
  4898. }
  4899. return FormatError.None;
  4900. }
  4901. /// <summary>
  4902. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  4903. /// </summary>
  4904. /// <param name="other">The string to copy.</param>
  4905. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  4906. unsafe public FixedString512Bytes(NativeText.ReadOnly other)
  4907. {
  4908. this = default;
  4909. var error = Initialize(other.GetUnsafePtr(), other.Length);
  4910. CheckFormatError(error);
  4911. }
  4912. /// <summary>
  4913. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  4914. /// </summary>
  4915. /// <param name="other">The UnsafeText to copy.</param>
  4916. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  4917. unsafe public FixedString512Bytes(in UnsafeText other)
  4918. {
  4919. this = default;
  4920. var error = Initialize(other.GetUnsafePtr(), other.Length);
  4921. CheckFormatError(error);
  4922. }
  4923. /// <summary>
  4924. /// Returns the lexicographical sort order of this string relative to another.
  4925. /// </summary>
  4926. /// <param name="other">A string to compare with.</param>
  4927. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  4928. ///
  4929. /// 0 denotes that both strings have the same sort position.<br/>
  4930. /// -1 denotes that this string should be sorted to precede the other.<br/>
  4931. /// +1 denotes that this string should be sorted to follow the other.<br/>
  4932. /// </returns>
  4933. public int CompareTo(FixedString32Bytes other)
  4934. {
  4935. return FixedStringMethods.CompareTo(ref this, other);
  4936. }
  4937. /// <summary>
  4938. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  4939. /// </summary>
  4940. /// <param name="other">The string to copy.</param>
  4941. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  4942. public FixedString512Bytes(in FixedString32Bytes other)
  4943. {
  4944. this = default;
  4945. var error = Initialize(other);
  4946. CheckFormatError(error);
  4947. }
  4948. /// <summary>
  4949. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  4950. /// </summary>
  4951. /// <param name="other">The string to copy.</param>
  4952. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  4953. unsafe internal FormatError Initialize(in FixedString32Bytes other)
  4954. {
  4955. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  4956. }
  4957. /// <summary>
  4958. /// Returns true if a FixedString512Bytes and another string are equal.
  4959. /// </summary>
  4960. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4961. /// <param name="a">A FixedString512Bytes to compare for equality.</param>
  4962. /// <param name="b">A FixedString32Bytes to compare for equality.</param>
  4963. /// <returns>True if the two strings are equal.</returns>
  4964. public static bool operator ==(in FixedString512Bytes a, in FixedString32Bytes b)
  4965. {
  4966. // this must not call any methods on 'a' or 'b'
  4967. unsafe {
  4968. int alen = a.utf8LengthInBytes;
  4969. int blen = b.utf8LengthInBytes;
  4970. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  4971. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  4972. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  4973. }
  4974. }
  4975. /// <summary>
  4976. /// Returns true if a FixedString512Bytes and another string are unequal.
  4977. /// </summary>
  4978. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4979. /// <param name="a">A FixedString512Bytes to compare for inequality.</param>
  4980. /// <param name="b">A FixedString32Bytes to compare for inequality.</param>
  4981. /// <returns>True if the two strings are unequal.</returns>
  4982. public static bool operator !=(in FixedString512Bytes a, in FixedString32Bytes b)
  4983. {
  4984. return !(a == b);
  4985. }
  4986. /// <summary>
  4987. /// Returns true if this string and another string are equal.
  4988. /// </summary>
  4989. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  4990. /// <param name="other">A FixedString32Bytes to compare for equality.</param>
  4991. /// <returns>True if the two strings are equal.</returns>
  4992. public bool Equals(FixedString32Bytes other)
  4993. {
  4994. return this == other;
  4995. }
  4996. /// <summary>
  4997. /// Returns the lexicographical sort order of this string relative to another.
  4998. /// </summary>
  4999. /// <param name="other">A string to compare with.</param>
  5000. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  5001. ///
  5002. /// 0 denotes that both strings have the same sort position.<br/>
  5003. /// -1 denotes that this string should be sorted to precede the other.<br/>
  5004. /// +1 denotes that this string should be sorted to follow the other.<br/>
  5005. /// </returns>
  5006. public int CompareTo(FixedString64Bytes other)
  5007. {
  5008. return FixedStringMethods.CompareTo(ref this, other);
  5009. }
  5010. /// <summary>
  5011. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  5012. /// </summary>
  5013. /// <param name="other">The string to copy.</param>
  5014. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  5015. public FixedString512Bytes(in FixedString64Bytes other)
  5016. {
  5017. this = default;
  5018. var error = Initialize(other);
  5019. CheckFormatError(error);
  5020. }
  5021. /// <summary>
  5022. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  5023. /// </summary>
  5024. /// <param name="other">The string to copy.</param>
  5025. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  5026. unsafe internal FormatError Initialize(in FixedString64Bytes other)
  5027. {
  5028. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  5029. }
  5030. /// <summary>
  5031. /// Returns true if a FixedString512Bytes and another string are equal.
  5032. /// </summary>
  5033. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5034. /// <param name="a">A FixedString512Bytes to compare for equality.</param>
  5035. /// <param name="b">A FixedString64Bytes to compare for equality.</param>
  5036. /// <returns>True if the two strings are equal.</returns>
  5037. public static bool operator ==(in FixedString512Bytes a, in FixedString64Bytes b)
  5038. {
  5039. // this must not call any methods on 'a' or 'b'
  5040. unsafe {
  5041. int alen = a.utf8LengthInBytes;
  5042. int blen = b.utf8LengthInBytes;
  5043. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  5044. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  5045. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  5046. }
  5047. }
  5048. /// <summary>
  5049. /// Returns true if a FixedString512Bytes and another string are unequal.
  5050. /// </summary>
  5051. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5052. /// <param name="a">A FixedString512Bytes to compare for inequality.</param>
  5053. /// <param name="b">A FixedString64Bytes to compare for inequality.</param>
  5054. /// <returns>True if the two strings are unequal.</returns>
  5055. public static bool operator !=(in FixedString512Bytes a, in FixedString64Bytes b)
  5056. {
  5057. return !(a == b);
  5058. }
  5059. /// <summary>
  5060. /// Returns true if this string and another string are equal.
  5061. /// </summary>
  5062. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5063. /// <param name="other">A FixedString64Bytes to compare for equality.</param>
  5064. /// <returns>True if the two strings are equal.</returns>
  5065. public bool Equals(FixedString64Bytes other)
  5066. {
  5067. return this == other;
  5068. }
  5069. /// <summary>
  5070. /// Returns the lexicographical sort order of this string relative to another.
  5071. /// </summary>
  5072. /// <param name="other">A string to compare with.</param>
  5073. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  5074. ///
  5075. /// 0 denotes that both strings have the same sort position.<br/>
  5076. /// -1 denotes that this string should be sorted to precede the other.<br/>
  5077. /// +1 denotes that this string should be sorted to follow the other.<br/>
  5078. /// </returns>
  5079. public int CompareTo(FixedString128Bytes other)
  5080. {
  5081. return FixedStringMethods.CompareTo(ref this, other);
  5082. }
  5083. /// <summary>
  5084. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  5085. /// </summary>
  5086. /// <param name="other">The string to copy.</param>
  5087. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  5088. public FixedString512Bytes(in FixedString128Bytes other)
  5089. {
  5090. this = default;
  5091. var error = Initialize(other);
  5092. CheckFormatError(error);
  5093. }
  5094. /// <summary>
  5095. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  5096. /// </summary>
  5097. /// <param name="other">The string to copy.</param>
  5098. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  5099. unsafe internal FormatError Initialize(in FixedString128Bytes other)
  5100. {
  5101. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  5102. }
  5103. /// <summary>
  5104. /// Returns true if a FixedString512Bytes and another string are equal.
  5105. /// </summary>
  5106. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5107. /// <param name="a">A FixedString512Bytes to compare for equality.</param>
  5108. /// <param name="b">A FixedString128Bytes to compare for equality.</param>
  5109. /// <returns>True if the two strings are equal.</returns>
  5110. public static bool operator ==(in FixedString512Bytes a, in FixedString128Bytes b)
  5111. {
  5112. // this must not call any methods on 'a' or 'b'
  5113. unsafe {
  5114. int alen = a.utf8LengthInBytes;
  5115. int blen = b.utf8LengthInBytes;
  5116. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  5117. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  5118. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  5119. }
  5120. }
  5121. /// <summary>
  5122. /// Returns true if a FixedString512Bytes and another string are unequal.
  5123. /// </summary>
  5124. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5125. /// <param name="a">A FixedString512Bytes to compare for inequality.</param>
  5126. /// <param name="b">A FixedString128Bytes to compare for inequality.</param>
  5127. /// <returns>True if the two strings are unequal.</returns>
  5128. public static bool operator !=(in FixedString512Bytes a, in FixedString128Bytes b)
  5129. {
  5130. return !(a == b);
  5131. }
  5132. /// <summary>
  5133. /// Returns true if this string and another string are equal.
  5134. /// </summary>
  5135. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5136. /// <param name="other">A FixedString128Bytes to compare for equality.</param>
  5137. /// <returns>True if the two strings are equal.</returns>
  5138. public bool Equals(FixedString128Bytes other)
  5139. {
  5140. return this == other;
  5141. }
  5142. /// <summary>
  5143. /// Returns the lexicographical sort order of this string relative to another.
  5144. /// </summary>
  5145. /// <param name="other">A string to compare with.</param>
  5146. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  5147. ///
  5148. /// 0 denotes that both strings have the same sort position.<br/>
  5149. /// -1 denotes that this string should be sorted to precede the other.<br/>
  5150. /// +1 denotes that this string should be sorted to follow the other.<br/>
  5151. /// </returns>
  5152. public int CompareTo(FixedString512Bytes other)
  5153. {
  5154. return FixedStringMethods.CompareTo(ref this, other);
  5155. }
  5156. /// <summary>
  5157. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  5158. /// </summary>
  5159. /// <param name="other">The string to copy.</param>
  5160. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  5161. public FixedString512Bytes(in FixedString512Bytes other)
  5162. {
  5163. this = default;
  5164. var error = Initialize(other);
  5165. CheckFormatError(error);
  5166. }
  5167. /// <summary>
  5168. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  5169. /// </summary>
  5170. /// <param name="other">The string to copy.</param>
  5171. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  5172. unsafe internal FormatError Initialize(in FixedString512Bytes other)
  5173. {
  5174. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  5175. }
  5176. /// <summary>
  5177. /// Returns true if a FixedString512Bytes and another string are equal.
  5178. /// </summary>
  5179. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5180. /// <param name="a">A FixedString512Bytes to compare for equality.</param>
  5181. /// <param name="b">A FixedString512Bytes to compare for equality.</param>
  5182. /// <returns>True if the two strings are equal.</returns>
  5183. public static bool operator ==(in FixedString512Bytes a, in FixedString512Bytes b)
  5184. {
  5185. // this must not call any methods on 'a' or 'b'
  5186. unsafe {
  5187. int alen = a.utf8LengthInBytes;
  5188. int blen = b.utf8LengthInBytes;
  5189. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  5190. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  5191. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  5192. }
  5193. }
  5194. /// <summary>
  5195. /// Returns true if a FixedString512Bytes and another string are unequal.
  5196. /// </summary>
  5197. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5198. /// <param name="a">A FixedString512Bytes to compare for inequality.</param>
  5199. /// <param name="b">A FixedString512Bytes to compare for inequality.</param>
  5200. /// <returns>True if the two strings are unequal.</returns>
  5201. public static bool operator !=(in FixedString512Bytes a, in FixedString512Bytes b)
  5202. {
  5203. return !(a == b);
  5204. }
  5205. /// <summary>
  5206. /// Returns true if this string and another string are equal.
  5207. /// </summary>
  5208. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5209. /// <param name="other">A FixedString512Bytes to compare for equality.</param>
  5210. /// <returns>True if the two strings are equal.</returns>
  5211. public bool Equals(FixedString512Bytes other)
  5212. {
  5213. return this == other;
  5214. }
  5215. /// <summary>
  5216. /// Returns the lexicographical sort order of this string relative to another.
  5217. /// </summary>
  5218. /// <param name="other">A string to compare with.</param>
  5219. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  5220. ///
  5221. /// 0 denotes that both strings have the same sort position.<br/>
  5222. /// -1 denotes that this string should be sorted to precede the other.<br/>
  5223. /// +1 denotes that this string should be sorted to follow the other.<br/>
  5224. /// </returns>
  5225. public int CompareTo(FixedString4096Bytes other)
  5226. {
  5227. return FixedStringMethods.CompareTo(ref this, other);
  5228. }
  5229. /// <summary>
  5230. /// Initializes and returns an instance of FixedString512Bytes that is a copy of another string.
  5231. /// </summary>
  5232. /// <param name="other">The string to copy.</param>
  5233. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  5234. public FixedString512Bytes(in FixedString4096Bytes other)
  5235. {
  5236. this = default;
  5237. var error = Initialize(other);
  5238. CheckFormatError(error);
  5239. }
  5240. /// <summary>
  5241. /// Initializes an instance of FixedString512Bytes that is a copy of another string.
  5242. /// </summary>
  5243. /// <param name="other">The string to copy.</param>
  5244. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  5245. unsafe internal FormatError Initialize(in FixedString4096Bytes other)
  5246. {
  5247. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  5248. }
  5249. /// <summary>
  5250. /// Returns true if a FixedString512Bytes and another string are equal.
  5251. /// </summary>
  5252. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5253. /// <param name="a">A FixedString512Bytes to compare for equality.</param>
  5254. /// <param name="b">A FixedString4096Bytes to compare for equality.</param>
  5255. /// <returns>True if the two strings are equal.</returns>
  5256. public static bool operator ==(in FixedString512Bytes a, in FixedString4096Bytes b)
  5257. {
  5258. // this must not call any methods on 'a' or 'b'
  5259. unsafe {
  5260. int alen = a.utf8LengthInBytes;
  5261. int blen = b.utf8LengthInBytes;
  5262. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  5263. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  5264. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  5265. }
  5266. }
  5267. /// <summary>
  5268. /// Returns true if a FixedString512Bytes and another string are unequal.
  5269. /// </summary>
  5270. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5271. /// <param name="a">A FixedString512Bytes to compare for inequality.</param>
  5272. /// <param name="b">A FixedString4096Bytes to compare for inequality.</param>
  5273. /// <returns>True if the two strings are unequal.</returns>
  5274. public static bool operator !=(in FixedString512Bytes a, in FixedString4096Bytes b)
  5275. {
  5276. return !(a == b);
  5277. }
  5278. /// <summary>
  5279. /// Returns true if this string and another string are equal.
  5280. /// </summary>
  5281. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  5282. /// <param name="other">A FixedString4096Bytes to compare for equality.</param>
  5283. /// <returns>True if the two strings are equal.</returns>
  5284. public bool Equals(FixedString4096Bytes other)
  5285. {
  5286. return this == other;
  5287. }
  5288. /// <summary>
  5289. /// Returns a new FixedString4096Bytes that is a copy of another string.
  5290. /// </summary>
  5291. /// <param name="fs">A FixedString512Bytes to copy.</param>
  5292. /// <returns>A new FixedString4096Bytes that is a copy of the other string.</returns>
  5293. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  5294. public static implicit operator FixedString4096Bytes(in FixedString512Bytes fs) => new FixedString4096Bytes(in fs);
  5295. /// <summary>
  5296. /// Returns a new FixedString512Bytes that is a copy of another string.
  5297. /// </summary>
  5298. /// <param name="b">A string to copy.</param>
  5299. /// <returns>A new FixedString512Bytes that is a copy of another string.</returns>
  5300. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString512Bytes.</exception>
  5301. [ExcludeFromBurstCompatTesting("Takes managed string")]
  5302. public static implicit operator FixedString512Bytes(string b) => new FixedString512Bytes(b);
  5303. /// <summary>
  5304. /// Returns a new managed string that is a copy of this string.
  5305. /// </summary>
  5306. /// <returns>A new managed string that is a copy of this string.</returns>
  5307. [ExcludeFromBurstCompatTesting("Returns managed string")]
  5308. public override String ToString()
  5309. {
  5310. return this.ConvertToString();
  5311. }
  5312. /// <summary>
  5313. /// Returns a hash code of this string.
  5314. /// </summary>
  5315. /// <remarks>Only the character bytes are included in the hash: any bytes beyond <see cref="Length"/> are not part of the hash.</remarks>
  5316. /// <returns>The hash code of this string.</returns>
  5317. public override int GetHashCode()
  5318. {
  5319. return this.ComputeHashCode();
  5320. }
  5321. /// <summary>
  5322. /// Returns true if this string and an object are equal.
  5323. /// </summary>
  5324. /// <remarks>
  5325. /// Returns false if the object is neither a System.String or a FixedString.
  5326. ///
  5327. /// Two strings are equal if they have equal length and all their characters match.</remarks>
  5328. /// <param name="obj">An object to compare for equality.</param>
  5329. /// <returns>True if this string and the object are equal.</returns>
  5330. [ExcludeFromBurstCompatTesting("Takes managed object")]
  5331. public override bool Equals(object obj)
  5332. {
  5333. if(ReferenceEquals(null, obj)) return false;
  5334. if(obj is String aString) return Equals(aString);
  5335. if(obj is FixedString32Bytes aFixedString32Bytes) return Equals(aFixedString32Bytes);
  5336. if(obj is FixedString64Bytes aFixedString64Bytes) return Equals(aFixedString64Bytes);
  5337. if(obj is FixedString128Bytes aFixedString128Bytes) return Equals(aFixedString128Bytes);
  5338. if(obj is FixedString512Bytes aFixedString512Bytes) return Equals(aFixedString512Bytes);
  5339. if(obj is FixedString4096Bytes aFixedString4096Bytes) return Equals(aFixedString4096Bytes);
  5340. return false;
  5341. }
  5342. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  5343. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  5344. readonly void CheckIndexInRange(int index)
  5345. {
  5346. if (index < 0)
  5347. throw new IndexOutOfRangeException($"Index {index} must be positive.");
  5348. if (index >= utf8LengthInBytes)
  5349. throw new IndexOutOfRangeException($"Index {index} is out of range in FixedString512Bytes of '{utf8LengthInBytes}' Length.");
  5350. }
  5351. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  5352. void CheckLengthInRange(int length)
  5353. {
  5354. if (length < 0)
  5355. throw new ArgumentOutOfRangeException($"Length {length} must be positive.");
  5356. if (length > utf8MaxLengthInBytes)
  5357. throw new ArgumentOutOfRangeException($"Length {length} is out of range in FixedString512Bytes of '{utf8MaxLengthInBytes}' Capacity.");
  5358. }
  5359. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  5360. void CheckCapacityInRange(int capacity)
  5361. {
  5362. if (capacity > utf8MaxLengthInBytes)
  5363. throw new ArgumentOutOfRangeException($"Capacity {capacity} must be lower than {utf8MaxLengthInBytes}.");
  5364. }
  5365. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  5366. static void CheckCopyError(CopyError error, String source)
  5367. {
  5368. if (error != CopyError.None)
  5369. throw new ArgumentException($"FixedString512Bytes: {error} while copying \"{source}\"");
  5370. }
  5371. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  5372. static void CheckFormatError(FormatError error)
  5373. {
  5374. if (error != FormatError.None)
  5375. throw new ArgumentException("Source is too long to fit into fixed string of this size");
  5376. }
  5377. }
  5378. // A temporary copy of a struct is made before it is displayed in a C# debugger.
  5379. // However, only the first element of data members with names is copied at this time.
  5380. // Therefore, it's important that all data visible in the debugger, has a name
  5381. // and includes no 'fixed' array. This is why we name every byte in the following struct.
  5382. /// <summary>
  5383. /// For internal use only.
  5384. /// </summary>
  5385. [Serializable]
  5386. [StructLayout(LayoutKind.Explicit, Size=4094)]
  5387. [GenerateTestsForBurstCompatibility]
  5388. public struct FixedBytes4094
  5389. {
  5390. /// <summary>
  5391. /// For internal use only.
  5392. /// </summary>
  5393. [FieldOffset(0)] public FixedBytes16 offset0000;
  5394. /// <summary>
  5395. /// For internal use only.
  5396. /// </summary>
  5397. [FieldOffset(16)] public FixedBytes16 offset0016;
  5398. /// <summary>
  5399. /// For internal use only.
  5400. /// </summary>
  5401. [FieldOffset(32)] public FixedBytes16 offset0032;
  5402. /// <summary>
  5403. /// For internal use only.
  5404. /// </summary>
  5405. [FieldOffset(48)] public FixedBytes16 offset0048;
  5406. /// <summary>
  5407. /// For internal use only.
  5408. /// </summary>
  5409. [FieldOffset(64)] public FixedBytes16 offset0064;
  5410. /// <summary>
  5411. /// For internal use only.
  5412. /// </summary>
  5413. [FieldOffset(80)] public FixedBytes16 offset0080;
  5414. /// <summary>
  5415. /// For internal use only.
  5416. /// </summary>
  5417. [FieldOffset(96)] public FixedBytes16 offset0096;
  5418. /// <summary>
  5419. /// For internal use only.
  5420. /// </summary>
  5421. [FieldOffset(112)] public FixedBytes16 offset0112;
  5422. /// <summary>
  5423. /// For internal use only.
  5424. /// </summary>
  5425. [FieldOffset(128)] public FixedBytes16 offset0128;
  5426. /// <summary>
  5427. /// For internal use only.
  5428. /// </summary>
  5429. [FieldOffset(144)] public FixedBytes16 offset0144;
  5430. /// <summary>
  5431. /// For internal use only.
  5432. /// </summary>
  5433. [FieldOffset(160)] public FixedBytes16 offset0160;
  5434. /// <summary>
  5435. /// For internal use only.
  5436. /// </summary>
  5437. [FieldOffset(176)] public FixedBytes16 offset0176;
  5438. /// <summary>
  5439. /// For internal use only.
  5440. /// </summary>
  5441. [FieldOffset(192)] public FixedBytes16 offset0192;
  5442. /// <summary>
  5443. /// For internal use only.
  5444. /// </summary>
  5445. [FieldOffset(208)] public FixedBytes16 offset0208;
  5446. /// <summary>
  5447. /// For internal use only.
  5448. /// </summary>
  5449. [FieldOffset(224)] public FixedBytes16 offset0224;
  5450. /// <summary>
  5451. /// For internal use only.
  5452. /// </summary>
  5453. [FieldOffset(240)] public FixedBytes16 offset0240;
  5454. /// <summary>
  5455. /// For internal use only.
  5456. /// </summary>
  5457. [FieldOffset(256)] public FixedBytes16 offset0256;
  5458. /// <summary>
  5459. /// For internal use only.
  5460. /// </summary>
  5461. [FieldOffset(272)] public FixedBytes16 offset0272;
  5462. /// <summary>
  5463. /// For internal use only.
  5464. /// </summary>
  5465. [FieldOffset(288)] public FixedBytes16 offset0288;
  5466. /// <summary>
  5467. /// For internal use only.
  5468. /// </summary>
  5469. [FieldOffset(304)] public FixedBytes16 offset0304;
  5470. /// <summary>
  5471. /// For internal use only.
  5472. /// </summary>
  5473. [FieldOffset(320)] public FixedBytes16 offset0320;
  5474. /// <summary>
  5475. /// For internal use only.
  5476. /// </summary>
  5477. [FieldOffset(336)] public FixedBytes16 offset0336;
  5478. /// <summary>
  5479. /// For internal use only.
  5480. /// </summary>
  5481. [FieldOffset(352)] public FixedBytes16 offset0352;
  5482. /// <summary>
  5483. /// For internal use only.
  5484. /// </summary>
  5485. [FieldOffset(368)] public FixedBytes16 offset0368;
  5486. /// <summary>
  5487. /// For internal use only.
  5488. /// </summary>
  5489. [FieldOffset(384)] public FixedBytes16 offset0384;
  5490. /// <summary>
  5491. /// For internal use only.
  5492. /// </summary>
  5493. [FieldOffset(400)] public FixedBytes16 offset0400;
  5494. /// <summary>
  5495. /// For internal use only.
  5496. /// </summary>
  5497. [FieldOffset(416)] public FixedBytes16 offset0416;
  5498. /// <summary>
  5499. /// For internal use only.
  5500. /// </summary>
  5501. [FieldOffset(432)] public FixedBytes16 offset0432;
  5502. /// <summary>
  5503. /// For internal use only.
  5504. /// </summary>
  5505. [FieldOffset(448)] public FixedBytes16 offset0448;
  5506. /// <summary>
  5507. /// For internal use only.
  5508. /// </summary>
  5509. [FieldOffset(464)] public FixedBytes16 offset0464;
  5510. /// <summary>
  5511. /// For internal use only.
  5512. /// </summary>
  5513. [FieldOffset(480)] public FixedBytes16 offset0480;
  5514. /// <summary>
  5515. /// For internal use only.
  5516. /// </summary>
  5517. [FieldOffset(496)] public FixedBytes16 offset0496;
  5518. /// <summary>
  5519. /// For internal use only.
  5520. /// </summary>
  5521. [FieldOffset(512)] public FixedBytes16 offset0512;
  5522. /// <summary>
  5523. /// For internal use only.
  5524. /// </summary>
  5525. [FieldOffset(528)] public FixedBytes16 offset0528;
  5526. /// <summary>
  5527. /// For internal use only.
  5528. /// </summary>
  5529. [FieldOffset(544)] public FixedBytes16 offset0544;
  5530. /// <summary>
  5531. /// For internal use only.
  5532. /// </summary>
  5533. [FieldOffset(560)] public FixedBytes16 offset0560;
  5534. /// <summary>
  5535. /// For internal use only.
  5536. /// </summary>
  5537. [FieldOffset(576)] public FixedBytes16 offset0576;
  5538. /// <summary>
  5539. /// For internal use only.
  5540. /// </summary>
  5541. [FieldOffset(592)] public FixedBytes16 offset0592;
  5542. /// <summary>
  5543. /// For internal use only.
  5544. /// </summary>
  5545. [FieldOffset(608)] public FixedBytes16 offset0608;
  5546. /// <summary>
  5547. /// For internal use only.
  5548. /// </summary>
  5549. [FieldOffset(624)] public FixedBytes16 offset0624;
  5550. /// <summary>
  5551. /// For internal use only.
  5552. /// </summary>
  5553. [FieldOffset(640)] public FixedBytes16 offset0640;
  5554. /// <summary>
  5555. /// For internal use only.
  5556. /// </summary>
  5557. [FieldOffset(656)] public FixedBytes16 offset0656;
  5558. /// <summary>
  5559. /// For internal use only.
  5560. /// </summary>
  5561. [FieldOffset(672)] public FixedBytes16 offset0672;
  5562. /// <summary>
  5563. /// For internal use only.
  5564. /// </summary>
  5565. [FieldOffset(688)] public FixedBytes16 offset0688;
  5566. /// <summary>
  5567. /// For internal use only.
  5568. /// </summary>
  5569. [FieldOffset(704)] public FixedBytes16 offset0704;
  5570. /// <summary>
  5571. /// For internal use only.
  5572. /// </summary>
  5573. [FieldOffset(720)] public FixedBytes16 offset0720;
  5574. /// <summary>
  5575. /// For internal use only.
  5576. /// </summary>
  5577. [FieldOffset(736)] public FixedBytes16 offset0736;
  5578. /// <summary>
  5579. /// For internal use only.
  5580. /// </summary>
  5581. [FieldOffset(752)] public FixedBytes16 offset0752;
  5582. /// <summary>
  5583. /// For internal use only.
  5584. /// </summary>
  5585. [FieldOffset(768)] public FixedBytes16 offset0768;
  5586. /// <summary>
  5587. /// For internal use only.
  5588. /// </summary>
  5589. [FieldOffset(784)] public FixedBytes16 offset0784;
  5590. /// <summary>
  5591. /// For internal use only.
  5592. /// </summary>
  5593. [FieldOffset(800)] public FixedBytes16 offset0800;
  5594. /// <summary>
  5595. /// For internal use only.
  5596. /// </summary>
  5597. [FieldOffset(816)] public FixedBytes16 offset0816;
  5598. /// <summary>
  5599. /// For internal use only.
  5600. /// </summary>
  5601. [FieldOffset(832)] public FixedBytes16 offset0832;
  5602. /// <summary>
  5603. /// For internal use only.
  5604. /// </summary>
  5605. [FieldOffset(848)] public FixedBytes16 offset0848;
  5606. /// <summary>
  5607. /// For internal use only.
  5608. /// </summary>
  5609. [FieldOffset(864)] public FixedBytes16 offset0864;
  5610. /// <summary>
  5611. /// For internal use only.
  5612. /// </summary>
  5613. [FieldOffset(880)] public FixedBytes16 offset0880;
  5614. /// <summary>
  5615. /// For internal use only.
  5616. /// </summary>
  5617. [FieldOffset(896)] public FixedBytes16 offset0896;
  5618. /// <summary>
  5619. /// For internal use only.
  5620. /// </summary>
  5621. [FieldOffset(912)] public FixedBytes16 offset0912;
  5622. /// <summary>
  5623. /// For internal use only.
  5624. /// </summary>
  5625. [FieldOffset(928)] public FixedBytes16 offset0928;
  5626. /// <summary>
  5627. /// For internal use only.
  5628. /// </summary>
  5629. [FieldOffset(944)] public FixedBytes16 offset0944;
  5630. /// <summary>
  5631. /// For internal use only.
  5632. /// </summary>
  5633. [FieldOffset(960)] public FixedBytes16 offset0960;
  5634. /// <summary>
  5635. /// For internal use only.
  5636. /// </summary>
  5637. [FieldOffset(976)] public FixedBytes16 offset0976;
  5638. /// <summary>
  5639. /// For internal use only.
  5640. /// </summary>
  5641. [FieldOffset(992)] public FixedBytes16 offset0992;
  5642. /// <summary>
  5643. /// For internal use only.
  5644. /// </summary>
  5645. [FieldOffset(1008)] public FixedBytes16 offset1008;
  5646. /// <summary>
  5647. /// For internal use only.
  5648. /// </summary>
  5649. [FieldOffset(1024)] public FixedBytes16 offset1024;
  5650. /// <summary>
  5651. /// For internal use only.
  5652. /// </summary>
  5653. [FieldOffset(1040)] public FixedBytes16 offset1040;
  5654. /// <summary>
  5655. /// For internal use only.
  5656. /// </summary>
  5657. [FieldOffset(1056)] public FixedBytes16 offset1056;
  5658. /// <summary>
  5659. /// For internal use only.
  5660. /// </summary>
  5661. [FieldOffset(1072)] public FixedBytes16 offset1072;
  5662. /// <summary>
  5663. /// For internal use only.
  5664. /// </summary>
  5665. [FieldOffset(1088)] public FixedBytes16 offset1088;
  5666. /// <summary>
  5667. /// For internal use only.
  5668. /// </summary>
  5669. [FieldOffset(1104)] public FixedBytes16 offset1104;
  5670. /// <summary>
  5671. /// For internal use only.
  5672. /// </summary>
  5673. [FieldOffset(1120)] public FixedBytes16 offset1120;
  5674. /// <summary>
  5675. /// For internal use only.
  5676. /// </summary>
  5677. [FieldOffset(1136)] public FixedBytes16 offset1136;
  5678. /// <summary>
  5679. /// For internal use only.
  5680. /// </summary>
  5681. [FieldOffset(1152)] public FixedBytes16 offset1152;
  5682. /// <summary>
  5683. /// For internal use only.
  5684. /// </summary>
  5685. [FieldOffset(1168)] public FixedBytes16 offset1168;
  5686. /// <summary>
  5687. /// For internal use only.
  5688. /// </summary>
  5689. [FieldOffset(1184)] public FixedBytes16 offset1184;
  5690. /// <summary>
  5691. /// For internal use only.
  5692. /// </summary>
  5693. [FieldOffset(1200)] public FixedBytes16 offset1200;
  5694. /// <summary>
  5695. /// For internal use only.
  5696. /// </summary>
  5697. [FieldOffset(1216)] public FixedBytes16 offset1216;
  5698. /// <summary>
  5699. /// For internal use only.
  5700. /// </summary>
  5701. [FieldOffset(1232)] public FixedBytes16 offset1232;
  5702. /// <summary>
  5703. /// For internal use only.
  5704. /// </summary>
  5705. [FieldOffset(1248)] public FixedBytes16 offset1248;
  5706. /// <summary>
  5707. /// For internal use only.
  5708. /// </summary>
  5709. [FieldOffset(1264)] public FixedBytes16 offset1264;
  5710. /// <summary>
  5711. /// For internal use only.
  5712. /// </summary>
  5713. [FieldOffset(1280)] public FixedBytes16 offset1280;
  5714. /// <summary>
  5715. /// For internal use only.
  5716. /// </summary>
  5717. [FieldOffset(1296)] public FixedBytes16 offset1296;
  5718. /// <summary>
  5719. /// For internal use only.
  5720. /// </summary>
  5721. [FieldOffset(1312)] public FixedBytes16 offset1312;
  5722. /// <summary>
  5723. /// For internal use only.
  5724. /// </summary>
  5725. [FieldOffset(1328)] public FixedBytes16 offset1328;
  5726. /// <summary>
  5727. /// For internal use only.
  5728. /// </summary>
  5729. [FieldOffset(1344)] public FixedBytes16 offset1344;
  5730. /// <summary>
  5731. /// For internal use only.
  5732. /// </summary>
  5733. [FieldOffset(1360)] public FixedBytes16 offset1360;
  5734. /// <summary>
  5735. /// For internal use only.
  5736. /// </summary>
  5737. [FieldOffset(1376)] public FixedBytes16 offset1376;
  5738. /// <summary>
  5739. /// For internal use only.
  5740. /// </summary>
  5741. [FieldOffset(1392)] public FixedBytes16 offset1392;
  5742. /// <summary>
  5743. /// For internal use only.
  5744. /// </summary>
  5745. [FieldOffset(1408)] public FixedBytes16 offset1408;
  5746. /// <summary>
  5747. /// For internal use only.
  5748. /// </summary>
  5749. [FieldOffset(1424)] public FixedBytes16 offset1424;
  5750. /// <summary>
  5751. /// For internal use only.
  5752. /// </summary>
  5753. [FieldOffset(1440)] public FixedBytes16 offset1440;
  5754. /// <summary>
  5755. /// For internal use only.
  5756. /// </summary>
  5757. [FieldOffset(1456)] public FixedBytes16 offset1456;
  5758. /// <summary>
  5759. /// For internal use only.
  5760. /// </summary>
  5761. [FieldOffset(1472)] public FixedBytes16 offset1472;
  5762. /// <summary>
  5763. /// For internal use only.
  5764. /// </summary>
  5765. [FieldOffset(1488)] public FixedBytes16 offset1488;
  5766. /// <summary>
  5767. /// For internal use only.
  5768. /// </summary>
  5769. [FieldOffset(1504)] public FixedBytes16 offset1504;
  5770. /// <summary>
  5771. /// For internal use only.
  5772. /// </summary>
  5773. [FieldOffset(1520)] public FixedBytes16 offset1520;
  5774. /// <summary>
  5775. /// For internal use only.
  5776. /// </summary>
  5777. [FieldOffset(1536)] public FixedBytes16 offset1536;
  5778. /// <summary>
  5779. /// For internal use only.
  5780. /// </summary>
  5781. [FieldOffset(1552)] public FixedBytes16 offset1552;
  5782. /// <summary>
  5783. /// For internal use only.
  5784. /// </summary>
  5785. [FieldOffset(1568)] public FixedBytes16 offset1568;
  5786. /// <summary>
  5787. /// For internal use only.
  5788. /// </summary>
  5789. [FieldOffset(1584)] public FixedBytes16 offset1584;
  5790. /// <summary>
  5791. /// For internal use only.
  5792. /// </summary>
  5793. [FieldOffset(1600)] public FixedBytes16 offset1600;
  5794. /// <summary>
  5795. /// For internal use only.
  5796. /// </summary>
  5797. [FieldOffset(1616)] public FixedBytes16 offset1616;
  5798. /// <summary>
  5799. /// For internal use only.
  5800. /// </summary>
  5801. [FieldOffset(1632)] public FixedBytes16 offset1632;
  5802. /// <summary>
  5803. /// For internal use only.
  5804. /// </summary>
  5805. [FieldOffset(1648)] public FixedBytes16 offset1648;
  5806. /// <summary>
  5807. /// For internal use only.
  5808. /// </summary>
  5809. [FieldOffset(1664)] public FixedBytes16 offset1664;
  5810. /// <summary>
  5811. /// For internal use only.
  5812. /// </summary>
  5813. [FieldOffset(1680)] public FixedBytes16 offset1680;
  5814. /// <summary>
  5815. /// For internal use only.
  5816. /// </summary>
  5817. [FieldOffset(1696)] public FixedBytes16 offset1696;
  5818. /// <summary>
  5819. /// For internal use only.
  5820. /// </summary>
  5821. [FieldOffset(1712)] public FixedBytes16 offset1712;
  5822. /// <summary>
  5823. /// For internal use only.
  5824. /// </summary>
  5825. [FieldOffset(1728)] public FixedBytes16 offset1728;
  5826. /// <summary>
  5827. /// For internal use only.
  5828. /// </summary>
  5829. [FieldOffset(1744)] public FixedBytes16 offset1744;
  5830. /// <summary>
  5831. /// For internal use only.
  5832. /// </summary>
  5833. [FieldOffset(1760)] public FixedBytes16 offset1760;
  5834. /// <summary>
  5835. /// For internal use only.
  5836. /// </summary>
  5837. [FieldOffset(1776)] public FixedBytes16 offset1776;
  5838. /// <summary>
  5839. /// For internal use only.
  5840. /// </summary>
  5841. [FieldOffset(1792)] public FixedBytes16 offset1792;
  5842. /// <summary>
  5843. /// For internal use only.
  5844. /// </summary>
  5845. [FieldOffset(1808)] public FixedBytes16 offset1808;
  5846. /// <summary>
  5847. /// For internal use only.
  5848. /// </summary>
  5849. [FieldOffset(1824)] public FixedBytes16 offset1824;
  5850. /// <summary>
  5851. /// For internal use only.
  5852. /// </summary>
  5853. [FieldOffset(1840)] public FixedBytes16 offset1840;
  5854. /// <summary>
  5855. /// For internal use only.
  5856. /// </summary>
  5857. [FieldOffset(1856)] public FixedBytes16 offset1856;
  5858. /// <summary>
  5859. /// For internal use only.
  5860. /// </summary>
  5861. [FieldOffset(1872)] public FixedBytes16 offset1872;
  5862. /// <summary>
  5863. /// For internal use only.
  5864. /// </summary>
  5865. [FieldOffset(1888)] public FixedBytes16 offset1888;
  5866. /// <summary>
  5867. /// For internal use only.
  5868. /// </summary>
  5869. [FieldOffset(1904)] public FixedBytes16 offset1904;
  5870. /// <summary>
  5871. /// For internal use only.
  5872. /// </summary>
  5873. [FieldOffset(1920)] public FixedBytes16 offset1920;
  5874. /// <summary>
  5875. /// For internal use only.
  5876. /// </summary>
  5877. [FieldOffset(1936)] public FixedBytes16 offset1936;
  5878. /// <summary>
  5879. /// For internal use only.
  5880. /// </summary>
  5881. [FieldOffset(1952)] public FixedBytes16 offset1952;
  5882. /// <summary>
  5883. /// For internal use only.
  5884. /// </summary>
  5885. [FieldOffset(1968)] public FixedBytes16 offset1968;
  5886. /// <summary>
  5887. /// For internal use only.
  5888. /// </summary>
  5889. [FieldOffset(1984)] public FixedBytes16 offset1984;
  5890. /// <summary>
  5891. /// For internal use only.
  5892. /// </summary>
  5893. [FieldOffset(2000)] public FixedBytes16 offset2000;
  5894. /// <summary>
  5895. /// For internal use only.
  5896. /// </summary>
  5897. [FieldOffset(2016)] public FixedBytes16 offset2016;
  5898. /// <summary>
  5899. /// For internal use only.
  5900. /// </summary>
  5901. [FieldOffset(2032)] public FixedBytes16 offset2032;
  5902. /// <summary>
  5903. /// For internal use only.
  5904. /// </summary>
  5905. [FieldOffset(2048)] public FixedBytes16 offset2048;
  5906. /// <summary>
  5907. /// For internal use only.
  5908. /// </summary>
  5909. [FieldOffset(2064)] public FixedBytes16 offset2064;
  5910. /// <summary>
  5911. /// For internal use only.
  5912. /// </summary>
  5913. [FieldOffset(2080)] public FixedBytes16 offset2080;
  5914. /// <summary>
  5915. /// For internal use only.
  5916. /// </summary>
  5917. [FieldOffset(2096)] public FixedBytes16 offset2096;
  5918. /// <summary>
  5919. /// For internal use only.
  5920. /// </summary>
  5921. [FieldOffset(2112)] public FixedBytes16 offset2112;
  5922. /// <summary>
  5923. /// For internal use only.
  5924. /// </summary>
  5925. [FieldOffset(2128)] public FixedBytes16 offset2128;
  5926. /// <summary>
  5927. /// For internal use only.
  5928. /// </summary>
  5929. [FieldOffset(2144)] public FixedBytes16 offset2144;
  5930. /// <summary>
  5931. /// For internal use only.
  5932. /// </summary>
  5933. [FieldOffset(2160)] public FixedBytes16 offset2160;
  5934. /// <summary>
  5935. /// For internal use only.
  5936. /// </summary>
  5937. [FieldOffset(2176)] public FixedBytes16 offset2176;
  5938. /// <summary>
  5939. /// For internal use only.
  5940. /// </summary>
  5941. [FieldOffset(2192)] public FixedBytes16 offset2192;
  5942. /// <summary>
  5943. /// For internal use only.
  5944. /// </summary>
  5945. [FieldOffset(2208)] public FixedBytes16 offset2208;
  5946. /// <summary>
  5947. /// For internal use only.
  5948. /// </summary>
  5949. [FieldOffset(2224)] public FixedBytes16 offset2224;
  5950. /// <summary>
  5951. /// For internal use only.
  5952. /// </summary>
  5953. [FieldOffset(2240)] public FixedBytes16 offset2240;
  5954. /// <summary>
  5955. /// For internal use only.
  5956. /// </summary>
  5957. [FieldOffset(2256)] public FixedBytes16 offset2256;
  5958. /// <summary>
  5959. /// For internal use only.
  5960. /// </summary>
  5961. [FieldOffset(2272)] public FixedBytes16 offset2272;
  5962. /// <summary>
  5963. /// For internal use only.
  5964. /// </summary>
  5965. [FieldOffset(2288)] public FixedBytes16 offset2288;
  5966. /// <summary>
  5967. /// For internal use only.
  5968. /// </summary>
  5969. [FieldOffset(2304)] public FixedBytes16 offset2304;
  5970. /// <summary>
  5971. /// For internal use only.
  5972. /// </summary>
  5973. [FieldOffset(2320)] public FixedBytes16 offset2320;
  5974. /// <summary>
  5975. /// For internal use only.
  5976. /// </summary>
  5977. [FieldOffset(2336)] public FixedBytes16 offset2336;
  5978. /// <summary>
  5979. /// For internal use only.
  5980. /// </summary>
  5981. [FieldOffset(2352)] public FixedBytes16 offset2352;
  5982. /// <summary>
  5983. /// For internal use only.
  5984. /// </summary>
  5985. [FieldOffset(2368)] public FixedBytes16 offset2368;
  5986. /// <summary>
  5987. /// For internal use only.
  5988. /// </summary>
  5989. [FieldOffset(2384)] public FixedBytes16 offset2384;
  5990. /// <summary>
  5991. /// For internal use only.
  5992. /// </summary>
  5993. [FieldOffset(2400)] public FixedBytes16 offset2400;
  5994. /// <summary>
  5995. /// For internal use only.
  5996. /// </summary>
  5997. [FieldOffset(2416)] public FixedBytes16 offset2416;
  5998. /// <summary>
  5999. /// For internal use only.
  6000. /// </summary>
  6001. [FieldOffset(2432)] public FixedBytes16 offset2432;
  6002. /// <summary>
  6003. /// For internal use only.
  6004. /// </summary>
  6005. [FieldOffset(2448)] public FixedBytes16 offset2448;
  6006. /// <summary>
  6007. /// For internal use only.
  6008. /// </summary>
  6009. [FieldOffset(2464)] public FixedBytes16 offset2464;
  6010. /// <summary>
  6011. /// For internal use only.
  6012. /// </summary>
  6013. [FieldOffset(2480)] public FixedBytes16 offset2480;
  6014. /// <summary>
  6015. /// For internal use only.
  6016. /// </summary>
  6017. [FieldOffset(2496)] public FixedBytes16 offset2496;
  6018. /// <summary>
  6019. /// For internal use only.
  6020. /// </summary>
  6021. [FieldOffset(2512)] public FixedBytes16 offset2512;
  6022. /// <summary>
  6023. /// For internal use only.
  6024. /// </summary>
  6025. [FieldOffset(2528)] public FixedBytes16 offset2528;
  6026. /// <summary>
  6027. /// For internal use only.
  6028. /// </summary>
  6029. [FieldOffset(2544)] public FixedBytes16 offset2544;
  6030. /// <summary>
  6031. /// For internal use only.
  6032. /// </summary>
  6033. [FieldOffset(2560)] public FixedBytes16 offset2560;
  6034. /// <summary>
  6035. /// For internal use only.
  6036. /// </summary>
  6037. [FieldOffset(2576)] public FixedBytes16 offset2576;
  6038. /// <summary>
  6039. /// For internal use only.
  6040. /// </summary>
  6041. [FieldOffset(2592)] public FixedBytes16 offset2592;
  6042. /// <summary>
  6043. /// For internal use only.
  6044. /// </summary>
  6045. [FieldOffset(2608)] public FixedBytes16 offset2608;
  6046. /// <summary>
  6047. /// For internal use only.
  6048. /// </summary>
  6049. [FieldOffset(2624)] public FixedBytes16 offset2624;
  6050. /// <summary>
  6051. /// For internal use only.
  6052. /// </summary>
  6053. [FieldOffset(2640)] public FixedBytes16 offset2640;
  6054. /// <summary>
  6055. /// For internal use only.
  6056. /// </summary>
  6057. [FieldOffset(2656)] public FixedBytes16 offset2656;
  6058. /// <summary>
  6059. /// For internal use only.
  6060. /// </summary>
  6061. [FieldOffset(2672)] public FixedBytes16 offset2672;
  6062. /// <summary>
  6063. /// For internal use only.
  6064. /// </summary>
  6065. [FieldOffset(2688)] public FixedBytes16 offset2688;
  6066. /// <summary>
  6067. /// For internal use only.
  6068. /// </summary>
  6069. [FieldOffset(2704)] public FixedBytes16 offset2704;
  6070. /// <summary>
  6071. /// For internal use only.
  6072. /// </summary>
  6073. [FieldOffset(2720)] public FixedBytes16 offset2720;
  6074. /// <summary>
  6075. /// For internal use only.
  6076. /// </summary>
  6077. [FieldOffset(2736)] public FixedBytes16 offset2736;
  6078. /// <summary>
  6079. /// For internal use only.
  6080. /// </summary>
  6081. [FieldOffset(2752)] public FixedBytes16 offset2752;
  6082. /// <summary>
  6083. /// For internal use only.
  6084. /// </summary>
  6085. [FieldOffset(2768)] public FixedBytes16 offset2768;
  6086. /// <summary>
  6087. /// For internal use only.
  6088. /// </summary>
  6089. [FieldOffset(2784)] public FixedBytes16 offset2784;
  6090. /// <summary>
  6091. /// For internal use only.
  6092. /// </summary>
  6093. [FieldOffset(2800)] public FixedBytes16 offset2800;
  6094. /// <summary>
  6095. /// For internal use only.
  6096. /// </summary>
  6097. [FieldOffset(2816)] public FixedBytes16 offset2816;
  6098. /// <summary>
  6099. /// For internal use only.
  6100. /// </summary>
  6101. [FieldOffset(2832)] public FixedBytes16 offset2832;
  6102. /// <summary>
  6103. /// For internal use only.
  6104. /// </summary>
  6105. [FieldOffset(2848)] public FixedBytes16 offset2848;
  6106. /// <summary>
  6107. /// For internal use only.
  6108. /// </summary>
  6109. [FieldOffset(2864)] public FixedBytes16 offset2864;
  6110. /// <summary>
  6111. /// For internal use only.
  6112. /// </summary>
  6113. [FieldOffset(2880)] public FixedBytes16 offset2880;
  6114. /// <summary>
  6115. /// For internal use only.
  6116. /// </summary>
  6117. [FieldOffset(2896)] public FixedBytes16 offset2896;
  6118. /// <summary>
  6119. /// For internal use only.
  6120. /// </summary>
  6121. [FieldOffset(2912)] public FixedBytes16 offset2912;
  6122. /// <summary>
  6123. /// For internal use only.
  6124. /// </summary>
  6125. [FieldOffset(2928)] public FixedBytes16 offset2928;
  6126. /// <summary>
  6127. /// For internal use only.
  6128. /// </summary>
  6129. [FieldOffset(2944)] public FixedBytes16 offset2944;
  6130. /// <summary>
  6131. /// For internal use only.
  6132. /// </summary>
  6133. [FieldOffset(2960)] public FixedBytes16 offset2960;
  6134. /// <summary>
  6135. /// For internal use only.
  6136. /// </summary>
  6137. [FieldOffset(2976)] public FixedBytes16 offset2976;
  6138. /// <summary>
  6139. /// For internal use only.
  6140. /// </summary>
  6141. [FieldOffset(2992)] public FixedBytes16 offset2992;
  6142. /// <summary>
  6143. /// For internal use only.
  6144. /// </summary>
  6145. [FieldOffset(3008)] public FixedBytes16 offset3008;
  6146. /// <summary>
  6147. /// For internal use only.
  6148. /// </summary>
  6149. [FieldOffset(3024)] public FixedBytes16 offset3024;
  6150. /// <summary>
  6151. /// For internal use only.
  6152. /// </summary>
  6153. [FieldOffset(3040)] public FixedBytes16 offset3040;
  6154. /// <summary>
  6155. /// For internal use only.
  6156. /// </summary>
  6157. [FieldOffset(3056)] public FixedBytes16 offset3056;
  6158. /// <summary>
  6159. /// For internal use only.
  6160. /// </summary>
  6161. [FieldOffset(3072)] public FixedBytes16 offset3072;
  6162. /// <summary>
  6163. /// For internal use only.
  6164. /// </summary>
  6165. [FieldOffset(3088)] public FixedBytes16 offset3088;
  6166. /// <summary>
  6167. /// For internal use only.
  6168. /// </summary>
  6169. [FieldOffset(3104)] public FixedBytes16 offset3104;
  6170. /// <summary>
  6171. /// For internal use only.
  6172. /// </summary>
  6173. [FieldOffset(3120)] public FixedBytes16 offset3120;
  6174. /// <summary>
  6175. /// For internal use only.
  6176. /// </summary>
  6177. [FieldOffset(3136)] public FixedBytes16 offset3136;
  6178. /// <summary>
  6179. /// For internal use only.
  6180. /// </summary>
  6181. [FieldOffset(3152)] public FixedBytes16 offset3152;
  6182. /// <summary>
  6183. /// For internal use only.
  6184. /// </summary>
  6185. [FieldOffset(3168)] public FixedBytes16 offset3168;
  6186. /// <summary>
  6187. /// For internal use only.
  6188. /// </summary>
  6189. [FieldOffset(3184)] public FixedBytes16 offset3184;
  6190. /// <summary>
  6191. /// For internal use only.
  6192. /// </summary>
  6193. [FieldOffset(3200)] public FixedBytes16 offset3200;
  6194. /// <summary>
  6195. /// For internal use only.
  6196. /// </summary>
  6197. [FieldOffset(3216)] public FixedBytes16 offset3216;
  6198. /// <summary>
  6199. /// For internal use only.
  6200. /// </summary>
  6201. [FieldOffset(3232)] public FixedBytes16 offset3232;
  6202. /// <summary>
  6203. /// For internal use only.
  6204. /// </summary>
  6205. [FieldOffset(3248)] public FixedBytes16 offset3248;
  6206. /// <summary>
  6207. /// For internal use only.
  6208. /// </summary>
  6209. [FieldOffset(3264)] public FixedBytes16 offset3264;
  6210. /// <summary>
  6211. /// For internal use only.
  6212. /// </summary>
  6213. [FieldOffset(3280)] public FixedBytes16 offset3280;
  6214. /// <summary>
  6215. /// For internal use only.
  6216. /// </summary>
  6217. [FieldOffset(3296)] public FixedBytes16 offset3296;
  6218. /// <summary>
  6219. /// For internal use only.
  6220. /// </summary>
  6221. [FieldOffset(3312)] public FixedBytes16 offset3312;
  6222. /// <summary>
  6223. /// For internal use only.
  6224. /// </summary>
  6225. [FieldOffset(3328)] public FixedBytes16 offset3328;
  6226. /// <summary>
  6227. /// For internal use only.
  6228. /// </summary>
  6229. [FieldOffset(3344)] public FixedBytes16 offset3344;
  6230. /// <summary>
  6231. /// For internal use only.
  6232. /// </summary>
  6233. [FieldOffset(3360)] public FixedBytes16 offset3360;
  6234. /// <summary>
  6235. /// For internal use only.
  6236. /// </summary>
  6237. [FieldOffset(3376)] public FixedBytes16 offset3376;
  6238. /// <summary>
  6239. /// For internal use only.
  6240. /// </summary>
  6241. [FieldOffset(3392)] public FixedBytes16 offset3392;
  6242. /// <summary>
  6243. /// For internal use only.
  6244. /// </summary>
  6245. [FieldOffset(3408)] public FixedBytes16 offset3408;
  6246. /// <summary>
  6247. /// For internal use only.
  6248. /// </summary>
  6249. [FieldOffset(3424)] public FixedBytes16 offset3424;
  6250. /// <summary>
  6251. /// For internal use only.
  6252. /// </summary>
  6253. [FieldOffset(3440)] public FixedBytes16 offset3440;
  6254. /// <summary>
  6255. /// For internal use only.
  6256. /// </summary>
  6257. [FieldOffset(3456)] public FixedBytes16 offset3456;
  6258. /// <summary>
  6259. /// For internal use only.
  6260. /// </summary>
  6261. [FieldOffset(3472)] public FixedBytes16 offset3472;
  6262. /// <summary>
  6263. /// For internal use only.
  6264. /// </summary>
  6265. [FieldOffset(3488)] public FixedBytes16 offset3488;
  6266. /// <summary>
  6267. /// For internal use only.
  6268. /// </summary>
  6269. [FieldOffset(3504)] public FixedBytes16 offset3504;
  6270. /// <summary>
  6271. /// For internal use only.
  6272. /// </summary>
  6273. [FieldOffset(3520)] public FixedBytes16 offset3520;
  6274. /// <summary>
  6275. /// For internal use only.
  6276. /// </summary>
  6277. [FieldOffset(3536)] public FixedBytes16 offset3536;
  6278. /// <summary>
  6279. /// For internal use only.
  6280. /// </summary>
  6281. [FieldOffset(3552)] public FixedBytes16 offset3552;
  6282. /// <summary>
  6283. /// For internal use only.
  6284. /// </summary>
  6285. [FieldOffset(3568)] public FixedBytes16 offset3568;
  6286. /// <summary>
  6287. /// For internal use only.
  6288. /// </summary>
  6289. [FieldOffset(3584)] public FixedBytes16 offset3584;
  6290. /// <summary>
  6291. /// For internal use only.
  6292. /// </summary>
  6293. [FieldOffset(3600)] public FixedBytes16 offset3600;
  6294. /// <summary>
  6295. /// For internal use only.
  6296. /// </summary>
  6297. [FieldOffset(3616)] public FixedBytes16 offset3616;
  6298. /// <summary>
  6299. /// For internal use only.
  6300. /// </summary>
  6301. [FieldOffset(3632)] public FixedBytes16 offset3632;
  6302. /// <summary>
  6303. /// For internal use only.
  6304. /// </summary>
  6305. [FieldOffset(3648)] public FixedBytes16 offset3648;
  6306. /// <summary>
  6307. /// For internal use only.
  6308. /// </summary>
  6309. [FieldOffset(3664)] public FixedBytes16 offset3664;
  6310. /// <summary>
  6311. /// For internal use only.
  6312. /// </summary>
  6313. [FieldOffset(3680)] public FixedBytes16 offset3680;
  6314. /// <summary>
  6315. /// For internal use only.
  6316. /// </summary>
  6317. [FieldOffset(3696)] public FixedBytes16 offset3696;
  6318. /// <summary>
  6319. /// For internal use only.
  6320. /// </summary>
  6321. [FieldOffset(3712)] public FixedBytes16 offset3712;
  6322. /// <summary>
  6323. /// For internal use only.
  6324. /// </summary>
  6325. [FieldOffset(3728)] public FixedBytes16 offset3728;
  6326. /// <summary>
  6327. /// For internal use only.
  6328. /// </summary>
  6329. [FieldOffset(3744)] public FixedBytes16 offset3744;
  6330. /// <summary>
  6331. /// For internal use only.
  6332. /// </summary>
  6333. [FieldOffset(3760)] public FixedBytes16 offset3760;
  6334. /// <summary>
  6335. /// For internal use only.
  6336. /// </summary>
  6337. [FieldOffset(3776)] public FixedBytes16 offset3776;
  6338. /// <summary>
  6339. /// For internal use only.
  6340. /// </summary>
  6341. [FieldOffset(3792)] public FixedBytes16 offset3792;
  6342. /// <summary>
  6343. /// For internal use only.
  6344. /// </summary>
  6345. [FieldOffset(3808)] public FixedBytes16 offset3808;
  6346. /// <summary>
  6347. /// For internal use only.
  6348. /// </summary>
  6349. [FieldOffset(3824)] public FixedBytes16 offset3824;
  6350. /// <summary>
  6351. /// For internal use only.
  6352. /// </summary>
  6353. [FieldOffset(3840)] public FixedBytes16 offset3840;
  6354. /// <summary>
  6355. /// For internal use only.
  6356. /// </summary>
  6357. [FieldOffset(3856)] public FixedBytes16 offset3856;
  6358. /// <summary>
  6359. /// For internal use only.
  6360. /// </summary>
  6361. [FieldOffset(3872)] public FixedBytes16 offset3872;
  6362. /// <summary>
  6363. /// For internal use only.
  6364. /// </summary>
  6365. [FieldOffset(3888)] public FixedBytes16 offset3888;
  6366. /// <summary>
  6367. /// For internal use only.
  6368. /// </summary>
  6369. [FieldOffset(3904)] public FixedBytes16 offset3904;
  6370. /// <summary>
  6371. /// For internal use only.
  6372. /// </summary>
  6373. [FieldOffset(3920)] public FixedBytes16 offset3920;
  6374. /// <summary>
  6375. /// For internal use only.
  6376. /// </summary>
  6377. [FieldOffset(3936)] public FixedBytes16 offset3936;
  6378. /// <summary>
  6379. /// For internal use only.
  6380. /// </summary>
  6381. [FieldOffset(3952)] public FixedBytes16 offset3952;
  6382. /// <summary>
  6383. /// For internal use only.
  6384. /// </summary>
  6385. [FieldOffset(3968)] public FixedBytes16 offset3968;
  6386. /// <summary>
  6387. /// For internal use only.
  6388. /// </summary>
  6389. [FieldOffset(3984)] public FixedBytes16 offset3984;
  6390. /// <summary>
  6391. /// For internal use only.
  6392. /// </summary>
  6393. [FieldOffset(4000)] public FixedBytes16 offset4000;
  6394. /// <summary>
  6395. /// For internal use only.
  6396. /// </summary>
  6397. [FieldOffset(4016)] public FixedBytes16 offset4016;
  6398. /// <summary>
  6399. /// For internal use only.
  6400. /// </summary>
  6401. [FieldOffset(4032)] public FixedBytes16 offset4032;
  6402. /// <summary>
  6403. /// For internal use only.
  6404. /// </summary>
  6405. [FieldOffset(4048)] public FixedBytes16 offset4048;
  6406. /// <summary>
  6407. /// For internal use only.
  6408. /// </summary>
  6409. [FieldOffset(4064)] public FixedBytes16 offset4064;
  6410. /// <summary>
  6411. /// For internal use only.
  6412. /// </summary>
  6413. [FieldOffset(4080)] public byte byte4080;
  6414. /// <summary>
  6415. /// For internal use only.
  6416. /// </summary>
  6417. [FieldOffset(4081)] public byte byte4081;
  6418. /// <summary>
  6419. /// For internal use only.
  6420. /// </summary>
  6421. [FieldOffset(4082)] public byte byte4082;
  6422. /// <summary>
  6423. /// For internal use only.
  6424. /// </summary>
  6425. [FieldOffset(4083)] public byte byte4083;
  6426. /// <summary>
  6427. /// For internal use only.
  6428. /// </summary>
  6429. [FieldOffset(4084)] public byte byte4084;
  6430. /// <summary>
  6431. /// For internal use only.
  6432. /// </summary>
  6433. [FieldOffset(4085)] public byte byte4085;
  6434. /// <summary>
  6435. /// For internal use only.
  6436. /// </summary>
  6437. [FieldOffset(4086)] public byte byte4086;
  6438. /// <summary>
  6439. /// For internal use only.
  6440. /// </summary>
  6441. [FieldOffset(4087)] public byte byte4087;
  6442. /// <summary>
  6443. /// For internal use only.
  6444. /// </summary>
  6445. [FieldOffset(4088)] public byte byte4088;
  6446. /// <summary>
  6447. /// For internal use only.
  6448. /// </summary>
  6449. [FieldOffset(4089)] public byte byte4089;
  6450. /// <summary>
  6451. /// For internal use only.
  6452. /// </summary>
  6453. [FieldOffset(4090)] public byte byte4090;
  6454. /// <summary>
  6455. /// For internal use only.
  6456. /// </summary>
  6457. [FieldOffset(4091)] public byte byte4091;
  6458. /// <summary>
  6459. /// For internal use only.
  6460. /// </summary>
  6461. [FieldOffset(4092)] public byte byte4092;
  6462. /// <summary>
  6463. /// For internal use only.
  6464. /// </summary>
  6465. [FieldOffset(4093)] public byte byte4093;
  6466. }
  6467. /// <summary>
  6468. /// An unmanaged UTF-8 string whose content is stored directly in the 4096-byte struct.
  6469. /// </summary>
  6470. /// <remarks>
  6471. /// The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer)
  6472. /// followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character.
  6473. /// Effectively, the number of bytes for storing characters is 3 less than 4096 (two length bytes and one null byte).
  6474. ///
  6475. /// This layout is identical to a <see cref="FixedList4096Bytes{T}"/> of bytes, thus allowing reinterpretation between FixedString4096Bytes and FixedList4096Bytes.
  6476. ///
  6477. /// By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation.
  6478. /// Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.
  6479. /// </remarks>
  6480. [Serializable]
  6481. [StructLayout(LayoutKind.Sequential, Size=4096)]
  6482. [GenerateTestsForBurstCompatibility]
  6483. public partial struct FixedString4096Bytes
  6484. : INativeList<byte>
  6485. , IUTF8Bytes
  6486. , IComparable<String>
  6487. , IEquatable<String>
  6488. , IComparable<FixedString32Bytes>
  6489. , IEquatable<FixedString32Bytes>
  6490. , IComparable<FixedString64Bytes>
  6491. , IEquatable<FixedString64Bytes>
  6492. , IComparable<FixedString128Bytes>
  6493. , IEquatable<FixedString128Bytes>
  6494. , IComparable<FixedString512Bytes>
  6495. , IEquatable<FixedString512Bytes>
  6496. , IComparable<FixedString4096Bytes>
  6497. , IEquatable<FixedString4096Bytes>
  6498. {
  6499. internal const ushort utf8MaxLengthInBytes = 4093;
  6500. [SerializeField] internal ushort utf8LengthInBytes;
  6501. [SerializeField] internal FixedBytes4094 bytes;
  6502. /// <summary>
  6503. /// Returns the maximum number of UTF-8 bytes that can be stored in this string.
  6504. /// </summary>
  6505. /// <returns>
  6506. /// The maximum number of UTF-8 bytes that can be stored in this string.
  6507. /// </returns>
  6508. public static int UTF8MaxLengthInBytes => utf8MaxLengthInBytes;
  6509. /// <summary>
  6510. /// For internal use only. Use <see cref="ToString"/> instead.
  6511. /// </summary>
  6512. /// <value>For internal use only. Use <see cref="ToString"/> instead.</value>
  6513. [CreateProperty]
  6514. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  6515. [ExcludeFromBurstCompatTesting("Returns managed string")]
  6516. public string Value => ToString();
  6517. /// <summary>
  6518. /// Returns a pointer to the character bytes.
  6519. /// </summary>
  6520. /// <remarks>
  6521. /// The pointer returned by this method points into the internals of the target FixedString object. It is the
  6522. /// caller's responsibility to ensure that the pointer is not used after the FixedString object is destroyed or goes
  6523. /// out of scope.
  6524. /// </remarks>
  6525. /// <returns>A pointer to the character bytes.</returns>
  6526. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6527. public readonly unsafe byte* GetUnsafePtr()
  6528. {
  6529. fixed(void* b = &bytes)
  6530. return (byte*)b;
  6531. }
  6532. /// <summary>
  6533. /// The current length in bytes of this string's content.
  6534. /// </summary>
  6535. /// <remarks>
  6536. /// The length value does not include the null-terminator byte.
  6537. /// </remarks>
  6538. /// <param name="value">The new length in bytes of the string's content.</param>
  6539. /// <exception cref="ArgumentOutOfRangeException">Thrown if the new length is out of bounds.</exception>
  6540. /// <value>
  6541. /// The current length in bytes of this string's content.
  6542. /// </value>
  6543. public int Length
  6544. {
  6545. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6546. readonly get
  6547. {
  6548. return utf8LengthInBytes;
  6549. }
  6550. set
  6551. {
  6552. CheckLengthInRange(value);
  6553. utf8LengthInBytes = (ushort)value;
  6554. unsafe
  6555. {
  6556. GetUnsafePtr()[utf8LengthInBytes] = 0;
  6557. }
  6558. }
  6559. }
  6560. /// <summary>
  6561. /// The number of bytes this string has for storing UTF-8 characters.
  6562. /// </summary>
  6563. /// <value>The number of bytes this string has for storing UTF-8 characters.</value>
  6564. /// <remarks>
  6565. /// Does not include the null-terminator byte.
  6566. ///
  6567. /// A setter is included for conformity with <see cref="INativeList{T}"/>, but <see cref="Capacity"/> is fixed at 4093.
  6568. /// Setting the value to anything other than 4093 throws an exception.
  6569. ///
  6570. /// In UTF-8 encoding, each Unicode code point (character) requires 1 to 4 bytes,
  6571. /// so the number of characters that can be stored may be less than the capacity.
  6572. /// </remarks>
  6573. /// <exception cref="ArgumentOutOfRangeException">Thrown if attempting to set the capacity to anything other than 4093.</exception>
  6574. public int Capacity
  6575. {
  6576. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6577. readonly get
  6578. {
  6579. return utf8MaxLengthInBytes;
  6580. }
  6581. set
  6582. {
  6583. CheckCapacityInRange(value);
  6584. }
  6585. }
  6586. /// <summary>
  6587. /// Attempts to set the length in bytes. Does nothing if the new length is invalid.
  6588. /// </summary>
  6589. /// <param name="newLength">The desired length.</param>
  6590. /// <param name="clearOptions">Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)</param>
  6591. /// <returns>True if the new length is valid.</returns>
  6592. public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
  6593. {
  6594. if (newLength < 0 || newLength > utf8MaxLengthInBytes)
  6595. return false;
  6596. if (newLength == utf8LengthInBytes)
  6597. return true;
  6598. unsafe
  6599. {
  6600. if (clearOptions == NativeArrayOptions.ClearMemory)
  6601. {
  6602. if (newLength > utf8LengthInBytes)
  6603. UnsafeUtility.MemClear(GetUnsafePtr() + utf8LengthInBytes, newLength - utf8LengthInBytes);
  6604. else
  6605. UnsafeUtility.MemClear(GetUnsafePtr() + newLength, utf8LengthInBytes - newLength);
  6606. }
  6607. utf8LengthInBytes = (ushort)newLength;
  6608. // always null terminate
  6609. GetUnsafePtr()[utf8LengthInBytes] = 0;
  6610. }
  6611. return true;
  6612. }
  6613. /// <summary>
  6614. /// Returns true if this string is empty (has no characters).
  6615. /// </summary>
  6616. /// <value>True if this string is empty (has no characters).</value>
  6617. public readonly bool IsEmpty
  6618. {
  6619. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6620. get => utf8LengthInBytes == 0;
  6621. }
  6622. /// <summary>
  6623. /// Returns the byte (not character) at an index.
  6624. /// </summary>
  6625. /// <param name="index">A byte index.</param>
  6626. /// <value>The byte at the index.</value>
  6627. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  6628. public byte this[int index]
  6629. {
  6630. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6631. readonly get
  6632. {
  6633. unsafe
  6634. {
  6635. CheckIndexInRange(index);
  6636. return GetUnsafePtr()[index];
  6637. }
  6638. }
  6639. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6640. set
  6641. {
  6642. unsafe
  6643. {
  6644. CheckIndexInRange(index);
  6645. GetUnsafePtr()[index] = value;
  6646. }
  6647. }
  6648. }
  6649. /// <summary>
  6650. /// Returns the reference to a byte (not character) at an index.
  6651. /// </summary>
  6652. /// <param name="index">A byte index.</param>
  6653. /// <returns>A reference to the byte at the index.</returns>
  6654. /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of bounds.</exception>
  6655. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6656. public ref byte ElementAt(int index)
  6657. {
  6658. unsafe
  6659. {
  6660. CheckIndexInRange(index);
  6661. return ref GetUnsafePtr()[index];
  6662. }
  6663. }
  6664. /// <summary>
  6665. /// Sets the length to 0.
  6666. /// </summary>
  6667. public void Clear()
  6668. {
  6669. Length = 0;
  6670. }
  6671. /// <summary>
  6672. /// Appends a byte.
  6673. /// </summary>
  6674. /// <remarks>
  6675. /// A zero byte will always follow the newly appended byte.
  6676. ///
  6677. /// No validation is performed: it is your responsibility for the bytes of the string to form valid UTF-8 when you're done appending bytes.
  6678. /// </remarks>
  6679. /// <param name="value">A byte to append.</param>
  6680. public void Add(in byte value)
  6681. {
  6682. this[Length++] = value;
  6683. }
  6684. /// <summary>
  6685. /// An enumerator over the characters (not bytes) of a FixedString4096Bytes.
  6686. /// </summary>
  6687. /// <remarks>
  6688. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  6689. /// The first <see cref="MoveNext"/> call advances the enumerator's index to the first character.
  6690. /// </remarks>
  6691. public struct Enumerator : IEnumerator
  6692. {
  6693. FixedString4096Bytes target;
  6694. int offset;
  6695. Unicode.Rune current;
  6696. /// <summary>
  6697. /// Initializes and returns an instance of FixedString4096Bytes.Enumerator.
  6698. /// </summary>
  6699. /// <param name="other">A FixeString4096 for which to create an enumerator.</param>
  6700. public Enumerator(FixedString4096Bytes other)
  6701. {
  6702. target = other;
  6703. offset = 0;
  6704. current = default;
  6705. }
  6706. /// <summary>
  6707. /// Does nothing.
  6708. /// </summary>
  6709. public void Dispose()
  6710. {
  6711. }
  6712. /// <summary>
  6713. /// Advances the enumerator to the next character.
  6714. /// </summary>
  6715. /// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
  6716. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6717. public bool MoveNext()
  6718. {
  6719. if (offset >= target.Length)
  6720. return false;
  6721. unsafe
  6722. {
  6723. Unicode.Utf8ToUcs(out current, target.GetUnsafePtr(), ref offset, target.Length);
  6724. }
  6725. return true;
  6726. }
  6727. /// <summary>
  6728. /// Resets the enumerator to its initial state.
  6729. /// </summary>
  6730. public void Reset()
  6731. {
  6732. offset = 0;
  6733. current = default;
  6734. }
  6735. /// <summary>
  6736. /// The current character.
  6737. /// </summary>
  6738. /// <remarks>
  6739. /// In an enumerator's initial state, <see cref="Current"/> is not valid to read.
  6740. /// </remarks>
  6741. /// <value>The current character.</value>
  6742. public Unicode.Rune Current
  6743. {
  6744. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  6745. get => current;
  6746. }
  6747. object IEnumerator.Current => Current;
  6748. }
  6749. /// <summary>
  6750. /// Returns an enumerator for iterating over the characters of this string.
  6751. /// </summary>
  6752. /// <returns>An enumerator for iterating over the characters of the FixedString4096Bytes.</returns>
  6753. public Enumerator GetEnumerator()
  6754. {
  6755. return new Enumerator(this);
  6756. }
  6757. /// <summary>
  6758. /// Returns the lexicographical sort order of this string relative to another.
  6759. /// </summary>
  6760. /// <param name="other">A `System.String` to compare with.</param>
  6761. /// <returns>An integer denoting the lexicographical sort order of this string relative to the other:
  6762. ///
  6763. /// 0 denotes both strings have the same sort position.<br/>
  6764. /// -1 denotes that this string should be sorted to precede the other string.<br/>
  6765. /// +1 denotes that this string should be sorted to follow the other string.<br/>
  6766. /// </returns>
  6767. [ExcludeFromBurstCompatTesting("Takes managed string")]
  6768. public int CompareTo(String other)
  6769. {
  6770. return ToString().CompareTo(other);
  6771. }
  6772. /// <summary>
  6773. /// Returns true if this string and another have the same length and all the same characters.
  6774. /// </summary>
  6775. /// <param name="other">A string to compare for equality.</param>
  6776. /// <returns>True if this string and the other have the same length and all the same characters.</returns>
  6777. [ExcludeFromBurstCompatTesting("Takes managed string")]
  6778. public bool Equals(String other)
  6779. {
  6780. unsafe {
  6781. int alen = utf8LengthInBytes;
  6782. int blen = other.Length;
  6783. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(bytes);
  6784. fixed(char* bptr = other)
  6785. {
  6786. return UTF8ArrayUnsafeUtility.StrCmp(aptr, alen, bptr, blen) == 0;
  6787. }
  6788. }
  6789. }
  6790. /// <summary>
  6791. /// Returns a reference to a FixedList4096Bytes&lt;byte&gt; representation of this string.
  6792. /// </summary>
  6793. /// <remarks>
  6794. /// The referenced FixedListByte4096 is the very same bytes as the original FixedString4096Bytes,
  6795. /// so it is only valid as long as the original FixedString4096Bytes is valid.
  6796. /// </remarks>
  6797. /// <returns>A ref to a FixedListByte4096 representation of the FixedString4096Bytes.</returns>
  6798. public unsafe ref FixedList4096Bytes<byte> AsFixedList()
  6799. {
  6800. return ref UnsafeUtility.AsRef<FixedList4096Bytes<byte>>(UnsafeUtility.AddressOf(ref this));
  6801. }
  6802. /// <summary>
  6803. /// Initializes and returns an instance of FixedString4096Bytes with the characters copied from a string.
  6804. /// </summary>
  6805. /// <param name="source">The source string to copy.</param>
  6806. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  6807. [ExcludeFromBurstCompatTesting("Takes managed string")]
  6808. public FixedString4096Bytes(String source)
  6809. {
  6810. this = default;
  6811. var error = Initialize(source);
  6812. CheckCopyError(error, source);
  6813. }
  6814. /// <summary>
  6815. /// Initializes an instance of FixedString4096Bytes with the characters copied from a string.
  6816. /// </summary>
  6817. /// <param name="source">The source string to copy.</param>
  6818. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, only the portion that fits is copied in and CopyError.Truncation is returned.</returns>
  6819. [ExcludeFromBurstCompatTesting("Takes managed string")]
  6820. internal CopyError Initialize(String source)
  6821. {
  6822. return this.CopyFromTruncated(source);
  6823. }
  6824. /// <summary>
  6825. /// Initializes and returns an instance of FixedString4096Bytes with a single character repeatedly appended some number of times.
  6826. /// </summary>
  6827. /// <param name="rune">The Unicode.Rune to repeat.</param>
  6828. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  6829. public FixedString4096Bytes(Unicode.Rune rune, int count = 1)
  6830. {
  6831. this = default;
  6832. Initialize(rune, count);
  6833. }
  6834. /// <summary>
  6835. /// Initializes an instance of FixedString4096Bytes with a single character repeatedly appended some number of times.
  6836. /// </summary>
  6837. /// <param name="rune">The Unicode.Rune to repeat.</param>
  6838. /// <param name="count">The number of times to repeat the character. Default is 1.</param>
  6839. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  6840. internal FormatError Initialize(Unicode.Rune rune, int count = 1)
  6841. {
  6842. this = default;
  6843. return this.Append(rune, count);
  6844. }
  6845. /// <summary>
  6846. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  6847. /// </summary>
  6848. /// <param name="srcBytes">The source buffer.</param>
  6849. /// <param name="srcLength">The number of bytes to read from the source.</param>
  6850. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  6851. unsafe internal FormatError Initialize(byte* srcBytes, int srcLength)
  6852. {
  6853. bytes = default;
  6854. utf8LengthInBytes = 0;
  6855. unsafe {
  6856. int len = 0;
  6857. byte* dstBytes = GetUnsafePtr();
  6858. var error = UTF8ArrayUnsafeUtility.AppendUTF8Bytes(dstBytes, ref len, utf8MaxLengthInBytes, srcBytes, srcLength);
  6859. if(error != FormatError.None)
  6860. return error;
  6861. this.Length = len;
  6862. }
  6863. return FormatError.None;
  6864. }
  6865. /// <summary>
  6866. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  6867. /// </summary>
  6868. /// <param name="other">The string to copy.</param>
  6869. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  6870. unsafe public FixedString4096Bytes(NativeText.ReadOnly other)
  6871. {
  6872. this = default;
  6873. var error = Initialize(other.GetUnsafePtr(), other.Length);
  6874. CheckFormatError(error);
  6875. }
  6876. /// <summary>
  6877. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  6878. /// </summary>
  6879. /// <param name="other">The UnsafeText to copy.</param>
  6880. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  6881. unsafe public FixedString4096Bytes(in UnsafeText other)
  6882. {
  6883. this = default;
  6884. var error = Initialize(other.GetUnsafePtr(), other.Length);
  6885. CheckFormatError(error);
  6886. }
  6887. /// <summary>
  6888. /// Returns the lexicographical sort order of this string relative to another.
  6889. /// </summary>
  6890. /// <param name="other">A string to compare with.</param>
  6891. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  6892. ///
  6893. /// 0 denotes that both strings have the same sort position.<br/>
  6894. /// -1 denotes that this string should be sorted to precede the other.<br/>
  6895. /// +1 denotes that this string should be sorted to follow the other.<br/>
  6896. /// </returns>
  6897. public int CompareTo(FixedString32Bytes other)
  6898. {
  6899. return FixedStringMethods.CompareTo(ref this, other);
  6900. }
  6901. /// <summary>
  6902. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  6903. /// </summary>
  6904. /// <param name="other">The string to copy.</param>
  6905. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  6906. public FixedString4096Bytes(in FixedString32Bytes other)
  6907. {
  6908. this = default;
  6909. var error = Initialize(other);
  6910. CheckFormatError(error);
  6911. }
  6912. /// <summary>
  6913. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  6914. /// </summary>
  6915. /// <param name="other">The string to copy.</param>
  6916. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  6917. unsafe internal FormatError Initialize(in FixedString32Bytes other)
  6918. {
  6919. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  6920. }
  6921. /// <summary>
  6922. /// Returns true if a FixedString4096Bytes and another string are equal.
  6923. /// </summary>
  6924. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  6925. /// <param name="a">A FixedString4096Bytes to compare for equality.</param>
  6926. /// <param name="b">A FixedString32Bytes to compare for equality.</param>
  6927. /// <returns>True if the two strings are equal.</returns>
  6928. public static bool operator ==(in FixedString4096Bytes a, in FixedString32Bytes b)
  6929. {
  6930. // this must not call any methods on 'a' or 'b'
  6931. unsafe {
  6932. int alen = a.utf8LengthInBytes;
  6933. int blen = b.utf8LengthInBytes;
  6934. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  6935. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  6936. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  6937. }
  6938. }
  6939. /// <summary>
  6940. /// Returns true if a FixedString4096Bytes and another string are unequal.
  6941. /// </summary>
  6942. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  6943. /// <param name="a">A FixedString4096Bytes to compare for inequality.</param>
  6944. /// <param name="b">A FixedString32Bytes to compare for inequality.</param>
  6945. /// <returns>True if the two strings are unequal.</returns>
  6946. public static bool operator !=(in FixedString4096Bytes a, in FixedString32Bytes b)
  6947. {
  6948. return !(a == b);
  6949. }
  6950. /// <summary>
  6951. /// Returns true if this string and another string are equal.
  6952. /// </summary>
  6953. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  6954. /// <param name="other">A FixedString32Bytes to compare for equality.</param>
  6955. /// <returns>True if the two strings are equal.</returns>
  6956. public bool Equals(FixedString32Bytes other)
  6957. {
  6958. return this == other;
  6959. }
  6960. /// <summary>
  6961. /// Returns the lexicographical sort order of this string relative to another.
  6962. /// </summary>
  6963. /// <param name="other">A string to compare with.</param>
  6964. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  6965. ///
  6966. /// 0 denotes that both strings have the same sort position.<br/>
  6967. /// -1 denotes that this string should be sorted to precede the other.<br/>
  6968. /// +1 denotes that this string should be sorted to follow the other.<br/>
  6969. /// </returns>
  6970. public int CompareTo(FixedString64Bytes other)
  6971. {
  6972. return FixedStringMethods.CompareTo(ref this, other);
  6973. }
  6974. /// <summary>
  6975. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  6976. /// </summary>
  6977. /// <param name="other">The string to copy.</param>
  6978. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  6979. public FixedString4096Bytes(in FixedString64Bytes other)
  6980. {
  6981. this = default;
  6982. var error = Initialize(other);
  6983. CheckFormatError(error);
  6984. }
  6985. /// <summary>
  6986. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  6987. /// </summary>
  6988. /// <param name="other">The string to copy.</param>
  6989. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  6990. unsafe internal FormatError Initialize(in FixedString64Bytes other)
  6991. {
  6992. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  6993. }
  6994. /// <summary>
  6995. /// Returns true if a FixedString4096Bytes and another string are equal.
  6996. /// </summary>
  6997. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  6998. /// <param name="a">A FixedString4096Bytes to compare for equality.</param>
  6999. /// <param name="b">A FixedString64Bytes to compare for equality.</param>
  7000. /// <returns>True if the two strings are equal.</returns>
  7001. public static bool operator ==(in FixedString4096Bytes a, in FixedString64Bytes b)
  7002. {
  7003. // this must not call any methods on 'a' or 'b'
  7004. unsafe {
  7005. int alen = a.utf8LengthInBytes;
  7006. int blen = b.utf8LengthInBytes;
  7007. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  7008. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  7009. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  7010. }
  7011. }
  7012. /// <summary>
  7013. /// Returns true if a FixedString4096Bytes and another string are unequal.
  7014. /// </summary>
  7015. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7016. /// <param name="a">A FixedString4096Bytes to compare for inequality.</param>
  7017. /// <param name="b">A FixedString64Bytes to compare for inequality.</param>
  7018. /// <returns>True if the two strings are unequal.</returns>
  7019. public static bool operator !=(in FixedString4096Bytes a, in FixedString64Bytes b)
  7020. {
  7021. return !(a == b);
  7022. }
  7023. /// <summary>
  7024. /// Returns true if this string and another string are equal.
  7025. /// </summary>
  7026. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7027. /// <param name="other">A FixedString64Bytes to compare for equality.</param>
  7028. /// <returns>True if the two strings are equal.</returns>
  7029. public bool Equals(FixedString64Bytes other)
  7030. {
  7031. return this == other;
  7032. }
  7033. /// <summary>
  7034. /// Returns the lexicographical sort order of this string relative to another.
  7035. /// </summary>
  7036. /// <param name="other">A string to compare with.</param>
  7037. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  7038. ///
  7039. /// 0 denotes that both strings have the same sort position.<br/>
  7040. /// -1 denotes that this string should be sorted to precede the other.<br/>
  7041. /// +1 denotes that this string should be sorted to follow the other.<br/>
  7042. /// </returns>
  7043. public int CompareTo(FixedString128Bytes other)
  7044. {
  7045. return FixedStringMethods.CompareTo(ref this, other);
  7046. }
  7047. /// <summary>
  7048. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  7049. /// </summary>
  7050. /// <param name="other">The string to copy.</param>
  7051. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  7052. public FixedString4096Bytes(in FixedString128Bytes other)
  7053. {
  7054. this = default;
  7055. var error = Initialize(other);
  7056. CheckFormatError(error);
  7057. }
  7058. /// <summary>
  7059. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  7060. /// </summary>
  7061. /// <param name="other">The string to copy.</param>
  7062. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  7063. unsafe internal FormatError Initialize(in FixedString128Bytes other)
  7064. {
  7065. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  7066. }
  7067. /// <summary>
  7068. /// Returns true if a FixedString4096Bytes and another string are equal.
  7069. /// </summary>
  7070. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7071. /// <param name="a">A FixedString4096Bytes to compare for equality.</param>
  7072. /// <param name="b">A FixedString128Bytes to compare for equality.</param>
  7073. /// <returns>True if the two strings are equal.</returns>
  7074. public static bool operator ==(in FixedString4096Bytes a, in FixedString128Bytes b)
  7075. {
  7076. // this must not call any methods on 'a' or 'b'
  7077. unsafe {
  7078. int alen = a.utf8LengthInBytes;
  7079. int blen = b.utf8LengthInBytes;
  7080. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  7081. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  7082. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  7083. }
  7084. }
  7085. /// <summary>
  7086. /// Returns true if a FixedString4096Bytes and another string are unequal.
  7087. /// </summary>
  7088. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7089. /// <param name="a">A FixedString4096Bytes to compare for inequality.</param>
  7090. /// <param name="b">A FixedString128Bytes to compare for inequality.</param>
  7091. /// <returns>True if the two strings are unequal.</returns>
  7092. public static bool operator !=(in FixedString4096Bytes a, in FixedString128Bytes b)
  7093. {
  7094. return !(a == b);
  7095. }
  7096. /// <summary>
  7097. /// Returns true if this string and another string are equal.
  7098. /// </summary>
  7099. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7100. /// <param name="other">A FixedString128Bytes to compare for equality.</param>
  7101. /// <returns>True if the two strings are equal.</returns>
  7102. public bool Equals(FixedString128Bytes other)
  7103. {
  7104. return this == other;
  7105. }
  7106. /// <summary>
  7107. /// Returns the lexicographical sort order of this string relative to another.
  7108. /// </summary>
  7109. /// <param name="other">A string to compare with.</param>
  7110. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  7111. ///
  7112. /// 0 denotes that both strings have the same sort position.<br/>
  7113. /// -1 denotes that this string should be sorted to precede the other.<br/>
  7114. /// +1 denotes that this string should be sorted to follow the other.<br/>
  7115. /// </returns>
  7116. public int CompareTo(FixedString512Bytes other)
  7117. {
  7118. return FixedStringMethods.CompareTo(ref this, other);
  7119. }
  7120. /// <summary>
  7121. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  7122. /// </summary>
  7123. /// <param name="other">The string to copy.</param>
  7124. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  7125. public FixedString4096Bytes(in FixedString512Bytes other)
  7126. {
  7127. this = default;
  7128. var error = Initialize(other);
  7129. CheckFormatError(error);
  7130. }
  7131. /// <summary>
  7132. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  7133. /// </summary>
  7134. /// <param name="other">The string to copy.</param>
  7135. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  7136. unsafe internal FormatError Initialize(in FixedString512Bytes other)
  7137. {
  7138. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  7139. }
  7140. /// <summary>
  7141. /// Returns true if a FixedString4096Bytes and another string are equal.
  7142. /// </summary>
  7143. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7144. /// <param name="a">A FixedString4096Bytes to compare for equality.</param>
  7145. /// <param name="b">A FixedString512Bytes to compare for equality.</param>
  7146. /// <returns>True if the two strings are equal.</returns>
  7147. public static bool operator ==(in FixedString4096Bytes a, in FixedString512Bytes b)
  7148. {
  7149. // this must not call any methods on 'a' or 'b'
  7150. unsafe {
  7151. int alen = a.utf8LengthInBytes;
  7152. int blen = b.utf8LengthInBytes;
  7153. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  7154. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  7155. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  7156. }
  7157. }
  7158. /// <summary>
  7159. /// Returns true if a FixedString4096Bytes and another string are unequal.
  7160. /// </summary>
  7161. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7162. /// <param name="a">A FixedString4096Bytes to compare for inequality.</param>
  7163. /// <param name="b">A FixedString512Bytes to compare for inequality.</param>
  7164. /// <returns>True if the two strings are unequal.</returns>
  7165. public static bool operator !=(in FixedString4096Bytes a, in FixedString512Bytes b)
  7166. {
  7167. return !(a == b);
  7168. }
  7169. /// <summary>
  7170. /// Returns true if this string and another string are equal.
  7171. /// </summary>
  7172. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7173. /// <param name="other">A FixedString512Bytes to compare for equality.</param>
  7174. /// <returns>True if the two strings are equal.</returns>
  7175. public bool Equals(FixedString512Bytes other)
  7176. {
  7177. return this == other;
  7178. }
  7179. /// <summary>
  7180. /// Returns the lexicographical sort order of this string relative to another.
  7181. /// </summary>
  7182. /// <param name="other">A string to compare with.</param>
  7183. /// <returns>A number denoting the lexicographical sort order of this string relative to the other:
  7184. ///
  7185. /// 0 denotes that both strings have the same sort position.<br/>
  7186. /// -1 denotes that this string should be sorted to precede the other.<br/>
  7187. /// +1 denotes that this string should be sorted to follow the other.<br/>
  7188. /// </returns>
  7189. public int CompareTo(FixedString4096Bytes other)
  7190. {
  7191. return FixedStringMethods.CompareTo(ref this, other);
  7192. }
  7193. /// <summary>
  7194. /// Initializes and returns an instance of FixedString4096Bytes that is a copy of another string.
  7195. /// </summary>
  7196. /// <param name="other">The string to copy.</param>
  7197. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  7198. public FixedString4096Bytes(in FixedString4096Bytes other)
  7199. {
  7200. this = default;
  7201. var error = Initialize(other);
  7202. CheckFormatError(error);
  7203. }
  7204. /// <summary>
  7205. /// Initializes an instance of FixedString4096Bytes that is a copy of another string.
  7206. /// </summary>
  7207. /// <param name="other">The string to copy.</param>
  7208. /// <returns>If the length of the source string exceeds this fixed string's UTF8 capacity, the entire write operation will fail, and FormatError.Overflow is returned.</returns>
  7209. unsafe internal FormatError Initialize(in FixedString4096Bytes other)
  7210. {
  7211. return Initialize((byte*) UnsafeUtilityExtensions.AddressOf(other.bytes), other.utf8LengthInBytes);
  7212. }
  7213. /// <summary>
  7214. /// Returns true if a FixedString4096Bytes and another string are equal.
  7215. /// </summary>
  7216. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7217. /// <param name="a">A FixedString4096Bytes to compare for equality.</param>
  7218. /// <param name="b">A FixedString4096Bytes to compare for equality.</param>
  7219. /// <returns>True if the two strings are equal.</returns>
  7220. public static bool operator ==(in FixedString4096Bytes a, in FixedString4096Bytes b)
  7221. {
  7222. // this must not call any methods on 'a' or 'b'
  7223. unsafe {
  7224. int alen = a.utf8LengthInBytes;
  7225. int blen = b.utf8LengthInBytes;
  7226. byte* aptr = (byte*) UnsafeUtilityExtensions.AddressOf(a.bytes);
  7227. byte* bptr = (byte*) UnsafeUtilityExtensions.AddressOf(b.bytes);
  7228. return UTF8ArrayUnsafeUtility.EqualsUTF8Bytes(aptr, alen, bptr, blen);
  7229. }
  7230. }
  7231. /// <summary>
  7232. /// Returns true if a FixedString4096Bytes and another string are unequal.
  7233. /// </summary>
  7234. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7235. /// <param name="a">A FixedString4096Bytes to compare for inequality.</param>
  7236. /// <param name="b">A FixedString4096Bytes to compare for inequality.</param>
  7237. /// <returns>True if the two strings are unequal.</returns>
  7238. public static bool operator !=(in FixedString4096Bytes a, in FixedString4096Bytes b)
  7239. {
  7240. return !(a == b);
  7241. }
  7242. /// <summary>
  7243. /// Returns true if this string and another string are equal.
  7244. /// </summary>
  7245. /// <remarks>Two strings are equal if they have equal length and all their characters match.</remarks>
  7246. /// <param name="other">A FixedString4096Bytes to compare for equality.</param>
  7247. /// <returns>True if the two strings are equal.</returns>
  7248. public bool Equals(FixedString4096Bytes other)
  7249. {
  7250. return this == other;
  7251. }
  7252. /// <summary>
  7253. /// Returns a new FixedString4096Bytes that is a copy of another string.
  7254. /// </summary>
  7255. /// <param name="b">A string to copy.</param>
  7256. /// <returns>A new FixedString4096Bytes that is a copy of another string.</returns>
  7257. /// <exception cref="ArgumentException">Thrown if the string to copy's length exceeds the capacity of FixedString4096Bytes.</exception>
  7258. [ExcludeFromBurstCompatTesting("Takes managed string")]
  7259. public static implicit operator FixedString4096Bytes(string b) => new FixedString4096Bytes(b);
  7260. /// <summary>
  7261. /// Returns a new managed string that is a copy of this string.
  7262. /// </summary>
  7263. /// <returns>A new managed string that is a copy of this string.</returns>
  7264. [ExcludeFromBurstCompatTesting("Returns managed string")]
  7265. public override String ToString()
  7266. {
  7267. return this.ConvertToString();
  7268. }
  7269. /// <summary>
  7270. /// Returns a hash code of this string.
  7271. /// </summary>
  7272. /// <remarks>Only the character bytes are included in the hash: any bytes beyond <see cref="Length"/> are not part of the hash.</remarks>
  7273. /// <returns>The hash code of this string.</returns>
  7274. public override int GetHashCode()
  7275. {
  7276. return this.ComputeHashCode();
  7277. }
  7278. /// <summary>
  7279. /// Returns true if this string and an object are equal.
  7280. /// </summary>
  7281. /// <remarks>
  7282. /// Returns false if the object is neither a System.String or a FixedString.
  7283. ///
  7284. /// Two strings are equal if they have equal length and all their characters match.</remarks>
  7285. /// <param name="obj">An object to compare for equality.</param>
  7286. /// <returns>True if this string and the object are equal.</returns>
  7287. [ExcludeFromBurstCompatTesting("Takes managed object")]
  7288. public override bool Equals(object obj)
  7289. {
  7290. if(ReferenceEquals(null, obj)) return false;
  7291. if(obj is String aString) return Equals(aString);
  7292. if(obj is FixedString32Bytes aFixedString32Bytes) return Equals(aFixedString32Bytes);
  7293. if(obj is FixedString64Bytes aFixedString64Bytes) return Equals(aFixedString64Bytes);
  7294. if(obj is FixedString128Bytes aFixedString128Bytes) return Equals(aFixedString128Bytes);
  7295. if(obj is FixedString512Bytes aFixedString512Bytes) return Equals(aFixedString512Bytes);
  7296. if(obj is FixedString4096Bytes aFixedString4096Bytes) return Equals(aFixedString4096Bytes);
  7297. return false;
  7298. }
  7299. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  7300. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  7301. readonly void CheckIndexInRange(int index)
  7302. {
  7303. if (index < 0)
  7304. throw new IndexOutOfRangeException($"Index {index} must be positive.");
  7305. if (index >= utf8LengthInBytes)
  7306. throw new IndexOutOfRangeException($"Index {index} is out of range in FixedString4096Bytes of '{utf8LengthInBytes}' Length.");
  7307. }
  7308. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  7309. void CheckLengthInRange(int length)
  7310. {
  7311. if (length < 0)
  7312. throw new ArgumentOutOfRangeException($"Length {length} must be positive.");
  7313. if (length > utf8MaxLengthInBytes)
  7314. throw new ArgumentOutOfRangeException($"Length {length} is out of range in FixedString4096Bytes of '{utf8MaxLengthInBytes}' Capacity.");
  7315. }
  7316. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  7317. void CheckCapacityInRange(int capacity)
  7318. {
  7319. if (capacity > utf8MaxLengthInBytes)
  7320. throw new ArgumentOutOfRangeException($"Capacity {capacity} must be lower than {utf8MaxLengthInBytes}.");
  7321. }
  7322. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  7323. static void CheckCopyError(CopyError error, String source)
  7324. {
  7325. if (error != CopyError.None)
  7326. throw new ArgumentException($"FixedString4096Bytes: {error} while copying \"{source}\"");
  7327. }
  7328. [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")]
  7329. static void CheckFormatError(FormatError error)
  7330. {
  7331. if (error != FormatError.None)
  7332. throw new ArgumentException("Source is too long to fit into fixed string of this size");
  7333. }
  7334. }
  7335. }