using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace BansheeEngine { /** @addtogroup Localization * @{ */ /// Used for string localization. Stores strings and their translations in various languages. public partial class StringTable : Resource { private StringTable(bool __dummy0) { } /// Creates a new empty string table resource. public StringTable() { Internal_create(this); } /// Returns a reference wrapper for this resource. public RRef Ref { get { return Internal_GetRef(mCachedPtr); } } /// Returns a total number of strings in the table. public uint NumStrings { get { return Internal_getNumStrings(mCachedPtr); } } /// Returns all identifiers that the string table contains localized strings for. public string[] Identifiers { get { return Internal_getIdentifiers(mCachedPtr); } } /// Returns a reference wrapper for this resource. public static implicit operator RRef(StringTable x) { return Internal_GetRef(x.mCachedPtr); } /// Checks does the string table contain the provided identifier. /// Identifier to look for. /// True if the identifier exists in the table, false otherwise. public bool Contains(string identifier) { return Internal_contains(mCachedPtr, identifier); } /// Adds or modifies string translation for the specified language. public void SetString(string identifier, Language language, string value) { Internal_setString(mCachedPtr, identifier, language, value); } /// /// Returns a string translation for the specified language. Returns the identifier itself if one doesn't exist. /// public string GetString(string identifier, Language language) { return Internal_getString(mCachedPtr, identifier, language); } /// Removes the string described by identifier, from all languages. public void RemoveString(string identifier) { Internal_removeString(mCachedPtr, identifier); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern RRef Internal_GetRef(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Internal_contains(IntPtr thisPtr, string identifier); [MethodImpl(MethodImplOptions.InternalCall)] private static extern uint Internal_getNumStrings(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern string[] Internal_getIdentifiers(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setString(IntPtr thisPtr, string identifier, Language language, string value); [MethodImpl(MethodImplOptions.InternalCall)] private static extern string Internal_getString(IntPtr thisPtr, string identifier, Language language); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_removeString(IntPtr thisPtr, string identifier); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_create(StringTable managedInstance); } /** @} */ }