Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter Class Referencefinal
Collaboration diagram for anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter:
[legend]

Public Member Functions

 XMLTagHandlerAdapter (XMLTagHandler *handler) noexcept
 
void EmitStartTag (const std::string_view &name)
 
void EndTag (const std::string_view &name)
 
void WriteAttr (const std::string_view &name, std::string value)
 
template<typename T >
void WriteAttr (const std::string_view &name, T value)
 
void WriteData (std::string value)
 
void WriteRaw (std::string)
 
bool Finalize ()
 

Private Member Functions

void EmitStartTag ()
 
std::string_view CacheString (std::string string)
 

Private Attributes

XMLTagHandlermBaseHandler
 
std::vector< XMLTagHandler * > mHandlers
 
std::string_view mCurrentTagName
 
std::deque< std::string > mStringsCache
 
AttributesList mAttributes
 
bool mInTag { false }
 

Detailed Description

Definition at line 202 of file ProjectSerializer.cpp.

Constructor & Destructor Documentation

◆ XMLTagHandlerAdapter()

anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::XMLTagHandlerAdapter ( XMLTagHandler handler)
inlineexplicitnoexcept

Member Function Documentation

◆ CacheString()

std::string_view anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::CacheString ( std::string  string)
inlineprivate

Definition at line 309 of file ProjectSerializer.cpp.

310 {
311 mStringsCache.emplace_back(std::move(string));
312 return mStringsCache.back();
313 }

◆ EmitStartTag() [1/2]

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::EmitStartTag ( )
inlineprivate

Definition at line 279 of file ProjectSerializer.cpp.

280 {
281 if (mHandlers.empty())
282 {
283 mHandlers.push_back(mBaseHandler);
284 }
285 else
286 {
287 if (XMLTagHandler* const handler = mHandlers.back())
288 mHandlers.push_back(handler->HandleXMLChild(mCurrentTagName));
289 else
290 mHandlers.push_back(NULL);
291 }
292
293 if (XMLTagHandler*& handler = mHandlers.back())
294 {
295 if (!handler->HandleXMLTag(mCurrentTagName, mAttributes))
296 {
297 handler = nullptr;
298
299 if (mHandlers.size() == 1)
300 mBaseHandler = nullptr;
301 }
302 }
303
304 mStringsCache.clear();
305 mAttributes.clear();
306 mInTag = false;
307 }
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42

References cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler.

◆ EmitStartTag() [2/2]

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::EmitStartTag ( const std::string_view &  name)
inline

Definition at line 210 of file ProjectSerializer.cpp.

211 {
212 if (mInTag)
213 EmitStartTag();
214
216 mInTag = true;
217 }
const TranslatableString name
Definition: Distortion.cpp:76

References name.

◆ EndTag()

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::EndTag ( const std::string_view &  name)
inline

Definition at line 219 of file ProjectSerializer.cpp.

220 {
221 if (mInTag)
222 EmitStartTag();
223
224 if (XMLTagHandler* const handler = mHandlers.back())
225 handler->HandleXMLEndTag(name);
226
227 mHandlers.pop_back();
228 }

References cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, and name.

◆ Finalize()

bool anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::Finalize ( )
inline

Definition at line 267 of file ProjectSerializer.cpp.

268 {
269 if (mInTag)
270 {
271 EmitStartTag();
273 }
274
275 return mBaseHandler != nullptr;
276 }

◆ WriteAttr() [1/2]

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::WriteAttr ( const std::string_view &  name,
std::string  value 
)
inline

Definition at line 230 of file ProjectSerializer.cpp.

231 {
232 assert(mInTag);
233
234 if (!mInTag)
235 return;
236
237 mAttributes.emplace_back(name, CacheString(std::move(value)));
238 }

References name.

◆ WriteAttr() [2/2]

template<typename T >
void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::WriteAttr ( const std::string_view &  name,
value 
)
inline

Definition at line 240 of file ProjectSerializer.cpp.

241 {
242 assert(mInTag);
243
244 if (!mInTag)
245 return;
246
247 mAttributes.emplace_back(name, XMLAttributeValueView(value));
248 }
A view into an attribute value. The class does not take the ownership of the data.

References name.

◆ WriteData()

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::WriteData ( std::string  value)
inline

Definition at line 250 of file ProjectSerializer.cpp.

251 {
252 if (mInTag)
253 EmitStartTag();
254
255 if (XMLTagHandler* const handler = mHandlers.back())
256 handler->HandleXMLContent(CacheString(std::move(value)));
257 }

References cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler.

◆ WriteRaw()

void anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::WriteRaw ( std::string  )
inline

Definition at line 259 of file ProjectSerializer.cpp.

260 {
261 // This method is intentionally left empty.
262 // The only data that is serialized by FT_Raw
263 // is the boilerplate code like <?xml > and <!DOCTYPE>
264 // which are ignored
265 }

Member Data Documentation

◆ mAttributes

AttributesList anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mAttributes
private

Definition at line 322 of file ProjectSerializer.cpp.

◆ mBaseHandler

XMLTagHandler* anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mBaseHandler
private

Definition at line 315 of file ProjectSerializer.cpp.

◆ mCurrentTagName

std::string_view anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mCurrentTagName
private

Definition at line 319 of file ProjectSerializer.cpp.

◆ mHandlers

std::vector<XMLTagHandler*> anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mHandlers
private

Definition at line 317 of file ProjectSerializer.cpp.

◆ mInTag

bool anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mInTag { false }
private

Definition at line 324 of file ProjectSerializer.cpp.

◆ mStringsCache

std::deque<std::string> anonymous_namespace{ProjectSerializer.cpp}::XMLTagHandlerAdapter::mStringsCache
private

Definition at line 321 of file ProjectSerializer.cpp.


The documentation for this class was generated from the following file: