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

FixedStringFormatMethods.gen.cs 54KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. 
  2. //------------------------------------------------------------------------------
  3. // <auto-generated>
  4. // This code was generated by a tool.
  5. //
  6. // TextTransform Samples/Packages/com.unity.collections/Unity.Collections/FixedStringFormatMethods.tt
  7. //
  8. // Changes to this file may cause incorrect behavior and will be lost if
  9. // the code is regenerated.
  10. // </auto-generated>
  11. //------------------------------------------------------------------------------
  12. using System;
  13. using Unity.Collections.LowLevel.Unsafe;
  14. namespace Unity.Collections
  15. {
  16. /// <summary>
  17. /// Provides extension methods for FixedString*N*Bytes.
  18. /// </summary>
  19. public unsafe static partial class FixedStringMethods
  20. {
  21. /// <summary>
  22. /// Interpolates strings into a format string and appends the result to this string.
  23. /// </summary>
  24. /// <remarks>
  25. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  26. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  27. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  28. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  29. ///
  30. /// The overloads of this method take up to ten strings to interpolate into the format string.
  31. /// </remarks>
  32. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  33. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  34. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  35. /// <param name="dest">The string to append to.</param>d
  36. /// <param name="format">A string to be interpolated and appended.</param>
  37. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  38. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  39. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/) })]
  40. public static unsafe FormatError AppendFormat<T, U, T0>(ref this T dest, in U format, in T0 arg0)
  41. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  42. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  43. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  44. {
  45. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  46. int formatLength = formatRef.Length;
  47. byte* formatBytes = formatRef.GetUnsafePtr();
  48. int i = 0;
  49. FormatError err = FormatError.None;
  50. while (i < formatLength)
  51. {
  52. byte currByte = formatBytes[i++];
  53. if (currByte == (byte)'{')
  54. {
  55. if (i < formatLength)
  56. currByte = formatBytes[i++];
  57. else
  58. return FormatError.BadFormatSpecifier;
  59. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  60. {
  61. switch (currByte - (byte)'0')
  62. {
  63. case 0: err = dest.Append(in arg0); break;
  64. default: err = FormatError.BadFormatSpecifier; break;
  65. }
  66. }
  67. else if (currByte == (byte)'{')
  68. err = dest.AppendRawByte(currByte);
  69. else
  70. err = FormatError.BadFormatSpecifier;
  71. }
  72. else if (currByte == (byte)'}')
  73. {
  74. if (i < formatLength)
  75. currByte = formatBytes[i++];
  76. else
  77. err = FormatError.BadFormatSpecifier;
  78. if (currByte == (byte)'}')
  79. err = dest.AppendRawByte(currByte);
  80. else
  81. err = FormatError.BadFormatSpecifier;
  82. }
  83. else
  84. err = dest.AppendRawByte(currByte);
  85. if (err != FormatError.None)
  86. return err;
  87. }
  88. return FormatError.None;
  89. }
  90. /// <summary>
  91. /// Interpolates strings into a format string and appends the result to this string.
  92. /// </summary>
  93. /// <remarks>
  94. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  95. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  96. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  97. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  98. ///
  99. /// The overloads of this method take up to ten strings to interpolate into the format string.
  100. /// </remarks>
  101. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  102. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  103. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  104. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  105. /// <param name="dest">The string to append to.</param>d
  106. /// <param name="format">A string to be interpolated and appended.</param>
  107. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  108. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  109. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  110. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/) })]
  111. public static unsafe FormatError AppendFormat<T, U, T0, T1>(ref this T dest, in U format, in T0 arg0, in T1 arg1)
  112. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  113. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  114. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  115. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  116. {
  117. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  118. int formatLength = formatRef.Length;
  119. byte* formatBytes = formatRef.GetUnsafePtr();
  120. int i = 0;
  121. FormatError err = FormatError.None;
  122. while (i < formatLength)
  123. {
  124. byte currByte = formatBytes[i++];
  125. if (currByte == (byte)'{')
  126. {
  127. if (i < formatLength)
  128. currByte = formatBytes[i++];
  129. else
  130. return FormatError.BadFormatSpecifier;
  131. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  132. {
  133. switch (currByte - (byte)'0')
  134. {
  135. case 0: err = dest.Append(in arg0); break;
  136. case 1: err = dest.Append(in arg1); break;
  137. default: err = FormatError.BadFormatSpecifier; break;
  138. }
  139. }
  140. else if (currByte == (byte)'{')
  141. err = dest.AppendRawByte(currByte);
  142. else
  143. err = FormatError.BadFormatSpecifier;
  144. }
  145. else if (currByte == (byte)'}')
  146. {
  147. if (i < formatLength)
  148. currByte = formatBytes[i++];
  149. else
  150. err = FormatError.BadFormatSpecifier;
  151. if (currByte == (byte)'}')
  152. err = dest.AppendRawByte(currByte);
  153. else
  154. err = FormatError.BadFormatSpecifier;
  155. }
  156. else
  157. err = dest.AppendRawByte(currByte);
  158. if (err != FormatError.None)
  159. return err;
  160. }
  161. return FormatError.None;
  162. }
  163. /// <summary>
  164. /// Interpolates strings into a format string and appends the result to this string.
  165. /// </summary>
  166. /// <remarks>
  167. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  168. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  169. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  170. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  171. ///
  172. /// The overloads of this method take up to ten strings to interpolate into the format string.
  173. /// </remarks>
  174. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  175. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  176. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  177. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  178. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  179. /// <param name="dest">The string to append to.</param>d
  180. /// <param name="format">A string to be interpolated and appended.</param>
  181. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  182. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  183. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  184. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  185. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/) })]
  186. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2)
  187. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  188. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  189. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  190. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  191. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  192. {
  193. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  194. int formatLength = formatRef.Length;
  195. byte* formatBytes = formatRef.GetUnsafePtr();
  196. int i = 0;
  197. FormatError err = FormatError.None;
  198. while (i < formatLength)
  199. {
  200. byte currByte = formatBytes[i++];
  201. if (currByte == (byte)'{')
  202. {
  203. if (i < formatLength)
  204. currByte = formatBytes[i++];
  205. else
  206. return FormatError.BadFormatSpecifier;
  207. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  208. {
  209. switch (currByte - (byte)'0')
  210. {
  211. case 0: err = dest.Append(in arg0); break;
  212. case 1: err = dest.Append(in arg1); break;
  213. case 2: err = dest.Append(in arg2); break;
  214. default: err = FormatError.BadFormatSpecifier; break;
  215. }
  216. }
  217. else if (currByte == (byte)'{')
  218. err = dest.AppendRawByte(currByte);
  219. else
  220. err = FormatError.BadFormatSpecifier;
  221. }
  222. else if (currByte == (byte)'}')
  223. {
  224. if (i < formatLength)
  225. currByte = formatBytes[i++];
  226. else
  227. err = FormatError.BadFormatSpecifier;
  228. if (currByte == (byte)'}')
  229. err = dest.AppendRawByte(currByte);
  230. else
  231. err = FormatError.BadFormatSpecifier;
  232. }
  233. else
  234. err = dest.AppendRawByte(currByte);
  235. if (err != FormatError.None)
  236. return err;
  237. }
  238. return FormatError.None;
  239. }
  240. /// <summary>
  241. /// Interpolates strings into a format string and appends the result to this string.
  242. /// </summary>
  243. /// <remarks>
  244. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  245. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  246. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  247. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  248. ///
  249. /// The overloads of this method take up to ten strings to interpolate into the format string.
  250. /// </remarks>
  251. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  252. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  253. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  254. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  255. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  256. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  257. /// <param name="dest">The string to append to.</param>d
  258. /// <param name="format">A string to be interpolated and appended.</param>
  259. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  260. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  261. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  262. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  263. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  264. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/) })]
  265. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3)
  266. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  267. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  268. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  269. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  270. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  271. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  272. {
  273. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  274. int formatLength = formatRef.Length;
  275. byte* formatBytes = formatRef.GetUnsafePtr();
  276. int i = 0;
  277. FormatError err = FormatError.None;
  278. while (i < formatLength)
  279. {
  280. byte currByte = formatBytes[i++];
  281. if (currByte == (byte)'{')
  282. {
  283. if (i < formatLength)
  284. currByte = formatBytes[i++];
  285. else
  286. return FormatError.BadFormatSpecifier;
  287. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  288. {
  289. switch (currByte - (byte)'0')
  290. {
  291. case 0: err = dest.Append(in arg0); break;
  292. case 1: err = dest.Append(in arg1); break;
  293. case 2: err = dest.Append(in arg2); break;
  294. case 3: err = dest.Append(in arg3); break;
  295. default: err = FormatError.BadFormatSpecifier; break;
  296. }
  297. }
  298. else if (currByte == (byte)'{')
  299. err = dest.AppendRawByte(currByte);
  300. else
  301. err = FormatError.BadFormatSpecifier;
  302. }
  303. else if (currByte == (byte)'}')
  304. {
  305. if (i < formatLength)
  306. currByte = formatBytes[i++];
  307. else
  308. err = FormatError.BadFormatSpecifier;
  309. if (currByte == (byte)'}')
  310. err = dest.AppendRawByte(currByte);
  311. else
  312. err = FormatError.BadFormatSpecifier;
  313. }
  314. else
  315. err = dest.AppendRawByte(currByte);
  316. if (err != FormatError.None)
  317. return err;
  318. }
  319. return FormatError.None;
  320. }
  321. /// <summary>
  322. /// Interpolates strings into a format string and appends the result to this string.
  323. /// </summary>
  324. /// <remarks>
  325. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  326. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  327. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  328. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  329. ///
  330. /// The overloads of this method take up to ten strings to interpolate into the format string.
  331. /// </remarks>
  332. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  333. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  334. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  335. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  336. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  337. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  338. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  339. /// <param name="dest">The string to append to.</param>d
  340. /// <param name="format">A string to be interpolated and appended.</param>
  341. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  342. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  343. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  344. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  345. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  346. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  347. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/) })]
  348. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4)
  349. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  350. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  351. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  352. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  353. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  354. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  355. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  356. {
  357. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  358. int formatLength = formatRef.Length;
  359. byte* formatBytes = formatRef.GetUnsafePtr();
  360. int i = 0;
  361. FormatError err = FormatError.None;
  362. while (i < formatLength)
  363. {
  364. byte currByte = formatBytes[i++];
  365. if (currByte == (byte)'{')
  366. {
  367. if (i < formatLength)
  368. currByte = formatBytes[i++];
  369. else
  370. return FormatError.BadFormatSpecifier;
  371. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  372. {
  373. switch (currByte - (byte)'0')
  374. {
  375. case 0: err = dest.Append(in arg0); break;
  376. case 1: err = dest.Append(in arg1); break;
  377. case 2: err = dest.Append(in arg2); break;
  378. case 3: err = dest.Append(in arg3); break;
  379. case 4: err = dest.Append(in arg4); break;
  380. default: err = FormatError.BadFormatSpecifier; break;
  381. }
  382. }
  383. else if (currByte == (byte)'{')
  384. err = dest.AppendRawByte(currByte);
  385. else
  386. err = FormatError.BadFormatSpecifier;
  387. }
  388. else if (currByte == (byte)'}')
  389. {
  390. if (i < formatLength)
  391. currByte = formatBytes[i++];
  392. else
  393. err = FormatError.BadFormatSpecifier;
  394. if (currByte == (byte)'}')
  395. err = dest.AppendRawByte(currByte);
  396. else
  397. err = FormatError.BadFormatSpecifier;
  398. }
  399. else
  400. err = dest.AppendRawByte(currByte);
  401. if (err != FormatError.None)
  402. return err;
  403. }
  404. return FormatError.None;
  405. }
  406. /// <summary>
  407. /// Interpolates strings into a format string and appends the result to this string.
  408. /// </summary>
  409. /// <remarks>
  410. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  411. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  412. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  413. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  414. ///
  415. /// The overloads of this method take up to ten strings to interpolate into the format string.
  416. /// </remarks>
  417. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  418. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  419. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  420. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  421. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  422. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  423. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  424. /// <typeparam name="T5">The type of value to interpolate into the format string.</typeparam>
  425. /// <param name="dest">The string to append to.</param>d
  426. /// <param name="format">A string to be interpolated and appended.</param>
  427. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  428. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  429. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  430. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  431. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  432. /// <param name="arg5">A FixedString*N*Bytes to interpolate into the format string.</param>
  433. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  434. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/), typeof(FixedString128Bytes /*T5*/) })]
  435. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4, T5>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5)
  436. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  437. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  438. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  439. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  440. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  441. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  442. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  443. where T5 : unmanaged, INativeList<byte>, IUTF8Bytes
  444. {
  445. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  446. int formatLength = formatRef.Length;
  447. byte* formatBytes = formatRef.GetUnsafePtr();
  448. int i = 0;
  449. FormatError err = FormatError.None;
  450. while (i < formatLength)
  451. {
  452. byte currByte = formatBytes[i++];
  453. if (currByte == (byte)'{')
  454. {
  455. if (i < formatLength)
  456. currByte = formatBytes[i++];
  457. else
  458. return FormatError.BadFormatSpecifier;
  459. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  460. {
  461. switch (currByte - (byte)'0')
  462. {
  463. case 0: err = dest.Append(in arg0); break;
  464. case 1: err = dest.Append(in arg1); break;
  465. case 2: err = dest.Append(in arg2); break;
  466. case 3: err = dest.Append(in arg3); break;
  467. case 4: err = dest.Append(in arg4); break;
  468. case 5: err = dest.Append(in arg5); break;
  469. default: err = FormatError.BadFormatSpecifier; break;
  470. }
  471. }
  472. else if (currByte == (byte)'{')
  473. err = dest.AppendRawByte(currByte);
  474. else
  475. err = FormatError.BadFormatSpecifier;
  476. }
  477. else if (currByte == (byte)'}')
  478. {
  479. if (i < formatLength)
  480. currByte = formatBytes[i++];
  481. else
  482. err = FormatError.BadFormatSpecifier;
  483. if (currByte == (byte)'}')
  484. err = dest.AppendRawByte(currByte);
  485. else
  486. err = FormatError.BadFormatSpecifier;
  487. }
  488. else
  489. err = dest.AppendRawByte(currByte);
  490. if (err != FormatError.None)
  491. return err;
  492. }
  493. return FormatError.None;
  494. }
  495. /// <summary>
  496. /// Interpolates strings into a format string and appends the result to this string.
  497. /// </summary>
  498. /// <remarks>
  499. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  500. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  501. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  502. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  503. ///
  504. /// The overloads of this method take up to ten strings to interpolate into the format string.
  505. /// </remarks>
  506. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  507. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  508. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  509. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  510. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  511. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  512. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  513. /// <typeparam name="T5">The type of value to interpolate into the format string.</typeparam>
  514. /// <typeparam name="T6">The type of value to interpolate into the format string.</typeparam>
  515. /// <param name="dest">The string to append to.</param>d
  516. /// <param name="format">A string to be interpolated and appended.</param>
  517. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  518. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  519. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  520. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  521. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  522. /// <param name="arg5">A FixedString*N*Bytes to interpolate into the format string.</param>
  523. /// <param name="arg6">A FixedString*N*Bytes to interpolate into the format string.</param>
  524. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  525. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/), typeof(FixedString128Bytes /*T5*/), typeof(FixedString128Bytes /*T6*/) })]
  526. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5, in T6 arg6)
  527. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  528. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  529. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  530. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  531. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  532. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  533. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  534. where T5 : unmanaged, INativeList<byte>, IUTF8Bytes
  535. where T6 : unmanaged, INativeList<byte>, IUTF8Bytes
  536. {
  537. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  538. int formatLength = formatRef.Length;
  539. byte* formatBytes = formatRef.GetUnsafePtr();
  540. int i = 0;
  541. FormatError err = FormatError.None;
  542. while (i < formatLength)
  543. {
  544. byte currByte = formatBytes[i++];
  545. if (currByte == (byte)'{')
  546. {
  547. if (i < formatLength)
  548. currByte = formatBytes[i++];
  549. else
  550. return FormatError.BadFormatSpecifier;
  551. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  552. {
  553. switch (currByte - (byte)'0')
  554. {
  555. case 0: err = dest.Append(in arg0); break;
  556. case 1: err = dest.Append(in arg1); break;
  557. case 2: err = dest.Append(in arg2); break;
  558. case 3: err = dest.Append(in arg3); break;
  559. case 4: err = dest.Append(in arg4); break;
  560. case 5: err = dest.Append(in arg5); break;
  561. case 6: err = dest.Append(in arg6); break;
  562. default: err = FormatError.BadFormatSpecifier; break;
  563. }
  564. }
  565. else if (currByte == (byte)'{')
  566. err = dest.AppendRawByte(currByte);
  567. else
  568. err = FormatError.BadFormatSpecifier;
  569. }
  570. else if (currByte == (byte)'}')
  571. {
  572. if (i < formatLength)
  573. currByte = formatBytes[i++];
  574. else
  575. err = FormatError.BadFormatSpecifier;
  576. if (currByte == (byte)'}')
  577. err = dest.AppendRawByte(currByte);
  578. else
  579. err = FormatError.BadFormatSpecifier;
  580. }
  581. else
  582. err = dest.AppendRawByte(currByte);
  583. if (err != FormatError.None)
  584. return err;
  585. }
  586. return FormatError.None;
  587. }
  588. /// <summary>
  589. /// Interpolates strings into a format string and appends the result to this string.
  590. /// </summary>
  591. /// <remarks>
  592. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  593. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  594. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  595. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  596. ///
  597. /// The overloads of this method take up to ten strings to interpolate into the format string.
  598. /// </remarks>
  599. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  600. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  601. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  602. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  603. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  604. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  605. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  606. /// <typeparam name="T5">The type of value to interpolate into the format string.</typeparam>
  607. /// <typeparam name="T6">The type of value to interpolate into the format string.</typeparam>
  608. /// <typeparam name="T7">The type of value to interpolate into the format string.</typeparam>
  609. /// <param name="dest">The string to append to.</param>d
  610. /// <param name="format">A string to be interpolated and appended.</param>
  611. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  612. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  613. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  614. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  615. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  616. /// <param name="arg5">A FixedString*N*Bytes to interpolate into the format string.</param>
  617. /// <param name="arg6">A FixedString*N*Bytes to interpolate into the format string.</param>
  618. /// <param name="arg7">A FixedString*N*Bytes to interpolate into the format string.</param>
  619. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  620. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/), typeof(FixedString128Bytes /*T5*/), typeof(FixedString128Bytes /*T6*/), typeof(FixedString128Bytes /*T7*/) })]
  621. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5, in T6 arg6, in T7 arg7)
  622. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  623. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  624. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  625. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  626. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  627. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  628. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  629. where T5 : unmanaged, INativeList<byte>, IUTF8Bytes
  630. where T6 : unmanaged, INativeList<byte>, IUTF8Bytes
  631. where T7 : unmanaged, INativeList<byte>, IUTF8Bytes
  632. {
  633. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  634. int formatLength = formatRef.Length;
  635. byte* formatBytes = formatRef.GetUnsafePtr();
  636. int i = 0;
  637. FormatError err = FormatError.None;
  638. while (i < formatLength)
  639. {
  640. byte currByte = formatBytes[i++];
  641. if (currByte == (byte)'{')
  642. {
  643. if (i < formatLength)
  644. currByte = formatBytes[i++];
  645. else
  646. return FormatError.BadFormatSpecifier;
  647. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  648. {
  649. switch (currByte - (byte)'0')
  650. {
  651. case 0: err = dest.Append(in arg0); break;
  652. case 1: err = dest.Append(in arg1); break;
  653. case 2: err = dest.Append(in arg2); break;
  654. case 3: err = dest.Append(in arg3); break;
  655. case 4: err = dest.Append(in arg4); break;
  656. case 5: err = dest.Append(in arg5); break;
  657. case 6: err = dest.Append(in arg6); break;
  658. case 7: err = dest.Append(in arg7); break;
  659. default: err = FormatError.BadFormatSpecifier; break;
  660. }
  661. }
  662. else if (currByte == (byte)'{')
  663. err = dest.AppendRawByte(currByte);
  664. else
  665. err = FormatError.BadFormatSpecifier;
  666. }
  667. else if (currByte == (byte)'}')
  668. {
  669. if (i < formatLength)
  670. currByte = formatBytes[i++];
  671. else
  672. err = FormatError.BadFormatSpecifier;
  673. if (currByte == (byte)'}')
  674. err = dest.AppendRawByte(currByte);
  675. else
  676. err = FormatError.BadFormatSpecifier;
  677. }
  678. else
  679. err = dest.AppendRawByte(currByte);
  680. if (err != FormatError.None)
  681. return err;
  682. }
  683. return FormatError.None;
  684. }
  685. /// <summary>
  686. /// Interpolates strings into a format string and appends the result to this string.
  687. /// </summary>
  688. /// <remarks>
  689. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  690. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  691. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  692. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  693. ///
  694. /// The overloads of this method take up to ten strings to interpolate into the format string.
  695. /// </remarks>
  696. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  697. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  698. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  699. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  700. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  701. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  702. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  703. /// <typeparam name="T5">The type of value to interpolate into the format string.</typeparam>
  704. /// <typeparam name="T6">The type of value to interpolate into the format string.</typeparam>
  705. /// <typeparam name="T7">The type of value to interpolate into the format string.</typeparam>
  706. /// <typeparam name="T8">The type of value to interpolate into the format string.</typeparam>
  707. /// <param name="dest">The string to append to.</param>d
  708. /// <param name="format">A string to be interpolated and appended.</param>
  709. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  710. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  711. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  712. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  713. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  714. /// <param name="arg5">A FixedString*N*Bytes to interpolate into the format string.</param>
  715. /// <param name="arg6">A FixedString*N*Bytes to interpolate into the format string.</param>
  716. /// <param name="arg7">A FixedString*N*Bytes to interpolate into the format string.</param>
  717. /// <param name="arg8">A FixedString*N*Bytes to interpolate into the format string.</param>
  718. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  719. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/), typeof(FixedString128Bytes /*T5*/), typeof(FixedString128Bytes /*T6*/), typeof(FixedString128Bytes /*T7*/), typeof(FixedString128Bytes /*T8*/) })]
  720. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5, in T6 arg6, in T7 arg7, in T8 arg8)
  721. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  722. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  723. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  724. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  725. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  726. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  727. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  728. where T5 : unmanaged, INativeList<byte>, IUTF8Bytes
  729. where T6 : unmanaged, INativeList<byte>, IUTF8Bytes
  730. where T7 : unmanaged, INativeList<byte>, IUTF8Bytes
  731. where T8 : unmanaged, INativeList<byte>, IUTF8Bytes
  732. {
  733. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  734. int formatLength = formatRef.Length;
  735. byte* formatBytes = formatRef.GetUnsafePtr();
  736. int i = 0;
  737. FormatError err = FormatError.None;
  738. while (i < formatLength)
  739. {
  740. byte currByte = formatBytes[i++];
  741. if (currByte == (byte)'{')
  742. {
  743. if (i < formatLength)
  744. currByte = formatBytes[i++];
  745. else
  746. return FormatError.BadFormatSpecifier;
  747. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  748. {
  749. switch (currByte - (byte)'0')
  750. {
  751. case 0: err = dest.Append(in arg0); break;
  752. case 1: err = dest.Append(in arg1); break;
  753. case 2: err = dest.Append(in arg2); break;
  754. case 3: err = dest.Append(in arg3); break;
  755. case 4: err = dest.Append(in arg4); break;
  756. case 5: err = dest.Append(in arg5); break;
  757. case 6: err = dest.Append(in arg6); break;
  758. case 7: err = dest.Append(in arg7); break;
  759. case 8: err = dest.Append(in arg8); break;
  760. default: err = FormatError.BadFormatSpecifier; break;
  761. }
  762. }
  763. else if (currByte == (byte)'{')
  764. err = dest.AppendRawByte(currByte);
  765. else
  766. err = FormatError.BadFormatSpecifier;
  767. }
  768. else if (currByte == (byte)'}')
  769. {
  770. if (i < formatLength)
  771. currByte = formatBytes[i++];
  772. else
  773. err = FormatError.BadFormatSpecifier;
  774. if (currByte == (byte)'}')
  775. err = dest.AppendRawByte(currByte);
  776. else
  777. err = FormatError.BadFormatSpecifier;
  778. }
  779. else
  780. err = dest.AppendRawByte(currByte);
  781. if (err != FormatError.None)
  782. return err;
  783. }
  784. return FormatError.None;
  785. }
  786. /// <summary>
  787. /// Interpolates strings into a format string and appends the result to this string.
  788. /// </summary>
  789. /// <remarks>
  790. /// Similar to `StringBuilder.AppendFormat` but with significant limitations:
  791. /// - Only supports FixedString*N*Bytes arguments. To use other string types, convert them to FixedString*N*Bytes first.
  792. /// - Only supports numeric format placeholders of the form `{0}` .. `{N}`.
  793. /// - No format modifiers (*e.g.* `{0:x}`) are supported.
  794. ///
  795. /// The overloads of this method take up to ten strings to interpolate into the format string.
  796. /// </remarks>
  797. /// <typeparam name="T">A FixedString*N*Bytes type.</typeparam>
  798. /// <typeparam name="U">A FixedString*N*Bytes type.</typeparam>
  799. /// <typeparam name="T0">The type of value to interpolate into the format string.</typeparam>
  800. /// <typeparam name="T1">The type of value to interpolate into the format string.</typeparam>
  801. /// <typeparam name="T2">The type of value to interpolate into the format string.</typeparam>
  802. /// <typeparam name="T3">The type of value to interpolate into the format string.</typeparam>
  803. /// <typeparam name="T4">The type of value to interpolate into the format string.</typeparam>
  804. /// <typeparam name="T5">The type of value to interpolate into the format string.</typeparam>
  805. /// <typeparam name="T6">The type of value to interpolate into the format string.</typeparam>
  806. /// <typeparam name="T7">The type of value to interpolate into the format string.</typeparam>
  807. /// <typeparam name="T8">The type of value to interpolate into the format string.</typeparam>
  808. /// <typeparam name="T9">The type of value to interpolate into the format string.</typeparam>
  809. /// <param name="dest">The string to append to.</param>d
  810. /// <param name="format">A string to be interpolated and appended.</param>
  811. /// <param name="arg0">A FixedString*N*Bytes to interpolate into the format string.</param>
  812. /// <param name="arg1">A FixedString*N*Bytes to interpolate into the format string.</param>
  813. /// <param name="arg2">A FixedString*N*Bytes to interpolate into the format string.</param>
  814. /// <param name="arg3">A FixedString*N*Bytes to interpolate into the format string.</param>
  815. /// <param name="arg4">A FixedString*N*Bytes to interpolate into the format string.</param>
  816. /// <param name="arg5">A FixedString*N*Bytes to interpolate into the format string.</param>
  817. /// <param name="arg6">A FixedString*N*Bytes to interpolate into the format string.</param>
  818. /// <param name="arg7">A FixedString*N*Bytes to interpolate into the format string.</param>
  819. /// <param name="arg8">A FixedString*N*Bytes to interpolate into the format string.</param>
  820. /// <param name="arg9">A FixedString*N*Bytes to interpolate into the format string.</param>
  821. /// <returns><see cref="FormatError.None"/> if successful. Otherwise returns the appropriate <see cref="FormatError"/>.</returns>
  822. [GenerateTestsForBurstCompatibility(GenericTypeArguments = new[] { typeof(FixedString128Bytes /*T*/), typeof(FixedString128Bytes /*U*/), typeof(FixedString128Bytes /*T0*/), typeof(FixedString128Bytes /*T1*/), typeof(FixedString128Bytes /*T2*/), typeof(FixedString128Bytes /*T3*/), typeof(FixedString128Bytes /*T4*/), typeof(FixedString128Bytes /*T5*/), typeof(FixedString128Bytes /*T6*/), typeof(FixedString128Bytes /*T7*/), typeof(FixedString128Bytes /*T8*/), typeof(FixedString128Bytes /*T9*/) })]
  823. public static unsafe FormatError AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref this T dest, in U format, in T0 arg0, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5, in T6 arg6, in T7 arg7, in T8 arg8, in T9 arg9)
  824. where T : unmanaged, INativeList<byte>, IUTF8Bytes
  825. where U : unmanaged, INativeList<byte>, IUTF8Bytes
  826. where T0 : unmanaged, INativeList<byte>, IUTF8Bytes
  827. where T1 : unmanaged, INativeList<byte>, IUTF8Bytes
  828. where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
  829. where T3 : unmanaged, INativeList<byte>, IUTF8Bytes
  830. where T4 : unmanaged, INativeList<byte>, IUTF8Bytes
  831. where T5 : unmanaged, INativeList<byte>, IUTF8Bytes
  832. where T6 : unmanaged, INativeList<byte>, IUTF8Bytes
  833. where T7 : unmanaged, INativeList<byte>, IUTF8Bytes
  834. where T8 : unmanaged, INativeList<byte>, IUTF8Bytes
  835. where T9 : unmanaged, INativeList<byte>, IUTF8Bytes
  836. {
  837. ref var formatRef = ref UnsafeUtilityExtensions.AsRef(in format);
  838. int formatLength = formatRef.Length;
  839. byte* formatBytes = formatRef.GetUnsafePtr();
  840. int i = 0;
  841. FormatError err = FormatError.None;
  842. while (i < formatLength)
  843. {
  844. byte currByte = formatBytes[i++];
  845. if (currByte == (byte)'{')
  846. {
  847. if (i < formatLength)
  848. currByte = formatBytes[i++];
  849. else
  850. return FormatError.BadFormatSpecifier;
  851. if (currByte >= (byte)'0' && currByte <= (byte)'9' && i < formatLength && formatBytes[i++] == (byte)'}')
  852. {
  853. switch (currByte - (byte)'0')
  854. {
  855. case 0: err = dest.Append(in arg0); break;
  856. case 1: err = dest.Append(in arg1); break;
  857. case 2: err = dest.Append(in arg2); break;
  858. case 3: err = dest.Append(in arg3); break;
  859. case 4: err = dest.Append(in arg4); break;
  860. case 5: err = dest.Append(in arg5); break;
  861. case 6: err = dest.Append(in arg6); break;
  862. case 7: err = dest.Append(in arg7); break;
  863. case 8: err = dest.Append(in arg8); break;
  864. case 9: err = dest.Append(in arg9); break;
  865. default: err = FormatError.BadFormatSpecifier; break;
  866. }
  867. }
  868. else if (currByte == (byte)'{')
  869. err = dest.AppendRawByte(currByte);
  870. else
  871. err = FormatError.BadFormatSpecifier;
  872. }
  873. else if (currByte == (byte)'}')
  874. {
  875. if (i < formatLength)
  876. currByte = formatBytes[i++];
  877. else
  878. err = FormatError.BadFormatSpecifier;
  879. if (currByte == (byte)'}')
  880. err = dest.AppendRawByte(currByte);
  881. else
  882. err = FormatError.BadFormatSpecifier;
  883. }
  884. else
  885. err = dest.AppendRawByte(currByte);
  886. if (err != FormatError.None)
  887. return err;
  888. }
  889. return FormatError.None;
  890. }
  891. }
  892. }