MCPcopy Create free account
hub / github.com/KDE/kdevelop / FormatterData

Class FormatterData

kdevplatform/shell/sourceformatterselectionedit.cpp:74–211  ·  view source on GitHub ↗

* This class encapsulates an ISourceFormatter and its styles. * * The class is non-copyable and non-movable to ensure that references to it are never invalidated. */

Source from the content-addressed store, hash-verified

72 * The class is non-copyable and non-movable to ensure that references to it are never invalidated.
73 */
74class FormatterData
75{
76 Q_DISABLE_COPY_MOVE(FormatterData)
77public:
78 explicit FormatterData(const ISourceFormatter& formatter, StyleMap&& styles)
79 : m_formatter{formatter}
80 , m_name{m_formatter.name()}
81 , m_styles{std::move(styles)}
82 {
83 }
84
85 const QString& name() const
86 {
87 return m_name;
88 }
89 const ISourceFormatter& formatter() const
90 {
91 return m_formatter;
92 }
93
94 SourceFormatterStyle* findStyle(QStringView styleName)
95 {
96 const auto it = m_styles.find(styleName);
97 return it == m_styles.end() ? nullptr : &it->second;
98 }
99
100 template<typename StyleUser>
101 void forEachStyle(StyleUser callback)
102 {
103 for (auto it = m_styles.begin(), end = m_styles.end(); it != end; ++it) {
104 callback(it->second);
105 }
106 }
107
108 template<typename ConstStyleUser>
109 void forEachUserDefinedStyle(ConstStyleUser callback) const
110 {
111 for (auto it = m_userStyleRange.first(m_styles); it != m_userStyleRange.last(); ++it) {
112 Q_ASSERT(it->first.startsWith(userStyleNamePrefix));
113 callback(it->second);
114 }
115 }
116
117 template<typename StyleAndCategoryUser>
118 void forEachSupportingStyleInUiOrder(const QString& supportedLanguageName, StyleAndCategoryUser callback);
119
120 void assertExistingStyle(const SourceFormatterStyle& style)
121 {
122 Q_ASSERT(findStyle(style.name()) == &style);
123 }
124
125 void assertNullOrExistingStyle(const SourceFormatterStyle* style)
126 {
127 Q_ASSERT(!style || findStyle(style->name()) == style);
128 }
129
130 void removeStyle(const SourceFormatterStyle& style)
131 {

Callers

nothing calls this directly

Calls 4

toIntMethod · 0.80
nameMethod · 0.45
sizeMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected