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 196 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 303 of file ProjectSerializer.cpp.

304 {
305 mStringsCache.emplace_back(std::move(string));
306 return mStringsCache.back();
307 }

◆ EmitStartTag() [1/2]

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

Definition at line 273 of file ProjectSerializer.cpp.

274 {
275 if (mHandlers.empty())
276 {
277 mHandlers.push_back(mBaseHandler);
278 }
279 else
280 {
281 if (XMLTagHandler* const handler = mHandlers.back())
282 mHandlers.push_back(handler->HandleXMLChild(mCurrentTagName));
283 else
284 mHandlers.push_back(NULL);
285 }
286
287 if (XMLTagHandler*& handler = mHandlers.back())
288 {
289 if (!handler->HandleXMLTag(mCurrentTagName, mAttributes))
290 {
291 handler = nullptr;
292
293 if (mHandlers.size() == 1)
294 mBaseHandler = nullptr;
295 }
296 }
297
298 mStringsCache.clear();
299 mAttributes.clear();
300 mInTag = false;
301 }
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 audacity::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 204 of file ProjectSerializer.cpp.

205 {
206 if (mInTag)
207 EmitStartTag();
208
210 mInTag = true;
211 }
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 213 of file ProjectSerializer.cpp.

214 {
215 if (mInTag)
216 EmitStartTag();
217
218 if (XMLTagHandler* const handler = mHandlers.back())
219 handler->HandleXMLEndTag(name);
220
221 mHandlers.pop_back();
222 }

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

◆ Finalize()

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

Definition at line 261 of file ProjectSerializer.cpp.

262 {
263 if (mInTag)
264 {
265 EmitStartTag();
267 }
268
269 return mBaseHandler != nullptr;
270 }

◆ WriteAttr() [1/2]

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

Definition at line 224 of file ProjectSerializer.cpp.

225 {
226 assert(mInTag);
227
228 if (!mInTag)
229 return;
230
231 mAttributes.emplace_back(name, CacheString(std::move(value)));
232 }

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 234 of file ProjectSerializer.cpp.

235 {
236 assert(mInTag);
237
238 if (!mInTag)
239 return;
240
241 mAttributes.emplace_back(name, XMLAttributeValueView(value));
242 }
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 244 of file ProjectSerializer.cpp.

245 {
246 if (mInTag)
247 EmitStartTag();
248
249 if (XMLTagHandler* const handler = mHandlers.back())
250 handler->HandleXMLContent(CacheString(std::move(value)));
251 }

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

◆ WriteRaw()

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

Definition at line 253 of file ProjectSerializer.cpp.

254 {
255 // This method is intentionally left empty.
256 // The only data that is serialized by FT_Raw
257 // is the boilerplate code like <?xml > and <!DOCTYPE>
258 // which are ignored
259 }

Member Data Documentation

◆ mAttributes

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

Definition at line 316 of file ProjectSerializer.cpp.

◆ mBaseHandler

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

Definition at line 309 of file ProjectSerializer.cpp.

◆ mCurrentTagName

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

Definition at line 313 of file ProjectSerializer.cpp.

◆ mHandlers

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

Definition at line 311 of file ProjectSerializer.cpp.

◆ mInTag

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

Definition at line 318 of file ProjectSerializer.cpp.

◆ mStringsCache

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

Definition at line 315 of file ProjectSerializer.cpp.


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