diff --git a/src/Generator/Utils/Utils.cs b/src/Generator/Utils/Utils.cs index 138dcdfd..e2e5b9bd 100644 --- a/src/Generator/Utils/Utils.cs +++ b/src/Generator/Utils/Utils.cs @@ -186,6 +186,25 @@ namespace CppSharp // Return char and concat substring. return char.ToUpper(s[0]) + s.Substring(1); } + + public static string ReplaceLineBreaks(this string lines, string replacement) + { + return lines.Replace("\r\n", replacement) + .Replace("\r", replacement) + .Replace("\n", replacement); + } + + /// + /// Get the string slice between the two indexes. + /// Inclusive for start index, exclusive for end index. + /// + public static string Slice(this string source, int start, int end) + { + if (end < 0) + end = source.Length + end; + + return source.Substring(start, end - start); + } } public static class AssemblyHelpers