ImStrv: added imconfig class extension example, added natvis description.

This commit is contained in:
ocornut
2020-11-30 09:43:10 +01:00
parent 194bf63863
commit a643b23486
3 changed files with 19 additions and 4 deletions

View File

@ -269,7 +269,8 @@ struct ImVec4
#endif
};
// String view class.
// String view (non-owning pair of begin/end pointers, not necessarily zero-terminated)
// ImStrv are used as function parameters instead of passing a pair of const char*.
#define IMGUI_HAS_IMSTR
struct ImStrv
{
@ -280,9 +281,9 @@ struct ImStrv
ImStrv(const char* b, const char* e){ Begin = b; End = e ? e : b + strlen(b); }
inline size_t length() const { return (size_t)(End - Begin); }
inline bool empty() const { return Begin == End; } // == "" or == NULL
inline operator bool() const { return Begin != NULL; } // != NULL
#ifdef IM_IMSTR_CLASS_EXTRA
IM_IMSTR_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your string types and ImStrv.
inline operator bool() const { return Begin != NULL; } // return true when valid ("" is valid, NULL construction is not)
#ifdef IM_STR_CLASS_EXTRA
IM_STR_CLASS_EXTRA // Define additional constructor in imconfig.h to convert your string types (e.g. std::string, std::string_view) to ImStrV.
#endif
// private: bool operator==(ImStrv) { return false; } // [DEBUG] Uncomment to catch undesirable uses of operators
// private: bool operator!=(ImStrv) { return false; }