//
// XML storage C++ classes version 1.3
//
- // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009 Martin Fuchs <martin-fuchs@gmx.net>
+ // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Martin Fuchs <martin-fuchs@gmx.net>
//
/// \file xmlstorage.h
#define _tcsicmp strcasecmp
#define strnicmp strncasecmp
#define _tcsnicmp strncasecmp
-#endif
+#endif // UNICODE
#endif // _WIN32
#if defined(UNICODE) && !defined(XS_STRING_UTF8)
XS_String(LPCSTR s) {assign(s);}
XS_String(LPCSTR s, size_t l) {assign(s, l);}
- XS_String(const std::string& other) {assign(other.c_str());}
+ XS_String(const std::string& s) {assign(s.c_str());}
XS_String& operator=(LPCSTR s) {assign(s); return *this;}
void assign(LPCSTR s) {if (s) {size_t bl=strlen(s); LPWSTR b=(LPWSTR)alloca(sizeof(WCHAR)*bl); super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, bl, b, bl));} else erase();}
void assign(LPCSTR s, size_t l) {if (s) {size_t bl=l; LPWSTR b=(LPWSTR)alloca(sizeof(WCHAR)*bl); super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, bl));} else erase();}
#else
XS_String(LPCWSTR s) {assign(s);}
XS_String(LPCWSTR s, size_t l) {assign(s, l);}
- XS_String(const std::wstring& other) {assign(other.c_str());}
+ XS_String(const std::wstring& ws) {assign(ws.c_str());}
XS_String& operator=(LPCWSTR s) {assign(s); return *this;}
#ifdef XS_STRING_UTF8
void assign(LPCWSTR s) {if (s) {size_t bl=wcslen(s); LPSTR b=(LPSTR)alloca(bl); super::assign(b, WideCharToMultiByte(CP_UTF8, 0, s, (int)bl, b, (int)bl, 0, 0));} else erase();}
#endif
#endif // _WIN32
+#ifdef __ISSD_H
+// XS_String(const _ISSD RString& s) {assign(s.c_str());}
+// void assign(const _ISSD RString& s) {assign(s.c_str());}
+ XS_String& operator=(const _ISSD RString& s) {assign(s); return *this;}
+#endif
+
#ifdef XS_STRING_UTF8
void assign(const XS_String& s) {assign(s.c_str());}
#endif
{
FileHolder(LPCTSTR path, LPCTSTR mode)
{
-#ifdef __STDC_WANT_SECURE_LIB__ // secure CRT functions using VS 2005
+//@@ _MS_VER: temporarily needed for the ReactOS build environment
+#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER) // secure CRT functions using VS 2005
if (_tfopen_s(&_pfile, path, mode) != 0)
_pfile = NULL;
#else
_buf(_pfile)
#endif
{
+ if (!_pfile)
+ setstate(badbit);
}
protected:
_buf(_pfile)
#endif
{
+ if (!_pfile)
+ setstate(badbit);
}
~tofstream()
{
Children::iterator it, next=_children.begin();
- while((it=next++)!=_children.end())
+ while((it=next++) != _children.end())
if (**it == name)
_children.erase(it);
}
/// index operator attribute access
template<typename T> XS_String get(const T& attr_name) const {return (*_cur)[attr_name];}
XS_String& operator[](const XS_String& attr_name) {return (*_cur)[attr_name];}
+ const XS_String& operator[](const XS_String& attr_name) const {return (*_cur)[attr_name];}
/// insert children when building tree
void add_down(XMLNode* child)
add_down(new XMLNode(name));
}
+ /// create node with string content
+ void create_node_content(const XS_String& node_name, const XS_String& content)
+ {
+ XMLNode* pNode = new XMLNode(node_name);
+ pNode->set_content(content);
+ _cur->add_child(pNode);
+ }
+
/// create node if not already existing and move to it
void smart_create(const XS_String& child_name)
{
/// index operator attribute access
template<typename T> XS_String get(const T& attr_name) const {return _cur->get(attr_name);}
+ XS_String operator[](const XS_String& attr_name) const {return _cur->get(attr_name);}
/// go back to previous position
bool back()
bool read_file(LPCTSTR path)
{
tifstream in(path);
+ if (!in.good())
+ return false;
+
XMLReader reader(this, in);
#if defined(_STRING_DEFINED) && !defined(XS_STRING_UTF8)
_stack.top()._content = EncodeXMLString(s.c_str(), cdata);
}
+ /// create node with string content
+ void create_node_content(const XS_String& node_name, const XS_String& content)
+ {
+ create(node_name);
+ set_content(content);
+ back();
+ }
+
// public for access in StackEntry
enum WRITESTATE {
NOTHING, /*PRE,*/ ATTRIBUTES, PRE_CLOSED, /*CONTENT,*/ POST