Files
sbox-public/engine/Tools/ShaderProc/ShaderToken.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

58 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Facepunch.ShaderProc
{
class ShaderToken
{
public string Token;
public ShaderToken( string token )
{
Token = token;
}
public bool RemoveEverythingBefore( string expression )
{
var index = Token.IndexOf( expression );
if ( index >= 0 )
{
Token = Token.Substring( index + expression.Length );
return true;
}
return false;
}
public bool RemoveEverythingAfter( string expression )
{
var index = Token.IndexOf( expression );
if ( index >= 0 )
{
Token = Token.Substring( 0, index );
return true;
}
return false;
}
public bool RemoveEverythingBetween( string expStart, string expEnd, bool includingItself = true )
{
int extraTrail = includingItself ? expEnd.Length : 0;
var iS = Token.IndexOf( expStart );
var iE = Token.IndexOf( expEnd );
if ( iE >= 0 && iS >= 0 )
{
Token = Token.Remove( iS, iE - iS + extraTrail );
return true;
}
return false;
}
public override string ToString()
{
return Token;
}
}
}