Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: util/misc/symbolic_constants_common.h

Issue 565453002: Add symbolic_constants_posix and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix formatting Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
15 #ifndef CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_
16 #define CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_
17
18 namespace crashpad {
19
20 // Symbolic constant terminology:
Robert Sesek 2014/09/10 20:01:04 Can this comment be added to Doxygen somehow?
21 //
22 // A “family” is a group of related symbolic constants. Typically, within a
23 // single family, one function will be used to transform a numeric value to a
24 // string equivalent, and another will perform the inverse operation. Families
25 // include POSIX signals and Mach exception masks.
26 //
27 // A “full name” is the normal symbolic name used for a constant. For example,
28 // in the family of POSIX signals, the strings "SIGHUP" and "SIGSEGV" are full
29 // names.
30 //
31 // A “short name” is an abbreviated form of symbolic name used for a constant.
32 // Short names vary between families, but are commonly constructed by removing a
33 // common prefix from full names. For example, in the family of POSIX signals,
34 // the prefix is SIG, and short names include "HUP" and "SEGV".
35 //
36 // A “numeric string” is a string that does not contain a full or short name,
37 // but contains a numeric value that can be interpreted as a symbolic constant.
38 // For example, in the family of POSIX signals, SIGKILL generally has value 9,
39 // so the numeric string "9" would be interpreted equivalently to "SIGKILL".
40
41 //! \brief Options for various `*ToString` functions in `symbolic_constants_*`
42 //! files.
43 enum SymbolicConstantToStringOptionBits {
44 //! \brief Return the full name for a given constant.
45 //!
46 //! \attention API consumers should provide this value when desired, but
47 //! should provide only one of kUseFullName and ::kUseShortName. Because
48 //! kUseFullName is valueless, implementers should check for the absence
49 //! of ::kUseShortName instead.
50 kUseFullName = 0 << 0,
51
52 //! \brief Return the short name for a given constant.
53 kUseShortName = 1 << 0,
54
55 //! \brief If no symbolic name is known for a given constant, return an empty
56 //! string.
57 //!
58 //! \attention API consumers should provide this value when desired, but
59 //! should provide only one of kUnknownIsEmpty and ::kUnknownIsNumeric.
60 //! Because kUnknownIsEmpty is valueless, implementers should check for
61 //! the absence of ::kUnknownIsNumeric instead.
62 kUnknownIsEmpty = 0 << 1,
63
64 //! \brief If no symbolic name is known for a given constant, return a numeric
65 //! string.
66 //!
67 //! The numeric format used will vary by family, but will be appropriate to
68 //! the family. Families whose values are typically constructed as bitfields
69 //! will generally use a hexadecimal format, and other families will generally
70 //! use a signed or unsigned decimal format.
71 kUnknownIsNumeric = 1 << 1,
72
73 //! \brief Use `|` to combine values in a bitfield.
74 //!
75 //! For families whose values may be constructed as bitfields, allow
76 //! conversion to strings containing multiple individual components treated as
77 //! being combined by a bitwise “or” operation. An example family of constants
78 //! that behaves this way is the suite of Mach exception masks. For constants
79 //! that are not constructed as bitfields, or constants that are only
80 //! partially constructed as bitfields, this option has no effect.
81 kUseOr = 1 << 2,
82 };
83
84 //! \brief A bitfield containing values of #SymbolicConstantToStringOptionBits.
85 typedef unsigned int SymbolicConstantToStringOptions;
86
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 enum StringToSymbolicConstantOptionBits {
93 //! \brief Allow conversion from a string containing a symbolic constant by
94 //! its full name.
95 kAllowFullName = 1 << 0,
96
97 //! \brief Allow conversion from a string containing a symbolic constant by
98 //! its short name.
99 kAllowShortName = 1 << 1,
100
101 //! \brief Allow conversion from a numeric string.
102 kAllowNumber = 1 << 2,
103
104 //! \brief Allow `|` to combine values in a bitfield.
105 //!
106 //! For families whose values may be constructed as bitfields, allow
107 //! conversion of strings containing multiple individual components treated as
108 //! being combined by a bitwise “or” operation. An example family of constants
109 //! that behaves this way is the suite of Mach exception masks. For constants
110 //! that are not constructed as bitfields, or constants that are only
111 //! partially constructed as bitfields, this option has no effect.
112 kAllowOr = 1 << 3,
113 };
114
115 //! \brief A bitfield containing values of #StringToSymbolicConstantOptionBits.
116 typedef unsigned int StringToSymbolicConstantOptions;
117
118 } // namespace crashpad
119
120 #endif // CRASHPAD_UTIL_MISC_SYMBOLIC_CONSTANTS_COMMON_H_
OLDNEW
« no previous file with comments | « no previous file | util/posix/symbolic_constants_posix.h » ('j') | util/posix/symbolic_constants_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698