Audacity 3.2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
UpdateDataParser Class Referencefinal

A class that parses update server data format. More...

#include <UpdateDataParser.h>

Inheritance diagram for UpdateDataParser:
[legend]
Collaboration diagram for UpdateDataParser:
[legend]

Public Member Functions

 UpdateDataParser ()
 
 ~UpdateDataParser ()
 
bool Parse (const VersionPatch::UpdateDataFormat &updateData, VersionPatch *versionPatch)
 Parsing from update data format to VersionPatch fields. More...
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 

Private Types

enum class  XmlParsedTags : int {
  kNotUsedTag , kUpdateTag , kDescriptionTag , kOsTag ,
  kWin32Tag , kWin64Tag , kMacosTag , kLinuxTag ,
  kVersionTag , kLinkTag
}
 

Private Member Functions

bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
void HandleXMLEndTag (const std::string_view &tag) override
 
void HandleXMLContent (const std::string_view &content) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 
wxArrayString SplitChangelogSentences (const wxString &changelogContent)
 

Private Attributes

XmlParsedTags mXmlParsingState { XmlParsedTags::kNotUsedTag }
 
std::map< XmlParsedTags, const char * > mXmlTagNames
 
VersionPatchmVersionPatch { nullptr }
 

Detailed Description

A class that parses update server data format.

Definition at line 19 of file UpdateDataParser.h.

Member Enumeration Documentation

◆ XmlParsedTags

enum class UpdateDataParser::XmlParsedTags : int
strongprivate
Enumerator
kNotUsedTag 
kUpdateTag 
kDescriptionTag 
kOsTag 
kWin32Tag 
kWin64Tag 
kMacosTag 
kLinuxTag 
kVersionTag 
kLinkTag 

Definition at line 34 of file UpdateDataParser.h.

34 : int {
35 kNotUsedTag,
36 kUpdateTag,
37 kDescriptionTag,
38 kOsTag,
39 kWin32Tag,
40 kWin64Tag,
41 kMacosTag,
42 kLinuxTag,
43 kVersionTag,
44 kLinkTag
45 };

Constructor & Destructor Documentation

◆ UpdateDataParser()

UpdateDataParser::UpdateDataParser ( )

Definition at line 16 of file UpdateDataParser.cpp.

17{}

◆ ~UpdateDataParser()

UpdateDataParser::~UpdateDataParser ( )

Definition at line 19 of file UpdateDataParser.cpp.

20{}

Member Function Documentation

◆ HandleXMLChild()

XMLTagHandler * UpdateDataParser::HandleXMLChild ( const std::string_view &  tag)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 163 of file UpdateDataParser.cpp.

164{
165 for (auto& xmlTag : mXmlTagNames)
166 {
167 if (tag == xmlTag.second)
168 return this;
169 }
170
171 return NULL;
172}
std::map< XmlParsedTags, const char * > mXmlTagNames

References mXmlTagNames.

◆ HandleXMLContent()

void UpdateDataParser::HandleXMLContent ( const std::string_view &  content)
overrideprivate

Definition at line 134 of file UpdateDataParser.cpp.

135{
136 if (mVersionPatch == nullptr)
137 return;
138
139 wxString trimmedContent = std::string(content);
140
141 switch (mXmlParsingState)
142 {
144 trimmedContent.Trim(true).Trim(false);
146 break;
147
149 trimmedContent.Trim(true).Trim(false);
151 break;
152
154 trimmedContent.Trim(true).Trim(false);
155 mVersionPatch->download = trimmedContent;
156 break;
157
158 default:
159 break;
160 }
161}
VersionPatch * mVersionPatch
XmlParsedTags mXmlParsingState
wxArrayString SplitChangelogSentences(const wxString &changelogContent)
static VersionId ParseFromString(wxString &versionString)
Parse and return version object from version string like "1.2.3".
Definition: VersionId.cpp:31
VersionId version
Definition: VersionPatch.h:20
wxArrayString changelog
Definition: VersionPatch.h:21
wxString download
Definition: VersionPatch.h:22

References VersionPatch::changelog, VersionPatch::download, kDescriptionTag, kLinkTag, kVersionTag, mVersionPatch, mXmlParsingState, VersionId::ParseFromString(), SplitChangelogSentences(), and VersionPatch::version.

Here is the call graph for this function:

◆ HandleXMLEndTag()

void UpdateDataParser::HandleXMLEndTag ( const std::string_view &  tag)
overrideprivate

Definition at line 122 of file UpdateDataParser.cpp.

123{
127
128 // If it is our working OS, using "kOsTag" for keeping ready for parse state for both tags:
129 // <Version> and <Link>, that ordered one after another.
132}

References kDescriptionTag, kLinkTag, kNotUsedTag, kOsTag, kVersionTag, and mXmlParsingState.

◆ HandleXMLTag()

bool UpdateDataParser::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 52 of file UpdateDataParser.cpp.

53{
55 {
57 return true;
58 }
59
60 const wxPlatformInfo& info = wxPlatformInfo::Get();
61
62 constexpr bool is32Bit = sizeof(void*) == 4;
63 constexpr bool is64Bit = sizeof(void*) == 8;
64
65 if (is32Bit)
66 {
68 {
69 if (info.GetOperatingSystemId() & wxOS_WINDOWS)
71 return true;
72 }
73 }
74
75 if (is64Bit)
76 {
78 {
79 if (info.GetOperatingSystemId() & wxOS_WINDOWS)
81 return true;
82 }
83 }
84
86 {
87 if (info.GetOperatingSystemId() & wxOS_MAC)
89 return true;
90 }
91
93 {
94 if (info.GetOperatingSystemId() & wxOS_UNIX_LINUX)
96 return true;
97 }
98
100 {
103 return true;
104 }
105
107 {
110 return true;
111 }
112
113 for (auto& xmlTag : mXmlTagNames)
114 {
115 if (tag == xmlTag.second)
116 return true;
117 }
118
119 return false;
120}
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202

References BasicUI::Get(), kDescriptionTag, kLinkTag, kLinuxTag, kMacosTag, kOsTag, kVersionTag, kWin32Tag, kWin64Tag, mXmlParsingState, and mXmlTagNames.

Here is the call graph for this function:

◆ Parse()

bool UpdateDataParser::Parse ( const VersionPatch::UpdateDataFormat updateData,
VersionPatch versionPatch 
)

Parsing from update data format to VersionPatch fields.

Parameters
updateDataInputData.
versionPathParsed output data.
Returns
True if success.

Definition at line 22 of file UpdateDataParser.cpp.

23{
24 XMLFileReader xmlReader;
25
26 ValueRestorer<VersionPatch*> setter{ mVersionPatch, versionPatch };
27
28 return xmlReader.ParseString(this, updateData);
29}
Set a variable temporarily in a scope.
Definition: MemoryX.h:214
Reads a file and passes the results through an XMLTagHandler.
Definition: XMLFileReader.h:19
bool ParseString(XMLTagHandler *baseHandler, const wxString &xmldata)

References mVersionPatch, and XMLFileReader::ParseString().

Referenced by UpdateManager::GetUpdates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitChangelogSentences()

wxArrayString UpdateDataParser::SplitChangelogSentences ( const wxString &  changelogContent)
private

Definition at line 31 of file UpdateDataParser.cpp.

32{
33 wxArrayString changelogSentenceList;
34
35 size_t pos = 0;
36 std::string s(changelogContent.ToStdString());
37 std::string token;
38 const std::string delimiter(". ");
39
40 while ((pos = s.find(delimiter)) != std::string::npos)
41 {
42 token = s.substr(0, pos + 1);
43 changelogSentenceList.Add(wxString(token).Trim());
44
45 s.erase(0, pos + delimiter.length());
46 }
47 changelogSentenceList.Add(wxString(s).Trim());
48
49 return changelogSentenceList;
50}
constexpr size_t npos(-1)

References Tuple::detail::npos().

Referenced by HandleXMLContent().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mVersionPatch

VersionPatch* UpdateDataParser::mVersionPatch { nullptr }
private

Definition at line 68 of file UpdateDataParser.h.

Referenced by HandleXMLContent(), and Parse().

◆ mXmlParsingState

XmlParsedTags UpdateDataParser::mXmlParsingState { XmlParsedTags::kNotUsedTag }
private

Definition at line 46 of file UpdateDataParser.h.

Referenced by HandleXMLContent(), HandleXMLEndTag(), and HandleXMLTag().

◆ mXmlTagNames

std::map<XmlParsedTags, const char*> UpdateDataParser::mXmlTagNames
private
Initial value:

Definition at line 48 of file UpdateDataParser.h.

Referenced by HandleXMLChild(), and HandleXMLTag().


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