styleparams.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/html/styleparams.h
  3. // Purpose: wxHtml helper code for extracting style parameters
  4. // Author: Nigel Paton
  5. // Copyright: wxWidgets team
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_HTML_STYLEPARAMS_H_
  9. #define _WX_HTML_STYLEPARAMS_H_
  10. #include "wx/defs.h"
  11. #if wxUSE_HTML
  12. #include "wx/arrstr.h"
  13. class WXDLLIMPEXP_FWD_HTML wxHtmlTag;
  14. // This is a private class used by wxHTML to parse "style" attributes of HTML
  15. // elements. Currently both parsing and support for the parsed values is pretty
  16. // trivial.
  17. class WXDLLIMPEXP_HTML wxHtmlStyleParams
  18. {
  19. public:
  20. // Construct a style parameters object corresponding to the style attribute
  21. // of the given HTML tag.
  22. wxHtmlStyleParams(const wxHtmlTag& tag);
  23. // Check whether the named parameter is present or not.
  24. bool HasParam(const wxString& par) const
  25. {
  26. return m_names.Index(par, false /* ignore case */) != wxNOT_FOUND;
  27. }
  28. // Get the value of the named parameter, return empty string if none.
  29. wxString GetParam(const wxString& par) const
  30. {
  31. int index = m_names.Index(par, false);
  32. return index == wxNOT_FOUND ? wxString() : m_values[index];
  33. }
  34. private:
  35. // Arrays if names and values of the parameters
  36. wxArrayString
  37. m_names,
  38. m_values;
  39. };
  40. #endif // wxUSE_HTML
  41. #endif // _WX_HTML_STYLEPARAMS_H_