55#define MIN_HIGH_SURROGATE static_cast<wxUChar>(0xD800)
56#define MAX_HIGH_SURROGATE static_cast<wxUChar>(0xDBFF)
57#define MIN_LOW_SURROGATE static_cast<wxUChar>(0xDC00)
58#define MAX_LOW_SURROGATE static_cast<wxUChar>(0xDFFF)
61#define NONCHARACTER_FFFE static_cast<wxUChar>(0xFFFE)
62#define NONCHARACTER_FFFF static_cast<wxUChar>(0xFFFF)
89 for (i = 0; i <
mDepth; i++) {
114 for (i = 0; i <
mDepth - 1; i++) {
135 Write(wxString::Format(
wxT(
" %s=\"%s\""),
149 Write(wxString::Format(
wxT(
" %s=\"%d\""),
157 Write(wxString::Format(
wxT(
" %s=\"%d\""),
165 Write(wxString::Format(
wxT(
" %s=\"%ld\""),
173 Write(wxString::Format(
wxT(
" %s=\"%lld\""),
181 Write(wxString::Format(
wxT(
" %s=\"%lld\""),
189 Write(wxString::Format(
wxT(
" %s=\"%s\""),
197 Write(wxString::Format(
wxT(
" %s=\"%s\""),
207 for (i = 0; i <
mDepth; i++) {
230 int len = s.length();
232 for(
int i=0; i<len; i++) {
233 wxUChar c = s.GetChar(i);
237 result +=
wxT(
"'");
241 result +=
wxT(
""");
245 result +=
wxT(
"&");
249 result +=
wxT(
"<");
253 result +=
wxT(
">");
261 wxUChar c2 = s.GetChar(++i);
272 else if (!wxIsprint(c)) {
282 result += wxString::Format(
wxT(
"&#x%04x;"), c);
299 : mOutputPath{ outputPath }
300 , mCaption{ caption }
301 , mKeepBackup{ keepBackup }
304 auto tempPath = wxFileName::CreateTempFileName( outputPath );
305 if (!wxFFile::Open(tempPath,
wxT(
"wb")) || !IsOpened())
316 outputFn.GetPath() + wxFILE_SEP_PATH +
317 outputFn.GetName() +
wxT(
"_bak") +
318 wxString::Format(
wxT(
"%d"), index) +
wxT(
".") +
335 auto fileName = GetName();
338 ::wxRemoveFile( fileName );
392 if (!wxFFile::Flush())
399 if (!wxFFile::Close())
406 if (!wxFFile::Write(data, wxConvUTF8) ||
Error())
422 reserve(initialSize);
463 const wxScopedCharBuffer utf8Value = value.
GET().utf8_str();
469 const std::string_view&
name,
const std::string_view& value)
497 const std::string_view&
name,
long long value)
500 constexpr size_t bufferSize = 21;
501 char buffer[bufferSize];
503 const auto result =
ToChars(buffer, buffer + bufferSize, value);
505 if (result.ec != std::errc())
508 WriteAttr(
name, std::string_view(buffer, result.ptr - buffer));
518 const std::string_view&
name,
float value,
int digits )
520 constexpr size_t bufferSize = std::numeric_limits<float>::max_digits10 +
524 char buffer[bufferSize];
526 const auto result =
ToChars(buffer, buffer + bufferSize, value, digits);
528 if (result.ec != std::errc())
531 WriteAttr(
name, std::string_view(buffer, result.ptr - buffer));
535 const std::string_view&
name,
double value,
int digits )
537 constexpr size_t bufferSize = std::numeric_limits<double>::max_digits10 +
541 char buffer[bufferSize];
543 const auto result =
ToChars(buffer, buffer + bufferSize, value, digits);
545 if (result.ec != std::errc())
548 WriteAttr(
name, std::string_view(buffer, result.ptr - buffer));
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
MessageBoxException for violation of preconditions or assertions.
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
STRING_UTILS_API ToCharsResult ToChars(char *buffer, char *last, float value, int digitsAfterDecimalPoint) noexcept
Convert a single precision floating point number to a string, always uses the dot as decimal.
Define functions to convert numeric types to string representation.
Append(Adapt< My >([](My &table) { return(WaveChannelSubViews::numFactories() > 1) ? std::make_unique< Entry >("MultiView", Entry::CheckItem, OnMultiViewID, XXO("&Multi-view"), POPUP_MENU_FN(OnMultiView), table, [](PopupMenuHandler &handler, wxMenu &menu, int id){ auto &table=static_cast< WaveTrackMenuTable & >(handler);auto &track=table.FindWaveTrack();const auto &view=WaveChannelView::GetFirst(track);menu.Check(id, view.GetMultiView());}) :nullptr;}))
#define MIN_HIGH_SURROGATE
#define NONCHARACTER_FFFE
#define MAX_LOW_SURROGATE
static int charXMLCompatiblity[]
#define NONCHARACTER_FFFF
#define MAX_HIGH_SURROGATE
#define MIN_LOW_SURROGATE
Thrown for failure of file or database operations in deeply nested places.
@ Rename
involves two filenames
An explicitly nonlocalized string, not meant for the user to see.
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
static wxString ToString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, always uses the dot as decimal separator.
A low overhead memory stream with O(1) append, low heap fragmentation and a linear memory view.
void AppendData(const void *data, const size_t length)
void AppendByte(char data)
Holds a msgid for the translation catalog; may also bind format arguments.
const TranslatableString mCaption
void Write(const wxString &data) override
Write to file. Might throw.
void PreCommit()
Does the part of Commit that might fail because of exhaustion of space.
void CloseWithoutEndingTags()
void ThrowException(const wxFileName &fileName, const TranslatableString &caption)
const FilePath mOutputPath
XMLFileWriter(const FilePath &outputPath, const TranslatableString &caption, bool keepBackup=false)
XMLStringWriter(size_t initialSize=0)
virtual ~XMLStringWriter()
void Write(const wxString &data) override
void WriteData(const std::string_view &value)
void WriteSubTree(const std::string_view &value)
void StartTag(const std::string_view &name)
void EndTag(const std::string_view &name)
void WriteAttr(const std::string_view &name, const Identifier &value)
void WriteEscaped(const std::string_view &value)
MemoryStream ConsumeResult()
void Write(const std::string_view &value)
virtual void WriteData(const wxString &value)
std::vector< int > mHasKids
virtual void StartTag(const wxString &name)
static wxString XMLEsc(const wxString &s)
void WriteAttr(const wxString &name, const Identifier &value)
virtual void EndTag(const wxString &name)
virtual void Write(const wxString &data)=0
virtual void WriteSubTree(const wxString &value)