summaryrefslogtreecommitdiff
path: root/plugins/Quotes/src/XMLEngineMI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Quotes/src/XMLEngineMI.cpp')
-rw-r--r--plugins/Quotes/src/XMLEngineMI.cpp128
1 files changed, 64 insertions, 64 deletions
diff --git a/plugins/Quotes/src/XMLEngineMI.cpp b/plugins/Quotes/src/XMLEngineMI.cpp
index fd329db61d..7e9e3f6016 100644
--- a/plugins/Quotes/src/XMLEngineMI.cpp
+++ b/plugins/Quotes/src/XMLEngineMI.cpp
@@ -5,22 +5,22 @@ XML_API xi;
namespace
{
class CXMLNodeMI : public IXMLNode,
- private boost::noncopyable
+ private boost::noncopyable
{
public:
typedef boost::shared_ptr<IXMLNode> TXMLNodePtr;
public:
- explicit CXMLNodeMI(HXML hXMl,bool bDestroy = false) : m_hXML(hXMl),m_bDestroy(bDestroy)
+ explicit CXMLNodeMI(HXML hXMl, bool bDestroy = false) : m_hXML(hXMl), m_bDestroy(bDestroy)
{
assert(m_hXML);
}
virtual ~CXMLNodeMI()
{
- if(m_bDestroy)
+ if (m_bDestroy)
{
- xi.destroyNode(m_hXML);
+ xi.destroyNode(m_hXML);
}
}
@@ -29,10 +29,10 @@ namespace
return xi.getChildCount(m_hXML);
}
- virtual TXMLNodePtr GetChildNode(size_t nIndex)const
+ virtual TXMLNodePtr GetChildNode(size_t nIndex)const
{
HXML h = xi.getChild(m_hXML, (int)nIndex);
- if(h)
+ if (h)
{
return TXMLNodePtr(new CXMLNodeMI(h));
}
@@ -46,7 +46,7 @@ namespace
{
tstring sResult;
LPCTSTR psz = xi.getText(m_hXML);
- if(psz)
+ if (psz)
{
sResult = psz;
}
@@ -58,7 +58,7 @@ namespace
{
tstring sResult;
LPCTSTR psz = xi.getName(m_hXML);
- if(psz)
+ if (psz)
{
sResult = psz;
}
@@ -69,9 +69,9 @@ namespace
virtual bool AddChild(const TXMLNodePtr& pNode)
{
CXMLNodeMI* pXML = dynamic_cast<CXMLNodeMI*>(pNode.get());
- if(pXML)
+ if (pXML)
{
- xi.addChild2(pXML->m_hXML,m_hXML);
+ xi.addChild2(pXML->m_hXML, m_hXML);
pXML->m_bDestroy = false;
return true;
}
@@ -81,42 +81,42 @@ namespace
}
}
- virtual bool AddAttribute(const tstring& rsName,const tstring& rsValue)
+ virtual bool AddAttribute(const tstring& rsName, const tstring& rsValue)
{
- xi.addAttr(m_hXML,rsName.c_str(),rsValue.c_str());
+ xi.addAttr(m_hXML, rsName.c_str(), rsValue.c_str());
return true;
}
virtual tstring GetAttributeValue(const tstring& rsAttrName)
{
- LPCTSTR pszValue = xi.getAttrValue(m_hXML,rsAttrName.c_str());
+ LPCTSTR pszValue = xi.getAttrValue(m_hXML, rsAttrName.c_str());
return ((NULL != pszValue) ? tstring(pszValue) : tstring());
}
virtual void Write(tostream& o)const
{
-// struct safe_string
-// {
-// safe_string(LPTSTR p):m_p(p){}
-// ~safe_string(){xi.freeMem(m_p);}
-//
-// LPTSTR m_p;
-// };
-//
-// struct mir_safe_string
-// {
-// mir_safe_string(LPSTR p) : m_p(p){}
-// ~mir_safe_string(){mir_free(m_p);}
-//
-// LPSTR m_p;
-// };
-
-
- safe_string<TCHAR> ss(xi.toString(m_hXML,NULL));
- if(ss.m_p)
+ // struct safe_string
+ // {
+ // safe_string(LPTSTR p):m_p(p){}
+ // ~safe_string(){xi.freeMem(m_p);}
+ //
+ // LPTSTR m_p;
+ // };
+ //
+ // struct mir_safe_string
+ // {
+ // mir_safe_string(LPSTR p) : m_p(p){}
+ // ~mir_safe_string(){mir_free(m_p);}
+ //
+ // LPSTR m_p;
+ // };
+
+
+ safe_string<TCHAR> ss(xi.toString(m_hXML, NULL));
+ if (ss.m_p)
{
mir_safe_string<char> mss(mir_utf8encodeT(ss.m_p));
- if(mss.m_p)
+ if (mss.m_p)
{
o << mss.m_p;
}
@@ -139,37 +139,37 @@ CXMLEngineMI::~CXMLEngineMI()
IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const
{
-// struct mir_safe_string
-// {
-// mir_safe_string(LPTSTR p) : m_p(p){}
-// ~mir_safe_string(){mir_free(m_p);}
-//
-// LPTSTR m_p;
-// };
+ // struct mir_safe_string
+ // {
+ // mir_safe_string(LPTSTR p) : m_p(p){}
+ // ~mir_safe_string(){mir_free(m_p);}
+ //
+ // LPTSTR m_p;
+ // };
IXMLNode::TXMLNodePtr pResult;
FILE* stream;
- if(0 == ::_tfopen_s(&stream,rsFileName.c_str(),_T("r")))
+ if (0 == ::_tfopen_s(&stream, rsFileName.c_str(), _T("r")))
{
struct _stat st;
- if (-1 != ::_fstat(::_fileno(stream),&st))
+ if (-1 != ::_fstat(::_fileno(stream), &st))
{
- std::vector<char> aBuffer(st.st_size+1);
+ std::vector<char> aBuffer(st.st_size + 1);
char* pBuffer = &*(aBuffer.begin());
- size_t cBytes = ::fread(pBuffer,sizeof(char),st.st_size,stream);
- if(cBytes > 0 && cBytes <= static_cast<size_t>(st.st_size))
+ size_t cBytes = ::fread(pBuffer, sizeof(char), st.st_size, stream);
+ if (cBytes > 0 && cBytes <= static_cast<size_t>(st.st_size))
{
pBuffer[cBytes] = '\0';
- int nLen = (int)cBytes;
+ int nLen = (int)cBytes;
mir_safe_string<TCHAR> ss(mir_utf8decodeT(pBuffer));
- if(ss.m_p)
+ if (ss.m_p)
{
- HXML h = xi.parseString(ss.m_p,&nLen,NULL);
- if(h)
+ HXML h = xi.parseString(ss.m_p, &nLen, NULL);
+ if (h)
{
- pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h,true));
+ pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true));
}
}
}
@@ -182,36 +182,36 @@ IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const
namespace
{
- IXMLNode::TXMLNodePtr create_node(const tstring& rsName,const tstring& rsText,bool bIsDecl)
+ IXMLNode::TXMLNodePtr create_node(const tstring& rsName, const tstring& rsText, bool bIsDecl)
{
IXMLNode::TXMLNodePtr pResult;
- HXML h = xi.createNode(rsName.c_str(),rsText.c_str(),bIsDecl);
- if(h)
+ HXML h = xi.createNode(rsName.c_str(), rsText.c_str(), bIsDecl);
+ if (h)
{
- pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h,true));
+ pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true));
}
return pResult;
}
}
-bool CXMLEngineMI::SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePtr& pNode)const
+bool CXMLEngineMI::SaveFile(const tstring& rsFileName, const IXMLNode::TXMLNodePtr& pNode)const
{
CXMLNodeMI* pXML = dynamic_cast<CXMLNodeMI*>(pNode.get());
- if(pXML)
+ if (pXML)
{
tofstream file(rsFileName.c_str());
- if(file.good())
+ if (file.good())
{
- IXMLNode::TXMLNodePtr pRoot(create_node(_T("xml"),tstring(),true));
- if(pRoot)
+ IXMLNode::TXMLNodePtr pRoot(create_node(_T("xml"), tstring(), true));
+ if (pRoot)
{
- pRoot->AddAttribute(_T("version"),_T("1.0"));
- pRoot->AddAttribute(_T("encoding"),_T("UTF-8"));
+ pRoot->AddAttribute(_T("version"), _T("1.0"));
+ pRoot->AddAttribute(_T("encoding"), _T("UTF-8"));
file << *pRoot;
}
- if(file.good())
+ if (file.good())
{
file << *pNode;
}
@@ -223,7 +223,7 @@ bool CXMLEngineMI::SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePt
return false;
}
-IXMLNode::TXMLNodePtr CXMLEngineMI::CreateNode(const tstring& rsName,const tstring& rsText)const
+IXMLNode::TXMLNodePtr CXMLEngineMI::CreateNode(const tstring& rsName, const tstring& rsText)const
{
- return create_node(rsName,rsText,false);
+ return create_node(rsName, rsText, false);
} \ No newline at end of file