使用cstring替代const char*
This commit is contained in:
parent
01f6d900ba
commit
921f0553e1
|
@ -18,7 +18,7 @@ private:
|
|||
EventHandler _Handler;
|
||||
void* _Param;
|
||||
public:
|
||||
const char* Name; // 按钮名称
|
||||
cstring Name; // 按钮名称
|
||||
int Index; // 索引号,方便在众多按钮中标识按钮
|
||||
|
||||
InputPort Key; // 输入按键
|
||||
|
|
|
@ -269,7 +269,7 @@ void Button_GrayLevel::Init(TIMER tim, byte count, Button_GrayLevel* btns, Event
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
const char* names[] = { "一号", "二号", "三号", "四号" };
|
||||
cstring names[] = { "一号", "二号", "三号", "四号" };
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
|
|
|
@ -32,7 +32,7 @@ class Button_GrayLevel : public ByteDataPort
|
|||
public:
|
||||
int Index; // 索引号,方便在众多按钮中标识按钮
|
||||
#if DEBUG
|
||||
const char* Name; // 按钮名称
|
||||
cstring Name; // 按钮名称
|
||||
#endif
|
||||
|
||||
InputPort Key; // 输入按键
|
||||
|
|
|
@ -23,7 +23,7 @@ private:
|
|||
EventHandler _Handler;
|
||||
void* _Param;
|
||||
public:
|
||||
const char* Name;
|
||||
cstring Name;
|
||||
|
||||
InputPort* Key; // 输入按键
|
||||
OutputPort* Led; // 指示灯
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class Sensor
|
||||
{
|
||||
public:
|
||||
const char* Name; //名字
|
||||
cstring Name; //名字
|
||||
int Index; //索引号
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static uint OnSerial(ITransport* transport, Buffer& bs, void* param, void* param
|
|||
}
|
||||
#endif
|
||||
|
||||
void AP0104::Setup(ushort code, const char* name, COM message, int baudRate)
|
||||
void AP0104::Setup(ushort code, cstring name, COM message, int baudRate)
|
||||
{
|
||||
auto& sys = (TSys&)Sys;
|
||||
sys.Code = code;
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
AP0104();
|
||||
|
||||
void Setup(ushort code, const char* name, COM message = COM1, int baudRate = 0);
|
||||
void Setup(ushort code, cstring name, COM message = COM1, int baudRate = 0);
|
||||
|
||||
ISocketHost* Create5500();
|
||||
ITransport* Create2401();
|
||||
|
|
|
@ -40,7 +40,7 @@ static uint OnSerial(ITransport* transport, Buffer& bs, void* param, void* param
|
|||
}
|
||||
#endif
|
||||
|
||||
void AP0801::Setup(ushort code, const char* name, COM message, int baudRate)
|
||||
void AP0801::Setup(ushort code, cstring name, COM message, int baudRate)
|
||||
{
|
||||
auto& sys = (TSys&)Sys;
|
||||
sys.Code = code;
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
AP0801();
|
||||
|
||||
void Setup(ushort code, const char* name, COM message = COM1, int baudRate = 0);
|
||||
void Setup(ushort code, cstring name, COM message = COM1, int baudRate = 0);
|
||||
|
||||
ISocketHost* Create5500();
|
||||
ITransport* Create2401();
|
||||
|
|
|
@ -37,7 +37,7 @@ uint OnSerial(ITransport* transport, Buffer& bs, void* param, void* param2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void PA0903::Setup(ushort code, const char* name, COM message, int baudRate)
|
||||
void PA0903::Setup(ushort code, cstring name, COM message, int baudRate)
|
||||
{
|
||||
auto& sys = (TSys&)Sys;
|
||||
sys.Code = code;
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
PA0903();
|
||||
|
||||
void Setup(ushort code, const char* name, COM message = COM1, int baudRate = 0);
|
||||
void Setup(ushort code, cstring name, COM message = COM1, int baudRate = 0);
|
||||
|
||||
ISocketHost* Create5500();
|
||||
//ITransport* Create2401();
|
||||
|
|
4
Config.h
4
Config.h
|
@ -30,7 +30,7 @@ public:
|
|||
// 获取配置数据
|
||||
bool Get(const String& name, Buffer& bs) const;
|
||||
// 获取配置数据,如果不存在则覆盖
|
||||
//bool GetOrSet(const char* name, Buffer& bs) const;
|
||||
//bool GetOrSet(cstring name, Buffer& bs) const;
|
||||
// 获取配置数据
|
||||
const void* Get(const String& name) const;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
protected:
|
||||
const Config& Cfg;
|
||||
const char* _Name;
|
||||
cstring _Name;
|
||||
|
||||
void* _Start;
|
||||
void* _End;
|
||||
|
|
|
@ -57,14 +57,14 @@ ByteArray::ByteArray(ByteArray&& rval) : Array((const void*)nullptr, 0)
|
|||
/*// 字符串转为字节数组
|
||||
ByteArray::ByteArray(String& str) : Array(Arr, str.Length())
|
||||
{
|
||||
char* p = str.GetBuffer();
|
||||
auto p = str.GetBuffer();
|
||||
Set((byte*)p, str.Length());
|
||||
}
|
||||
|
||||
// 不允许修改,拷贝
|
||||
ByteArray::ByteArray(const String& str) : Array(Arr, str.Length())
|
||||
{
|
||||
const char* p = str.GetBuffer();
|
||||
cstring p = str.GetBuffer();
|
||||
//Copy((const byte*)p, str.Length());
|
||||
Set((const byte*)p, str.Length());
|
||||
}*/
|
||||
|
|
|
@ -371,12 +371,12 @@ String& DateTime::ToStr(String& str) const
|
|||
f短全部 M/d/yy HH:mm
|
||||
F长全部 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
const char* DateTime::GetString(byte kind, char* str)
|
||||
cstring DateTime::GetString(byte kind, char* str)
|
||||
{
|
||||
//assert_param(str);
|
||||
//if(!str) str = _Str;
|
||||
|
||||
const DateTime& st = *this;
|
||||
auto& st = *this;
|
||||
switch(kind)
|
||||
{
|
||||
case 'd':
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
f短全部 M/d/yy HH:mm
|
||||
F长全部 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
const char* GetString(byte kind = 'F', char* str = nullptr);
|
||||
cstring GetString(byte kind = 'F', char* str = nullptr);
|
||||
|
||||
// 当前时间
|
||||
static DateTime Now();
|
||||
|
|
|
@ -11,13 +11,13 @@ class StringSplit;
|
|||
class String : public Array
|
||||
{
|
||||
public:
|
||||
String(const char* cstr = "");
|
||||
String(cstring cstr = "");
|
||||
String(const String& str);
|
||||
String(String&& rval);
|
||||
// 外部传入缓冲区供内部使用,注意长度减去零结束符
|
||||
String(char* str, int length);
|
||||
// 包装静态字符串,直接使用,修改时扩容
|
||||
String(const char* str, int length);
|
||||
String(cstring str, int length);
|
||||
explicit String(char c);
|
||||
explicit String(byte value, int radix = 10);
|
||||
explicit String(short value, int radix = 10);
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
// 内存管理
|
||||
//inline uint Length() const { return _Length; }
|
||||
inline const char* GetBuffer() const { return (const char*)_Arr; }
|
||||
inline cstring GetBuffer() const { return (const char*)_Arr; }
|
||||
// 设置数组长度。改变长度后,确保最后以0结尾
|
||||
virtual bool SetLength(int length, bool bak);
|
||||
|
||||
|
@ -49,13 +49,13 @@ public:
|
|||
// 为被赋值对象建立一个备份。
|
||||
// 如果值为空或无效,或者内存分配失败,字符串将会被标记为无效
|
||||
String& operator = (const String& rhs);
|
||||
String& operator = (const char* cstr);
|
||||
String& operator = (cstring cstr);
|
||||
String& operator = (String&& rval);
|
||||
|
||||
// 连接内建类型。如果参数无效则认为连接失败
|
||||
bool Concat(const Object& obj);
|
||||
bool Concat(const String& str);
|
||||
bool Concat(const char* cstr);
|
||||
bool Concat(cstring cstr);
|
||||
bool Concat(char c);
|
||||
bool Concat(byte c, int radix = 10);
|
||||
bool Concat(short num, int radix = 10);
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
String& operator += (T rhs) {Concat(rhs); return (*this);}*/
|
||||
String& operator += (const Object& rhs) {Concat(rhs); return (*this);}
|
||||
String& operator += (const String& rhs) {Concat(rhs); return (*this);}
|
||||
String& operator += (const char* cstr) {Concat(cstr); return (*this);}
|
||||
String& operator += (cstring cstr) {Concat(cstr); return (*this);}
|
||||
String& operator += (char c) {Concat(c); return (*this);}
|
||||
String& operator += (byte num) {Concat(num); return (*this);}
|
||||
String& operator += (int num) {Concat(num); return (*this);}
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
friend String& operator + (String& lhs, const Object& rhs);
|
||||
friend String& operator + (String& lhs, const String& rhs);
|
||||
friend String& operator + (String& lhs, const char* cstr);
|
||||
friend String& operator + (String& lhs, cstring cstr);
|
||||
friend String& operator + (String& lhs, char c);
|
||||
friend String& operator + (String& lhs, byte num);
|
||||
friend String& operator + (String& lhs, int num);
|
||||
|
@ -98,12 +98,12 @@ public:
|
|||
//operator char*() const { return _Arr; }
|
||||
int CompareTo(const String& s) const;
|
||||
bool Equals(const String& s) const;
|
||||
bool Equals(const char* cstr) const;
|
||||
bool Equals(cstring cstr) const;
|
||||
bool EqualsIgnoreCase(const String& s) const;
|
||||
bool operator == (const String& rhs) const {return Equals(rhs);}
|
||||
bool operator == (const char* cstr) const {return Equals(cstr);}
|
||||
bool operator == (cstring cstr) const {return Equals(cstr);}
|
||||
bool operator != (const String& rhs) const {return !Equals(rhs);}
|
||||
bool operator != (const char* cstr) const {return !Equals(cstr);}
|
||||
bool operator != (cstring cstr) const {return !Equals(cstr);}
|
||||
bool operator < (const String& rhs) const;
|
||||
bool operator > (const String& rhs) const;
|
||||
bool operator <= (const String& rhs) const;
|
||||
|
@ -131,20 +131,20 @@ public:
|
|||
virtual void Show(bool newLine = false) const;
|
||||
|
||||
// 格式化字符串,输出到现有字符串后面。方便我们连续格式化多个字符串
|
||||
String& Format(const char* format, ...);
|
||||
String& Format(cstring format, ...);
|
||||
|
||||
int IndexOf(const char ch, int startIndex = 0) const;
|
||||
int IndexOf(const String& str, int startIndex = 0) const;
|
||||
int IndexOf(const char* str, int startIndex = 0) const;
|
||||
int IndexOf(cstring str, int startIndex = 0) const;
|
||||
int LastIndexOf(const char ch, int startIndex = 0) const;
|
||||
int LastIndexOf(const String& str, int startIndex = 0) const;
|
||||
int LastIndexOf(const char* str, int startIndex = 0) const;
|
||||
int LastIndexOf(cstring str, int startIndex = 0) const;
|
||||
bool Contains(const String& str) const;
|
||||
bool Contains(const char* str) const;
|
||||
bool Contains(cstring str) const;
|
||||
bool StartsWith(const String& str, int startIndex = 0) const;
|
||||
bool StartsWith(const char* str, int startIndex = 0) const;
|
||||
bool StartsWith(cstring str, int startIndex = 0) const;
|
||||
bool EndsWith(const String& str) const;
|
||||
bool EndsWith(const char* str) const;
|
||||
bool EndsWith(cstring str) const;
|
||||
|
||||
StringSplit Split(const String& sep) const;
|
||||
|
||||
|
@ -171,9 +171,9 @@ protected:
|
|||
protected:
|
||||
void init();
|
||||
void release();
|
||||
bool Concat(const char* cstr, uint length);
|
||||
bool Concat(cstring cstr, uint length);
|
||||
|
||||
String& copy(const char* cstr, uint length);
|
||||
String& copy(cstring cstr, uint length);
|
||||
void move(String& rhs);
|
||||
bool CopyOrWrite();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ char* dtostrf(double val, char width, byte prec, char* sout);
|
|||
|
||||
/******************************** String ********************************/
|
||||
|
||||
String::String(const char* cstr) : Array(Arr, ArrayLength(Arr))
|
||||
String::String(cstring cstr) : Array(Arr, ArrayLength(Arr))
|
||||
{
|
||||
init();
|
||||
|
||||
|
@ -132,7 +132,7 @@ String::String(char* str, int length) : Array(str, length)
|
|||
}
|
||||
|
||||
// 包装静态字符串,直接使用,修改时扩容
|
||||
String::String(const char* str, int length) : Array((char*)str, length)
|
||||
String::String(cstring str, int length) : Array((char*)str, length)
|
||||
{
|
||||
// 此时不能保证外部一定是0结尾
|
||||
_Capacity = length + 1;
|
||||
|
@ -183,7 +183,7 @@ void* String::Alloc(int len)
|
|||
}
|
||||
}
|
||||
|
||||
String& String::copy(const char* cstr, uint length)
|
||||
String& String::copy(cstring cstr, uint length)
|
||||
{
|
||||
if(!cstr || !length) return *this;
|
||||
|
||||
|
@ -311,7 +311,7 @@ String& String::operator = (String&& rval)
|
|||
return *this;
|
||||
}
|
||||
|
||||
String& String::operator = (const char* cstr)
|
||||
String& String::operator = (cstring cstr)
|
||||
{
|
||||
if (cstr) copy(cstr, strlen(cstr));
|
||||
else release();
|
||||
|
@ -329,7 +329,7 @@ bool String::Concat(const String& s)
|
|||
return Concat(s._Arr, s._Length);
|
||||
}
|
||||
|
||||
bool String::Concat(const char* cstr, uint length)
|
||||
bool String::Concat(cstring cstr, uint length)
|
||||
{
|
||||
if (!cstr) return false;
|
||||
if (length == 0) return true;
|
||||
|
@ -345,7 +345,7 @@ bool String::Concat(const char* cstr, uint length)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool String::Concat(const char* cstr)
|
||||
bool String::Concat(cstring cstr)
|
||||
{
|
||||
if (!cstr) return 0;
|
||||
return Concat(cstr, strlen(cstr));
|
||||
|
@ -468,14 +468,14 @@ bool String::Concat(UInt64 num, int radix)
|
|||
bool String::Concat(float num, byte decimalPlaces)
|
||||
{
|
||||
char buf[20];
|
||||
char* string = dtostrf(num, (decimalPlaces + 2), decimalPlaces, buf);
|
||||
auto string = dtostrf(num, (decimalPlaces + 2), decimalPlaces, buf);
|
||||
return Concat(string, strlen(string));
|
||||
}
|
||||
|
||||
bool String::Concat(double num, byte decimalPlaces)
|
||||
{
|
||||
char buf[20];
|
||||
char* string = dtostrf(num, (decimalPlaces + 2), decimalPlaces, buf);
|
||||
auto string = dtostrf(num, (decimalPlaces + 2), decimalPlaces, buf);
|
||||
return Concat(string, strlen(string));
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ String& operator + (String& lhs, const String& rhs)
|
|||
return a;
|
||||
}
|
||||
|
||||
String& operator + (String& lhs, const char* cstr)
|
||||
String& operator + (String& lhs, cstring cstr)
|
||||
{
|
||||
auto& a = const_cast<String&>(lhs);
|
||||
if (!cstr || !a.Concat(cstr, strlen(cstr))) a.release();
|
||||
|
@ -572,7 +572,7 @@ bool String::Equals(const String& s2) const
|
|||
return _Length == s2._Length && CompareTo(s2) == 0;
|
||||
}
|
||||
|
||||
bool String::Equals(const char* cstr) const
|
||||
bool String::Equals(cstring cstr) const
|
||||
{
|
||||
if (_Length == 0) return cstr == nullptr || *cstr == 0;
|
||||
if (cstr == nullptr) return _Arr[0] == 0;
|
||||
|
@ -585,8 +585,8 @@ bool String::EqualsIgnoreCase(const String &s2 ) const
|
|||
if (this == &s2) return true;
|
||||
if (_Length != s2._Length) return false;
|
||||
if (_Length == 0) return true;
|
||||
const char *p1 = _Arr;
|
||||
const char *p2 = s2._Arr;
|
||||
auto p1 = _Arr;
|
||||
auto p2 = s2._Arr;
|
||||
while (*p1) {
|
||||
if (tolower(*p1++) != tolower(*p2++)) return false;
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ ByteArray String::ToHex() const
|
|||
char cs[3];
|
||||
cs[2] = 0;
|
||||
byte* b = bs.GetBuffer();
|
||||
char* p = _Arr;
|
||||
auto p = _Arr;
|
||||
int n = 0;
|
||||
for(int i=0; i<_Length; i+=2)
|
||||
{
|
||||
|
@ -730,7 +730,7 @@ void String::Show(bool newLine) const
|
|||
}
|
||||
|
||||
// 格式化字符串,输出到现有字符串后面。方便我们连续格式化多个字符串
|
||||
String& String::Format(const char* format, ...)
|
||||
String& String::Format(cstring format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
@ -769,7 +769,7 @@ int String::IndexOf(const String& str, int startIndex) const
|
|||
return p - _Arr;
|
||||
}
|
||||
|
||||
int String::IndexOf(const char* str, int startIndex) const
|
||||
int String::IndexOf(cstring str, int startIndex) const
|
||||
{
|
||||
if(!str) return -1;
|
||||
if(startIndex + strlen(str) > _Length) return -1;
|
||||
|
@ -790,7 +790,7 @@ int String::LastIndexOf(const char ch, int startIndex) const
|
|||
return p - _Arr;
|
||||
}
|
||||
|
||||
char *strrstr(const char* s, const char* str)
|
||||
char *strrstr(cstring s, cstring str)
|
||||
{
|
||||
char *p;
|
||||
int _Length = strlen(s);
|
||||
|
@ -812,7 +812,7 @@ int String::LastIndexOf(const String& str, int startIndex) const
|
|||
return p - _Arr;
|
||||
}
|
||||
|
||||
int String::LastIndexOf(const char* str, int startIndex) const
|
||||
int String::LastIndexOf(cstring str, int startIndex) const
|
||||
{
|
||||
if(!str) return -1;
|
||||
if(startIndex + strlen(str) > _Length) return -1;
|
||||
|
@ -825,7 +825,7 @@ int String::LastIndexOf(const char* str, int startIndex) const
|
|||
|
||||
bool String::Contains(const String& str) const { return IndexOf(str) >= 0; }
|
||||
|
||||
bool String::Contains(const char* str) const { return IndexOf(str) >= 0; }
|
||||
bool String::Contains(cstring str) const { return IndexOf(str) >= 0; }
|
||||
|
||||
bool String::StartsWith(const String& str, int startIndex) const
|
||||
{
|
||||
|
@ -833,7 +833,7 @@ bool String::StartsWith(const String& str, int startIndex) const
|
|||
return strncmp(&_Arr[startIndex], str._Arr, str._Length) == 0;
|
||||
}
|
||||
|
||||
bool String::StartsWith(const char* str, int startIndex) const
|
||||
bool String::StartsWith(cstring str, int startIndex) const
|
||||
{
|
||||
if(!str) return false;
|
||||
int slen = strlen(str);
|
||||
|
@ -849,7 +849,7 @@ bool String::EndsWith(const String& str) const
|
|||
return strncmp(&_Arr[_Length - str._Length], str._Arr, str._Length) == 0;
|
||||
}
|
||||
|
||||
bool String::EndsWith(const char* str) const
|
||||
bool String::EndsWith(cstring str) const
|
||||
{
|
||||
if(!str) return false;
|
||||
int slen = strlen(str);
|
||||
|
|
13
Core/Type.h
13
Core/Type.h
|
@ -2,12 +2,13 @@
|
|||
#define __Type_H__
|
||||
|
||||
/* 类型定义 */
|
||||
typedef char sbyte;
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long long UInt64;
|
||||
typedef long long Int64;
|
||||
typedef char sbyte;
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long long UInt64;
|
||||
typedef long long Int64;
|
||||
typedef const char* cstring;
|
||||
|
||||
#define UInt64_Max 0xFFFFFFFFFFFFFFFFull
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ void assert_failed(uint8_t* file, unsigned int line)
|
|||
while (1) { }
|
||||
}
|
||||
|
||||
void assert_failed2(const char* msg, const char* file, unsigned int line)
|
||||
void assert_failed2(cstring msg, cstring file, unsigned int line)
|
||||
{
|
||||
debug_printf("%s Line %d, %s\r\n", msg, line, file);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class BufferPort
|
||||
{
|
||||
public:
|
||||
const char* Name;
|
||||
cstring Name;
|
||||
ITransport* Port;
|
||||
int Speed;
|
||||
COM Com;
|
||||
|
|
|
@ -60,7 +60,7 @@ void Sim900A::OnClose()
|
|||
bool Sim900A::OnWrite(const Buffer& bs) { return Send(bs); }
|
||||
uint Sim900A::OnRead(Buffer& bs) { return 0; }
|
||||
|
||||
String Sim900A::Send(const char* str, uint msTimeout)
|
||||
String Sim900A::Send(cstring str, uint msTimeout)
|
||||
{
|
||||
if(str)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ String Sim900A::Send(const char* str, uint msTimeout)
|
|||
return bs;
|
||||
}
|
||||
|
||||
bool Sim900A::SendCmd(const char* str, uint msTimeout, int times)
|
||||
bool Sim900A::SendCmd(cstring str, uint msTimeout, int times)
|
||||
{
|
||||
for(int i=0; i<times; i++)
|
||||
{
|
||||
|
|
|
@ -14,9 +14,9 @@ public:
|
|||
bool Inited;
|
||||
bool SendOK;
|
||||
|
||||
const char* Domain;
|
||||
cstring Domain;
|
||||
|
||||
const char* APN;
|
||||
cstring APN;
|
||||
|
||||
IDataPort* Led; // 指示灯
|
||||
|
||||
|
@ -36,8 +36,8 @@ private:
|
|||
virtual bool OnWrite(const Buffer& bs);
|
||||
virtual uint OnRead(Buffer& bs);
|
||||
|
||||
String Send(const char* str, uint msTimeout = 1000);
|
||||
bool SendCmd(const char* str, uint msTimeout = 1000, int times = 1);
|
||||
String Send(cstring str, uint msTimeout = 1000);
|
||||
bool SendCmd(cstring str, uint msTimeout = 1000, int times = 1);
|
||||
void SendAPN(bool issgp);
|
||||
void SendDomain();
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
class UBlox : public BufferPort
|
||||
{
|
||||
public:
|
||||
const char* Header; // 识别为数据包开头的字符串
|
||||
cstring Header; // 识别为数据包开头的字符串
|
||||
|
||||
UBlox();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
// 输出物理链路层状态
|
||||
void PhyStateShow();
|
||||
|
||||
const char* ToString() const { return "W5500"; }
|
||||
cstring ToString() const { return "W5500"; }
|
||||
|
||||
virtual ISocket* CreateSocket(ProtocolType type);
|
||||
|
||||
|
|
|
@ -394,10 +394,10 @@ bool Lock::Wait(int us)
|
|||
static const char** _TS = nullptr;
|
||||
static int _TS_Len = 0;
|
||||
|
||||
TraceStack::TraceStack(const char* name)
|
||||
TraceStack::TraceStack(cstring name)
|
||||
{
|
||||
// 字符串指针的数组
|
||||
static const char* __ts[16];
|
||||
static cstring __ts[16];
|
||||
_TS = __ts;
|
||||
|
||||
//_TS->Push(name);
|
||||
|
|
|
@ -111,7 +111,7 @@ extern "C"
|
|||
class TraceStack
|
||||
{
|
||||
public:
|
||||
TraceStack(const char* name);
|
||||
TraceStack(cstring name);
|
||||
~TraceStack();
|
||||
|
||||
static void Show();
|
||||
|
|
|
@ -16,7 +16,7 @@ BinaryPair::BinaryPair(Stream& ms)
|
|||
_p = ms.Position();
|
||||
}
|
||||
|
||||
Buffer BinaryPair::Get(const char* name) const
|
||||
Buffer BinaryPair::Get(cstring name) const
|
||||
{
|
||||
// 暂时不方便支持空名称的名值对,而服务端是支持的
|
||||
if(!name) return Buffer(nullptr, 0);
|
||||
|
@ -49,7 +49,7 @@ Buffer BinaryPair::Get(const char* name) const
|
|||
return Buffer(nullptr, 0);
|
||||
}
|
||||
|
||||
bool BinaryPair::Set(const char* name, const Buffer& bs)
|
||||
bool BinaryPair::Set(cstring name, const Buffer& bs)
|
||||
{
|
||||
auto& ms = *_s;
|
||||
ms.WriteArray(Buffer((void*)name, strlen(name)));
|
||||
|
@ -67,7 +67,7 @@ bool BinaryPair::Set(const String& name, const Buffer& bs)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, byte& value) const
|
||||
bool BinaryPair::Get(cstring name, byte& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(!bs.Length()) return false;
|
||||
|
@ -77,7 +77,7 @@ bool BinaryPair::Get(const char* name, byte& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, ushort& value) const
|
||||
bool BinaryPair::Get(cstring name, ushort& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(!bs.Length()) return false;
|
||||
|
@ -87,7 +87,7 @@ bool BinaryPair::Get(const char* name, ushort& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, uint& value) const
|
||||
bool BinaryPair::Get(cstring name, uint& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(!bs.Length()) return false;
|
||||
|
@ -97,7 +97,7 @@ bool BinaryPair::Get(const char* name, uint& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, UInt64& value) const
|
||||
bool BinaryPair::Get(cstring name, UInt64& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(!bs.Length()) return false;
|
||||
|
@ -107,7 +107,7 @@ bool BinaryPair::Get(const char* name, UInt64& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, Buffer& value) const
|
||||
bool BinaryPair::Get(cstring name, Buffer& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(!bs.Length()) return false;
|
||||
|
@ -117,7 +117,7 @@ bool BinaryPair::Get(const char* name, Buffer& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BinaryPair::Get(const char* name, IPEndPoint& value) const
|
||||
bool BinaryPair::Get(cstring name, IPEndPoint& value) const
|
||||
{
|
||||
auto bs = Get(name);
|
||||
if(bs.Length() < 6) return false;
|
||||
|
@ -131,27 +131,27 @@ bool BinaryPair::Get(const char* name, IPEndPoint& value) const
|
|||
}
|
||||
|
||||
|
||||
bool BinaryPair::Set(const char* name, byte value)
|
||||
bool BinaryPair::Set(cstring name, byte value)
|
||||
{
|
||||
return Set(name, Buffer(&value, 1));
|
||||
}
|
||||
|
||||
bool BinaryPair::Set(const char* name, ushort value)
|
||||
bool BinaryPair::Set(cstring name, ushort value)
|
||||
{
|
||||
return Set(name, Buffer(&value, 2));
|
||||
}
|
||||
|
||||
bool BinaryPair::Set(const char* name, uint value)
|
||||
bool BinaryPair::Set(cstring name, uint value)
|
||||
{
|
||||
return Set(name, Buffer(&value, 4));
|
||||
}
|
||||
|
||||
bool BinaryPair::Set(const char* name, UInt64 value)
|
||||
bool BinaryPair::Set(cstring name, UInt64 value)
|
||||
{
|
||||
return Set(name, Buffer(&value, 8));
|
||||
}
|
||||
|
||||
bool BinaryPair::Set(const char* name, const IPEndPoint& value)
|
||||
bool BinaryPair::Set(cstring name, const IPEndPoint& value)
|
||||
{
|
||||
MemoryStream ms(7);
|
||||
|
||||
|
|
|
@ -15,22 +15,22 @@ public:
|
|||
BinaryPair(Stream& ms);
|
||||
BinaryPair(const BinaryPair& pair) = delete;
|
||||
|
||||
Buffer Get(const char* name) const;
|
||||
bool Set(const char* name, const Buffer& bs);
|
||||
Buffer Get(cstring name) const;
|
||||
bool Set(cstring name, const Buffer& bs);
|
||||
bool Set(const String& name, const Buffer& bs);
|
||||
|
||||
bool Get(const char* name, byte& value) const;
|
||||
bool Get(const char* name, ushort& value) const;
|
||||
bool Get(const char* name, uint& value) const;
|
||||
bool Get(const char* name, UInt64& value) const;
|
||||
bool Get(const char* name, Buffer& value) const;
|
||||
bool Get(const char* name, IPEndPoint& value) const;
|
||||
bool Get(cstring name, byte& value) const;
|
||||
bool Get(cstring name, ushort& value) const;
|
||||
bool Get(cstring name, uint& value) const;
|
||||
bool Get(cstring name, UInt64& value) const;
|
||||
bool Get(cstring name, Buffer& value) const;
|
||||
bool Get(cstring name, IPEndPoint& value) const;
|
||||
|
||||
bool Set(const char* name, byte value);
|
||||
bool Set(const char* name, ushort value);
|
||||
bool Set(const char* name, uint value);
|
||||
bool Set(const char* name, UInt64 value);
|
||||
bool Set(const char* name, const IPEndPoint& value);
|
||||
bool Set(cstring name, byte value);
|
||||
bool Set(cstring name, ushort value);
|
||||
bool Set(cstring name, uint value);
|
||||
bool Set(cstring name, UInt64 value);
|
||||
bool Set(cstring name, const IPEndPoint& value);
|
||||
|
||||
private:
|
||||
//byte* Data; // 数据指针
|
||||
|
|
|
@ -21,7 +21,7 @@ void Message::SetData(const Buffer& bs, uint offset)
|
|||
if(Length > 0) bs.CopyTo(0, Data + offset, Length);
|
||||
}
|
||||
|
||||
void Message::SetError(byte errorCode, const char* msg)
|
||||
void Message::SetError(byte errorCode, cstring msg)
|
||||
{
|
||||
Error = true;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
// 设置数据
|
||||
void SetData(const Buffer& bs, uint offset = 0);
|
||||
void SetError(byte errorCode, const char* msg = nullptr);
|
||||
void SetError(byte errorCode, cstring msg = nullptr);
|
||||
|
||||
// 负载数据转数据流
|
||||
Stream ToStream();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "WeakStore.h"
|
||||
|
||||
// 初始化
|
||||
WeakStore::WeakStore(const char* magic, byte* ptr, uint len) : Data(0x40)
|
||||
WeakStore::WeakStore(cstring magic, byte* ptr, uint len) : Data(0x40)
|
||||
{
|
||||
Magic = magic;
|
||||
MagicLength = 0;
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
class WeakStore
|
||||
{
|
||||
public:
|
||||
const char* Magic; // 幻数。用于唯一标识
|
||||
cstring Magic; // 幻数。用于唯一标识
|
||||
uint MagicLength;
|
||||
ByteArray Data; // 数据
|
||||
|
||||
// 初始化
|
||||
WeakStore(const char* magic = nullptr, byte* ptr = nullptr, uint len = 0);
|
||||
WeakStore(cstring magic = nullptr, byte* ptr = nullptr, uint len = 0);
|
||||
|
||||
// 检查并确保初始化,返回原来是否已初始化
|
||||
bool Check();
|
||||
|
|
|
@ -225,7 +225,7 @@ bool Blu40::CheckSet()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Blu40::SetName(const char* name)
|
||||
bool Blu40::SetName(cstring name)
|
||||
{
|
||||
*_rts = false;
|
||||
Sys.Delay(170);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
// 设置发送信号强度 DB数
|
||||
bool SetTPL(int TPLDB);
|
||||
// 设置蓝牙名称
|
||||
bool SetName(const char* name);
|
||||
bool SetName(cstring name);
|
||||
// 设置产品识别码 硬件类型code
|
||||
bool SetPID(ushort pid);
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ short dns_makequery(short op, const String& name, Buffer& bs)
|
|||
|
||||
int st = 0;
|
||||
int idx = 0;
|
||||
//const char* dname = name.GetBuffer();
|
||||
//cstring dname = name.GetBuffer();
|
||||
//ushort dlen = strlen(dname);
|
||||
for (;;)
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ short dns_makequery(short op, const String& name, Buffer& bs)
|
|||
st = idx + 1;
|
||||
|
||||
//// 查找下一个小圆点
|
||||
//const char* cp1 = strchr(dname, '.');
|
||||
//cstring cp1 = strchr(dname, '.');
|
||||
//
|
||||
//int len = 0;
|
||||
//if (cp1 != nullptr)
|
||||
|
|
2
Sys.cpp
2
Sys.cpp
|
@ -402,7 +402,7 @@ void TSys::ShowInfo() const
|
|||
#include "Task.h"
|
||||
|
||||
// 创建任务,返回任务编号。dueTime首次调度时间ms,period调度间隔ms,-1表示仅处理一次
|
||||
uint TSys::AddTask(Action func, void* param, int dueTime, int period, const char* name) const
|
||||
uint TSys::AddTask(Action func, void* param, int dueTime, int period, cstring name) const
|
||||
{
|
||||
return Task::Scheduler()->Add(func, param, dueTime, period, name);
|
||||
}
|
||||
|
|
30
Sys.h
30
Sys.h
|
@ -7,6 +7,19 @@
|
|||
/*#include <stdlib.h>
|
||||
#include <string.h>*/
|
||||
|
||||
#include "Core\Type.h"
|
||||
#include "Core\Buffer.h"
|
||||
#include "Core\Array.h"
|
||||
#include "Core\ByteArray.h"
|
||||
#include "Core\SString.h"
|
||||
#include "Core\Stream.h"
|
||||
#include "Core\DateTime.h"
|
||||
#include "Core\Version.h"
|
||||
#include "Core\Delegate.h"
|
||||
|
||||
/* 引脚定义 */
|
||||
#include "Platform\Pin.h"
|
||||
|
||||
// 强迫内联
|
||||
#define _force_inline __attribute__( ( always_inline ) ) __INLINE
|
||||
|
||||
|
@ -31,7 +44,7 @@ extern "C"
|
|||
#define assert_ptr(expr) (assert_ptr_(expr) ? (void)0 : assert_failed2("ptr==nullptr", (const char*)__FILE__, __LINE__))
|
||||
bool assert_ptr_(const void* p);
|
||||
|
||||
void assert_failed2(const char* msg, const char* file, unsigned int line);
|
||||
void assert_failed2(cstring msg, cstring file, unsigned int line);
|
||||
#define assert(expr, msg) ((expr) ? (void)0 : assert_failed2(msg, (const char*)__FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
|
@ -41,19 +54,6 @@ void assert_failed2(const char* msg, const char* file, unsigned int line);
|
|||
|
||||
#endif
|
||||
|
||||
#include "Core\Type.h"
|
||||
#include "Core\Buffer.h"
|
||||
#include "Core\Array.h"
|
||||
#include "Core\ByteArray.h"
|
||||
#include "Core\SString.h"
|
||||
#include "Core\Stream.h"
|
||||
#include "Core\DateTime.h"
|
||||
#include "Core\Version.h"
|
||||
#include "Core\Delegate.h"
|
||||
|
||||
/* 引脚定义 */
|
||||
#include "Platform\Pin.h"
|
||||
|
||||
#if defined(BOOT) || defined(APP)
|
||||
struct HandlerRemap
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
|
||||
public:
|
||||
// 创建任务,返回任务编号。dueTime首次调度时间ms,period调度间隔ms,-1表示仅处理一次
|
||||
uint AddTask(Action func, void* param, int dueTime = 0, int period = 0, const char* name = nullptr) const;
|
||||
uint AddTask(Action func, void* param, int dueTime = 0, int period = 0, cstring name = nullptr) const;
|
||||
void RemoveTask(uint& taskid) const;
|
||||
// 设置任务的开关状态,同时运行指定任务最近一次调度的时间,0表示马上调度
|
||||
bool SetTask(uint taskid, bool enable, int msNextTime = -1) const;
|
||||
|
|
4
Task.cpp
4
Task.cpp
|
@ -138,7 +138,7 @@ Task* Task::Get(int taskid)
|
|||
|
||||
#pragma arm section code
|
||||
|
||||
TaskScheduler::TaskScheduler(const char* name)
|
||||
TaskScheduler::TaskScheduler(cstring name)
|
||||
{
|
||||
_Tasks.Clear();
|
||||
_Tasks.SetLength(0);
|
||||
|
@ -163,7 +163,7 @@ void TaskScheduler::Set(Task* tasks, uint count)
|
|||
}
|
||||
|
||||
// 创建任务,返回任务编号。dueTime首次调度时间ms,-1表示事件型任务,period调度间隔ms,-1表示仅处理一次
|
||||
uint TaskScheduler::Add(Action func, void* param, int dueTime, int period, const char* name)
|
||||
uint TaskScheduler::Add(Action func, void* param, int dueTime, int period, cstring name)
|
||||
{
|
||||
// 查找是否有可用空闲任务
|
||||
Task* task = nullptr;
|
||||
|
|
8
Task.h
8
Task.h
|
@ -15,7 +15,7 @@ public:
|
|||
TaskScheduler* Host;
|
||||
|
||||
uint ID; // 编号
|
||||
const char* Name; // 名称
|
||||
cstring Name; // 名称
|
||||
|
||||
Action Callback; // 回调
|
||||
void* Param; // 参数
|
||||
|
@ -61,7 +61,7 @@ private:
|
|||
friend class Task;
|
||||
|
||||
public:
|
||||
const char* Name; // 系统名称
|
||||
cstring Name; // 系统名称
|
||||
int Count; // 任务个数
|
||||
Task* Current; // 正在执行的任务
|
||||
bool Running; // 是否正在运行
|
||||
|
@ -70,14 +70,14 @@ public:
|
|||
int Cost; // 平均执行时间us
|
||||
int MaxCost; // 最大执行时间us
|
||||
|
||||
TaskScheduler(const char* name = nullptr);
|
||||
TaskScheduler(cstring name = nullptr);
|
||||
//~TaskScheduler();
|
||||
|
||||
// 使用外部缓冲区初始化任务列表,避免频繁的堆分配
|
||||
void Set(Task* tasks, uint count);
|
||||
|
||||
// 创建任务,返回任务编号。dueTime首次调度时间ms,-1表示事件型任务,period调度间隔ms,-1表示仅处理一次
|
||||
uint Add(Action func, void* param, int dueTime = 0, int period = 0, const char* name = nullptr);
|
||||
uint Add(Action func, void* param, int dueTime = 0, int period = 0, cstring name = nullptr);
|
||||
void Remove(uint taskid);
|
||||
|
||||
void Start();
|
||||
|
|
|
@ -18,7 +18,7 @@ static void TestCtor()
|
|||
|
||||
debug_printf("字符串构造函数测试\r\n");
|
||||
|
||||
auto err = "String(const char* cstr)";
|
||||
auto err = "String(cstring cstr)";
|
||||
|
||||
// 默认空字符串,使用内部数据区
|
||||
String str;
|
||||
|
@ -121,11 +121,11 @@ static void TestAssign()
|
|||
String str = "万家灯火,无声物联!";
|
||||
debug_printf("TestAssign: %s\r\n", str.GetBuffer());
|
||||
str = "无声物联";
|
||||
assert(str == "无声物联", "String& operator = (const char* cstr)");
|
||||
assert(str == "无声物联", "String& operator = (cstring cstr)");
|
||||
|
||||
String str2 = "xxx";
|
||||
str2 = str;
|
||||
assert(str == "无声物联", "String& operator = (const char* cstr)");
|
||||
assert(str == "无声物联", "String& operator = (cstring cstr)");
|
||||
assert(str2.GetBuffer() != str.GetBuffer(), "String& operator = (const String& rhs)");
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ static void TestAdd()
|
|||
str = str + 1234 + "#" + R("99xx") + '$' + -33.883 + "@" + DateTime::Now();
|
||||
str.Show(true);
|
||||
// 字符串连加 1234@0000-00-00 00:00:00#99xx
|
||||
assert(str.Contains("字符串连加 1234#99xx$-33.88@"), "friend StringHelper& operator + (const StringHelper& lhs, const char* cstr)");
|
||||
assert(str.Contains("字符串连加 1234#99xx$-33.88@"), "friend StringHelper& operator + (const StringHelper& lhs, cstring cstr)");
|
||||
}
|
||||
|
||||
static void TestEquals()
|
||||
|
@ -245,13 +245,13 @@ static void TestSet()
|
|||
assert(bs2[5] == 0x3F, "ByteArray ToHex()");
|
||||
|
||||
// 字符串搜索
|
||||
assert(str.IndexOf("36") == 0, "int IndexOf(const char* str, int startIndex = 0)");
|
||||
assert(str.IndexOf("36", 1) == 6, "int IndexOf(const char* str, int startIndex = 0)");
|
||||
assert(str.LastIndexOf("36", 6) == 6, "int LastIndexOf(const char* str, int startIndex = 0)");
|
||||
assert(str.LastIndexOf("36", 7) == -1, "int LastIndexOf(const char* str, int startIndex = 0)");
|
||||
assert(str.Contains("34-3F-31"), "bool Contains(const char* str) const");
|
||||
assert(str.StartsWith("36-"), "bool StartsWith(const char* str, int startIndex = 0)");
|
||||
assert(str.EndsWith("-32-34"), "bool EndsWith(const char* str)");
|
||||
assert(str.IndexOf("36") == 0, "int IndexOf(cstring str, int startIndex = 0)");
|
||||
assert(str.IndexOf("36", 1) == 6, "int IndexOf(cstring str, int startIndex = 0)");
|
||||
assert(str.LastIndexOf("36", 6) == 6, "int LastIndexOf(cstring str, int startIndex = 0)");
|
||||
assert(str.LastIndexOf("36", 7) == -1, "int LastIndexOf(cstring str, int startIndex = 0)");
|
||||
assert(str.Contains("34-3F-31"), "bool Contains(cstring str) const");
|
||||
assert(str.StartsWith("36-"), "bool StartsWith(cstring str, int startIndex = 0)");
|
||||
assert(str.EndsWith("-32-34"), "bool EndsWith(cstring str)");
|
||||
|
||||
// 字符串截取
|
||||
str = " 36-1f-36-35-34\n";
|
||||
|
|
2
Thread.h
2
Thread.h
|
@ -15,7 +15,7 @@ private:
|
|||
|
||||
public:
|
||||
uint ID; // 编号
|
||||
const char* Name; // 名称
|
||||
cstring Name; // 名称
|
||||
|
||||
uint* Stack; // 栈底
|
||||
uint* StackTop; // 栈顶
|
||||
|
|
2
Time.cpp
2
Time.cpp
|
@ -288,7 +288,7 @@ int TimeCost::Elapsed()
|
|||
return ms * 1000 + ts;
|
||||
}
|
||||
|
||||
void TimeCost::Show(const char* format)
|
||||
void TimeCost::Show(cstring format)
|
||||
{
|
||||
if(!format) format = "执行 %dus\r\n";
|
||||
debug_printf(format, Elapsed());
|
||||
|
|
2
Time.h
2
Time.h
|
@ -71,7 +71,7 @@ public:
|
|||
TimeCost();
|
||||
|
||||
int Elapsed(); // 逝去的时间,微秒
|
||||
void Show(const char* format = nullptr);
|
||||
void Show(cstring format = nullptr);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,7 +34,7 @@ TcpSocket::TcpSocket(TinyIP* tip) : Socket(tip)
|
|||
OnDisconnected = nullptr;
|
||||
}
|
||||
|
||||
const char* TcpSocket::ToString()
|
||||
cstring TcpSocket::ToString()
|
||||
{
|
||||
static char name[10];
|
||||
sprintf(name, "TCP_%d", Port);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
TcpHandler OnReceived;
|
||||
TcpHandler OnDisconnected;
|
||||
|
||||
virtual const char* ToString();
|
||||
virtual cstring ToString();
|
||||
|
||||
protected:
|
||||
void SendAck(uint len);
|
||||
|
|
|
@ -34,7 +34,7 @@ TcpSocket::TcpSocket(TinyIP* tip) : TinySocket(tip, IP_TCP)
|
|||
OnDisconnected = nullptr;
|
||||
}
|
||||
|
||||
/*const char* TcpSocket::ToString() const
|
||||
/*cstring TcpSocket::ToString() const
|
||||
{
|
||||
static char name[10];
|
||||
sprintf(name, "TCP_%d", Local.Port);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
TcpHandler OnReceived;
|
||||
TcpHandler OnDisconnected;
|
||||
|
||||
//virtual const char* ToString() const;
|
||||
//virtual cstring ToString() const;
|
||||
virtual String& ToStr(String& str) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -122,7 +122,7 @@ void TinyIP::Process(Stream& ms)
|
|||
debug_printf("=>");
|
||||
local.Show();
|
||||
|
||||
const char* name = "Unkown";
|
||||
cstring name = "Unkown";
|
||||
switch(ip->Protocol)
|
||||
{
|
||||
case IP_ICMP: { name = "ICMP"; break; }
|
||||
|
@ -247,7 +247,7 @@ bool TinyIP::SendEthernet(ETH_TYPE type, const MacAddress& remote, const byte* b
|
|||
len += sizeof(ETH_HEADER);
|
||||
//if(len < 60) len = 60; // 以太网最小包60字节
|
||||
|
||||
/*char* name = "Unkown";
|
||||
/*auto name = "Unkown";
|
||||
switch(type)
|
||||
{
|
||||
case ETH_ARP: { name = "ARP"; break; }
|
||||
|
@ -302,7 +302,7 @@ bool TinyIP::SendIP(IP_TYPE type, const IPAddress& remote, const byte* buf, uint
|
|||
return false;
|
||||
}
|
||||
|
||||
/*char* name = "Unkown";
|
||||
/*auto name = "Unkown";
|
||||
switch(type)
|
||||
{
|
||||
case IP_ICMP: { name = "ICMP"; break; }
|
||||
|
|
|
@ -16,7 +16,7 @@ UdpSocket::UdpSocket(TinyIP* tip) : TinySocket(tip, IP_UDP)
|
|||
Local.Address = tip->IP;
|
||||
}
|
||||
|
||||
/*const char* UdpSocket::ToString() const
|
||||
/*cstring UdpSocket::ToString() const
|
||||
{
|
||||
static char name[10];
|
||||
sprintf(name, "UDP_%d", Local.Port);
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
// 接收数据
|
||||
virtual uint Receive(Buffer& bs);
|
||||
|
||||
//virtual const char* ToString() const;
|
||||
//virtual cstring ToString() const;
|
||||
virtual String& ToStr(String& str) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -23,7 +23,7 @@ uint OnSerial(ITransport* transport, Buffer& bs, void* param, void* param2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Setup(ushort code, const char* name, COM message, int baudRate)
|
||||
void Setup(ushort code, cstring name, COM message, int baudRate)
|
||||
{
|
||||
auto& sys = (TSys&)Sys;
|
||||
sys.Code = code;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "App\Button_GrayLevel.h"
|
||||
|
||||
void Setup(ushort code, const char* name, COM message = COM1, int baudRate = 0);
|
||||
void Setup(ushort code, cstring name, COM message = COM1, int baudRate = 0);
|
||||
|
||||
void* InitConfig(void* data, uint size);
|
||||
void ClearConfig();
|
||||
|
|
|
@ -159,7 +159,7 @@ static uint OnSerial(ITransport* transport, Buffer& bs, void* param, void* param
|
|||
}
|
||||
#endif
|
||||
|
||||
void Token::Setup(ushort code, const char* name, COM message, int baudRate)
|
||||
void Token::Setup(ushort code, cstring name, COM message, int baudRate)
|
||||
{
|
||||
auto& sys = (TSys&)Sys;
|
||||
sys.Code = code;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
class Token
|
||||
{
|
||||
public:
|
||||
static void Setup(ushort code, const char* name, COM message = COM1, int baudRate = 0);
|
||||
static void Setup(ushort code, cstring name, COM message = COM1, int baudRate = 0);
|
||||
|
||||
static ISocketHost* CreateW5500(SPI spi, Pin irq, Pin rst = P0, Pin power = P0, IDataPort* led = nullptr);
|
||||
static ISocketHost* Create2860(SPI spi, Pin irq, Pin rst);
|
||||
|
|
|
@ -61,7 +61,7 @@ void TokenConfig::Show() const
|
|||
#endif
|
||||
}
|
||||
|
||||
TokenConfig* TokenConfig::Create(const char* vendor, ProtocolType protocol, ushort sport, ushort port)
|
||||
TokenConfig* TokenConfig::Create(cstring vendor, ProtocolType protocol, ushort sport, ushort port)
|
||||
{
|
||||
static TokenConfig tc;
|
||||
if(!Current)
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
String Vendor;
|
||||
|
||||
static TokenConfig* Current;
|
||||
static TokenConfig* Create(const char* vendor, ProtocolType protocol, ushort sport, ushort port);
|
||||
static TokenConfig* Create(cstring vendor, ProtocolType protocol, ushort sport, ushort port);
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
|
@ -271,7 +271,7 @@ bool TokenController::Send(Message& msg)
|
|||
return Controller::SendInternal(bs, msg.State);
|
||||
}
|
||||
|
||||
void TokenController::ShowMessage(const char* action, const Message& msg)
|
||||
void TokenController::ShowMessage(cstring action, const Message& msg)
|
||||
{
|
||||
#if MSG_DEBUG
|
||||
TS("TokenController::ShowMessage");
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
// 响应消息
|
||||
private:
|
||||
void ShowMessage(const char* action, const Message& msg);
|
||||
void ShowMessage(cstring action, const Message& msg);
|
||||
|
||||
// 统计
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue