public static string ToCSharpString(this CXString unmanagedString) { var str = Marshal.PtrToStringAnsi(unmanagedString.data); clang.disposeString(unmanagedString); return(str); }
public static string ToString(this CXString str) { string retval = clang.getCString(str); clang.disposeString(str); return(retval); }
/// <summary> /// The ToStringAndDispose /// </summary> /// <param name="cxString">The cxString<see cref="CXString"/></param> /// <returns>The <see cref="string"/></returns> internal static string ToStringAndDispose(this CXString cxString) { var pString = clang.clang_getCString(cxString); string result = Marshal.PtrToStringAnsi(pString); clang.clang_disposeString(cxString); return(result); }
/// <summary> /// Convert to Managed String /// </summary> /// <param name="string">Native Clang String</param> /// <param name="encoding">Default Encoding Type</param> /// <returns>Managed String</returns> internal static string ToManaged(this CXString @string, string encoding = "utf-8") { var char_ptr = LibClang.clang_getCString(@string); var str = char_ptr.ToManagedString(encoding); return(str); }
/// <summary> /// Initializes a new instance of the <see cref="TargetInfo"/> class. /// </summary> /// <param name="value">The value<see cref="IntPtr"/></param> internal unsafe TargetInfo(IntPtr value) { this.m_value = value; this.PointerWidth = clang.clang_TargetInfo_getPointerWidth(value); CXString tripleString = clang.clang_TargetInfo_getTriple(value); this.Triple = NativeMethodsHelper.ToStringAndDispose(tripleString); }
/// <summary> /// Gets the filename if a given CXFile /// </summary> /// <param name="file"> /// A <see cref="CXFile"/>: a CXFile instance /// </param> /// <returns> /// A <see cref="string"/>: the filename /// </returns> public string GetFileNameString(CXFile file) { lock (SyncRoot) { CXString cxstring = clang.getFileName(file); string fileName = Marshal.PtrToStringAnsi(clang.getCString(cxstring)); clang.disposeString(cxstring); return(fileName); } }
/// <summary> /// Gets the display name of a cursor. E.g.: a functions's display name its whole signature /// </summary> /// <param name="cursor"> /// A <see cref="CXCursor"/>: a cursor /// </param> /// <returns> /// A <see cref="string"/>: the cursor's display name /// </returns> public string GetCursorDisplayName(CXCursor cursor) { lock (SyncRoot) { CXString cxstring = clang.getCursorDisplayName(cursor); string spelling = Marshal.PtrToStringAnsi(clang.getCString(cxstring)); clang.disposeString(cxstring); return(spelling); } }
internal unsafe static extern CXString clang_getDiagnosticOption(CXDiagnostic diagnostic, CXString* disable);
internal static extern void clang_disposeString(CXString str);
internal static extern IntPtr clang_getCString(CXString str);