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