symbolic_constants_common.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Copyright 2014 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_
  15. #define CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_
  16. //! \file
  17. //!
  18. //! \anchor symbolic_constant_terminology
  19. //! Symbolic constant terminology
  20. //! =============================
  21. //! <dl>
  22. //! <dt>Family</dt>
  23. //! <dd>A group of related symbolic constants. Typically, within a single
  24. //! family, one function will be used to transform a numeric value to a
  25. //! string equivalent, and another will perform the inverse operation.
  26. //! Families include POSIX signals and Mach exception masks.</dd>
  27. //! <dt>Full name</dt>
  28. //! <dd>The normal symbolic name used for a constant. For example, in the
  29. //! family of POSIX signals, the strings `"SIGHUP"` and `"SIGSEGV"` are
  30. //! full names.</dd>
  31. //! <dt>Short name</dt>
  32. //! <dd>An abbreviated form of symbolic name used for a constant. Short names
  33. //! vary between families, but are commonly constructed by removing a
  34. //! common prefix from full names. For example, in the family of POSIX
  35. //! signals, the prefix is `SIG`, and short names include `"HUP"` and
  36. //! `"SEGV"`.</dd>
  37. //! <dt>Numeric string</dt>
  38. //! <dd>A string that does not contain a full or short name, but contains a
  39. //! numeric value that can be interpreted as a symbolic constant. For
  40. //! example, in the family of POSIX signals, `SIGKILL` generally has value
  41. //! `9`, so the numeric string `"9"` would be interpreted equivalently to
  42. //! `"SIGKILL"`.</dd>
  43. //! </dl>
  44. namespace crashpad {
  45. //! \brief Options for various `*ToString` functions in `symbolic_constants_*`
  46. //! files.
  47. //!
  48. //! \sa \ref symbolic_constant_terminology "Symbolic constant terminology"
  49. enum SymbolicConstantToStringOptionBits {
  50. //! \brief Return the full name for a given constant.
  51. //!
  52. //! \attention API consumers should provide this value when desired, but
  53. //! should provide only one of kUseFullName and ::kUseShortName. Because
  54. //! kUseFullName is valueless, implementers should check for the absence
  55. //! of ::kUseShortName instead.
  56. kUseFullName = 0 << 0,
  57. //! \brief Return the short name for a given constant.
  58. kUseShortName = 1 << 0,
  59. //! \brief If no symbolic name is known for a given constant, return an empty
  60. //! string.
  61. //!
  62. //! \attention API consumers should provide this value when desired, but
  63. //! should provide only one of kUnknownIsEmpty and ::kUnknownIsNumeric.
  64. //! Because kUnknownIsEmpty is valueless, implementers should check for
  65. //! the absence of ::kUnknownIsNumeric instead.
  66. kUnknownIsEmpty = 0 << 1,
  67. //! \brief If no symbolic name is known for a given constant, return a numeric
  68. //! string.
  69. //!
  70. //! The numeric format used will vary by family, but will be appropriate to
  71. //! the family. Families whose values are typically constructed as bitfields
  72. //! will generally use a hexadecimal format, and other families will generally
  73. //! use a signed or unsigned decimal format.
  74. kUnknownIsNumeric = 1 << 1,
  75. //! \brief Use `|` to combine values in a bitfield.
  76. //!
  77. //! For families whose values may be constructed as bitfields, allow
  78. //! conversion to strings containing multiple individual components treated as
  79. //! being combined by a bitwise “or” operation. An example family of constants
  80. //! that behaves this way is the suite of Mach exception masks. For constants
  81. //! that are not constructed as bitfields, or constants that are only
  82. //! partially constructed as bitfields, this option has no effect.
  83. kUseOr = 1 << 2,
  84. };
  85. //! \brief A bitfield containing values of #SymbolicConstantToStringOptionBits.
  86. using SymbolicConstantToStringOptions = unsigned int;
  87. //! \brief Options for various `StringTo*` functions in `symbolic_constants_*`
  88. //! files.
  89. //!
  90. //! Not every `StringTo*` function will implement each of these options. See
  91. //! function-specific documentation for details.
  92. //!
  93. //! \sa \ref symbolic_constant_terminology "Symbolic constant terminology"
  94. enum StringToSymbolicConstantOptionBits {
  95. //! \brief Allow conversion from a string containing a symbolic constant by
  96. //! its full name.
  97. kAllowFullName = 1 << 0,
  98. //! \brief Allow conversion from a string containing a symbolic constant by
  99. //! its short name.
  100. kAllowShortName = 1 << 1,
  101. //! \brief Allow conversion from a numeric string.
  102. kAllowNumber = 1 << 2,
  103. //! \brief Allow `|` to combine values in a bitfield.
  104. //!
  105. //! For families whose values may be constructed as bitfields, allow
  106. //! conversion of strings containing multiple individual components treated as
  107. //! being combined by a bitwise “or” operation. An example family of constants
  108. //! that behaves this way is the suite of Mach exception masks. For constants
  109. //! that are not constructed as bitfields, or constants that are only
  110. //! partially constructed as bitfields, this option has no effect.
  111. kAllowOr = 1 << 3,
  112. };
  113. //! \brief A bitfield containing values of #StringToSymbolicConstantOptionBits.
  114. using StringToSymbolicConstantOptions = unsigned int;
  115. } // namespace crashpad
  116. #endif // CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_