From 858d5b84cb2f9311d6e00d90c6f9527e2e6f57b4 Mon Sep 17 00:00:00 2001
From: lifan <2308045698@qq.com>
Date: 星期四, 04 九月 2025 17:50:13 +0800
Subject: [PATCH] update
---
jrj/xframe/src/xstring.cpp | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/jrj/xframe/src/xstring.cpp b/jrj/xframe/src/xstring.cpp
index 23f1c2c..785d733 100644
--- a/jrj/xframe/src/xstring.cpp
+++ b/jrj/xframe/src/xstring.cpp
@@ -172,7 +172,8 @@
p->initial();
p->flag = kUTF16 | kShouldFree;
p->m_len = len;
- nstring::toWStr(value,p->alloc(p->m_len+1),p->m_len+1);
+ p->m_val = p->alloc(p->m_len + 1);
+ nstring::toWStr(value,p->m_val,p->m_len+1);
return p;
}
@@ -185,7 +186,8 @@
p->initial();
p->flag = kUTF16 | kShouldFree;
p->m_len = len;
- nstring::toWStr(value,p->alloc(p->m_len+1),p->m_len+1);
+ p->m_val = p->alloc(p->m_len + 1);
+ nstring::toWStr(value,p->m_val,p->m_len+1);
return p;
}
public:
@@ -255,6 +257,7 @@
if(rhs.data)((KStringBlock<wchar_t>*)rhs.data)->AddRef();
}
+
xstring::xstring(wchar_t* val, bool shouldSysFree) :data(KStringBlock<wchar_t>::make(val,shouldSysFree))
{
@@ -268,14 +271,19 @@
{
}
+xstring::xstring(LPARAM val, bool bdata) :data(bdata?(void*)val:(KStringBlock<wchar_t>::make(val)))
+{
+ if (bdata)
+ {
+ ((KStringBlock<wchar_t>*)data)->AddRef();
+ }
+}
+
xstring::xstring(double val):data((KStringBlock<wchar_t>::make(val)))
{
}
-xstring::xstring(LPARAM val):data((KStringBlock<wchar_t>::make(val)))
-{
-}
xstring::~xstring()
{
@@ -284,8 +292,13 @@
xstring& xstring::operator =(const xstring& rhs)
{
if (data)((KStringBlock<wchar_t>*)data)->Release();
- ((KStringBlock<wchar_t>*)rhs.data)->AddRef();
- data = rhs.data;
+ if (rhs.data)
+ {
+ ((KStringBlock<wchar_t>*)rhs.data)->AddRef();
+ data = rhs.data;
+ }
+ else
+ data = nullptr;
return *this;
}
xstring& xstring::operator =(const wchar_t* rhs)
@@ -368,7 +381,7 @@
xstring::operator bool()
{
- return this->isEmpty();
+ return !this->isEmpty();
}
const wchar_t* xstring::c_str(bool bclone) const{
@@ -590,7 +603,11 @@
return false;
}
-xstring xstring::replace(wchar_t* from, wchar_t* to, int pos)
+xstring xstring::replace(const wchar_t* from, const wchar_t* to)
+{
+ return replace(from, to, 0);
+}
+xstring xstring::replace(const wchar_t* from, const wchar_t* to, int pos)
{
const wchar_t* pstr = c_str();
if (!pstr) return 0;
--
Gitblit v1.9.3