mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
feat: Add CStringPointer#ExtractText
- Move CString extensions to their own class. - Add some words to our dictionary.
This commit is contained in:
parent
ddda4d477d
commit
314c046ec9
3 changed files with 34 additions and 10 deletions
32
Dalamud/Utility/CStringExtensions.cs
Normal file
32
Dalamud/Utility/CStringExtensions.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using InteropGenerator.Runtime;
|
||||
|
||||
using Lumina.Text.ReadOnly;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// A set of helpful utilities for working with <see cref="CStringPointer"/>s from ClientStructs.
|
||||
/// </summary>
|
||||
public static class CStringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert a CStringPointer to a ReadOnlySeStringSpan.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer to convert.</param>
|
||||
/// <returns>A span.</returns>
|
||||
public static unsafe ReadOnlySeStringSpan AsReadOnlySeStringSpan(this CStringPointer ptr)
|
||||
{
|
||||
return ptr.AsSpan();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract text from this CStringPointer following <see cref="ReadOnlySeStringSpan.ExtractText()"/>'s rules. Only
|
||||
/// useful for SeStrings.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The CStringPointer to process.</param>
|
||||
/// <returns>Extracted text.</returns>
|
||||
public static string ExtractText(this CStringPointer ptr)
|
||||
{
|
||||
return ptr.AsReadOnlySeStringSpan().ExtractText();
|
||||
}
|
||||
}
|
||||
|
|
@ -228,14 +228,4 @@ public static class SeStringExtensions
|
|||
var replaced = ReplaceText(new ReadOnlySeString(builder.GetViewAsMemory()), toFind, replacement);
|
||||
builder.Clear().Append(replaced);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a CStringPointer to a ReadOnySeStringSpan.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer to convert.</param>
|
||||
/// <returns>A span.</returns>
|
||||
public static unsafe ReadOnlySeStringSpan AsReadOnlySeStringSpan(this CStringPointer ptr)
|
||||
{
|
||||
return new ReadOnlySeStringSpan(ptr.Value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue