56#define MIN_HIGH_SURROGATE static_cast<wxUChar>(0xD800)
57#define MAX_HIGH_SURROGATE static_cast<wxUChar>(0xDBFF)
58#define MIN_LOW_SURROGATE static_cast<wxUChar>(0xDC00)
59#define MAX_LOW_SURROGATE static_cast<wxUChar>(0xDFFF)
62#define NONCHARACTER_FFFE static_cast<wxUChar>(0xFFFE)
63#define NONCHARACTER_FFFF static_cast<wxUChar>(0xFFFF)
90 for (i = 0; i <
mDepth; i++) {
94 Write(wxString::Format(wxT(
"<%s"),
name));
115 for (i = 0; i <
mDepth - 1; i++) {
118 Write(wxString::Format(wxT(
"</%s>\n"),
name));
136 Write(wxString::Format(wxT(
" %s=\"%s\""),
150 Write(wxString::Format(wxT(
" %s=\"%d\""),
158 Write(wxString::Format(wxT(
" %s=\"%d\""),
166 Write(wxString::Format(wxT(
" %s=\"%ld\""),
174 Write(wxString::Format(wxT(
" %s=\"%lld\""),
182 Write(wxString::Format(wxT(
" %s=\"%lld\""),
190 Write(wxString::Format(wxT(
" %s=\"%s\""),
198 Write(wxString::Format(wxT(
" %s=\"%s\""),
208 for (i = 0; i <
mDepth; i++) {
231 int len = s.length();
233 for(
int i=0; i<len; i++) {
234 wxUChar c = s.GetChar(i);
238 result += wxT(
"'");
242 result += wxT(
""");
246 result += wxT(
"&");
250 result += wxT(
"<");
254 result += wxT(
">");
262 wxUChar c2 = s.GetChar(++i);
273 else if (!wxIsprint(c)) {
283 result += wxString::Format(wxT(
"&#x%04x;"), c);
300 : mOutputPath{ outputPath }
301 , mCaption{ caption }
302 , mKeepBackup{ keepBackup }
305 auto tempPath = wxFileName::CreateTempFileName( outputPath );
306 if (!wxFFile::Open(tempPath, wxT(
"wb")) || !IsOpened())
317 outputFn.GetPath() + wxFILE_SEP_PATH +
318 outputFn.GetName() + wxT(
"_bak") +
319 wxString::Format(wxT(
"%d"), index) + wxT(
".") +
336 auto fileName = GetName();
339 ::wxRemoveFile( fileName );
393 if (!wxFFile::Flush())
400 if (!wxFFile::Close())
407 if (!wxFFile::Write(data, wxConvUTF8) || Error())
423 reserve(initialSize);
464 const wxScopedCharBuffer utf8Value = value.
GET().utf8_str();
470 const std::string_view&
name,
const std::string_view& value)
498 const std::string_view&
name,
long long value)
501 constexpr size_t bufferSize = 21;
502 char buffer[bufferSize];
504 const auto result =
ToChars(buffer, buffer + bufferSize, value);
506 if (result.ec != std::errc())
509 WriteAttr(
name, std::string_view(buffer, result.ptr - buffer));
519 const std::string_view&
name,
float value,
int digits )
521 constexpr size_t bufferSize = std::numeric_limits<float>::max_digits10 +
525 char buffer[bufferSize];
527 const auto result =
ToChars(buffer, buffer + bufferSize, value, digits);
529 if (result.ec != std::errc())
532 WriteAttr(
name, std::string_view(buffer, result.ptr - buffer));
536 const std::string_view&
name,
double value,
int digits )
538 constexpr size_t bufferSize = std::numeric_limits<double>::max_digits10 +
542 char buffer[bufferSize];
544 const auto result =
ToChars(buffer, buffer + bufferSize, value, digits);
546 if (result.ec != std::errc())
549 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...
const TranslatableString name
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([](My &table) -> Registry::BaseItemPtr { if(WaveTrackSubViews::slots() > 1) return 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=WaveTrackView::Get(track);menu.Check(id, view.GetMultiView());});else return 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)