Merge branch 'master' of https://github.com/hyzboy/CMCore
This commit is contained in:
commit
0f9fb581cb
@ -1,4 +1,4 @@
|
|||||||
#ifndef HGL_EVENT_PROC_INCLUDE
|
#ifndef HGL_EVENT_PROC_INCLUDE
|
||||||
#define HGL_EVENT_PROC_INCLUDE
|
#define HGL_EVENT_PROC_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/Queue.h>
|
#include<hgl/type/Queue.h>
|
||||||
@ -6,7 +6,7 @@
|
|||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 事件基类
|
* 事件基类
|
||||||
*/
|
*/
|
||||||
class EventProc
|
class EventProc
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ namespace hgl
|
|||||||
using EventProcQueue=Queue<EventProc *>;
|
using EventProcQueue=Queue<EventProc *>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行一个事件
|
* 执行一个事件
|
||||||
*/
|
*/
|
||||||
inline bool UpdateEvent(EventProcQueue *epq)
|
inline bool UpdateEvent(EventProcQueue *epq)
|
||||||
{
|
{
|
||||||
@ -42,9 +42,9 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新执行事件队列
|
* 刷新执行事件队列
|
||||||
* @param epq 事件队列
|
* @param epq 事件队列
|
||||||
* @param max_count 最大刷新个数(-1表示无限制)
|
* @param max_count 最大刷新个数(-1表示无限制)
|
||||||
*/
|
*/
|
||||||
inline int UpdateEventQueue(EventProcQueue *epq,int max_count=-1)
|
inline int UpdateEventQueue(EventProcQueue *epq,int max_count=-1)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef HGL_IO_INPUT_EVENT_INCLUDE
|
#ifndef HGL_IO_INPUT_EVENT_INCLUDE
|
||||||
#define HGL_IO_INPUT_EVENT_INCLUDE
|
#define HGL_IO_INPUT_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSets.h>
|
||||||
@ -9,15 +9,15 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
struct EventHeader
|
struct EventHeader
|
||||||
{
|
{
|
||||||
uint8 type; ///<输入源类型
|
uint8 type; ///<输入源类型
|
||||||
uint8 index; ///<输入源索引(比如同一设备有多个)
|
uint8 index; ///<输入源索引(比如同一设备有多个)
|
||||||
uint16 id; ///<事件id
|
uint16 id; ///<事件id
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr size_t EventHeaderBytes=sizeof(EventHeader);
|
constexpr size_t EventHeaderBytes=sizeof(EventHeader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件处理结果
|
* 事件处理结果
|
||||||
*/
|
*/
|
||||||
enum class EventProcResult
|
enum class EventProcResult
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
|
#ifndef HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
|
||||||
#define HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
|
#define HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/TypeFunc.h>
|
#include<hgl/TypeFunc.h>
|
||||||
@ -7,7 +7,7 @@ namespace hgl
|
|||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 手柄按键枚举
|
* 手柄按键枚举
|
||||||
*/
|
*/
|
||||||
enum class JoystickButton
|
enum class JoystickButton
|
||||||
{
|
{
|
||||||
@ -33,10 +33,10 @@ namespace hgl
|
|||||||
Left =JoystickButton::Left,
|
Left =JoystickButton::Left,
|
||||||
Right =JoystickButton::Right,
|
Right =JoystickButton::Right,
|
||||||
|
|
||||||
Fork =JoystickButton::_0, // 叉
|
Fork =JoystickButton::_0, // 叉
|
||||||
Circle =JoystickButton::_1, // 圆
|
Circle =JoystickButton::_1, // 圆
|
||||||
Square =JoystickButton::_2, // 方
|
Square =JoystickButton::_2, // 方
|
||||||
Triangle =JoystickButton::_3, // 三角
|
Triangle =JoystickButton::_3, // 三角
|
||||||
|
|
||||||
L1 =JoystickButton::_6, L2 =JoystickButton::_4,
|
L1 =JoystickButton::_6, L2 =JoystickButton::_4,
|
||||||
R1 =JoystickButton::_7, R2 =JoystickButton::_5,
|
R1 =JoystickButton::_7, R2 =JoystickButton::_5,
|
||||||
@ -54,7 +54,7 @@ namespace hgl
|
|||||||
// R=JoystickButton::_5,
|
// R=JoystickButton::_5,
|
||||||
|
|
||||||
// //XBOX/XBOX360
|
// //XBOX/XBOX360
|
||||||
// //XBOX, //西瓜键
|
// //XBOX, //西瓜键
|
||||||
//};
|
//};
|
||||||
}//namespace io
|
}//namespace io
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef HGL_IO_KEYBOARD_EVENT_INCLUDE
|
#ifndef HGL_IO_KEYBOARD_EVENT_INCLUDE
|
||||||
#define HGL_IO_KEYBOARD_EVENT_INCLUDE
|
#define HGL_IO_KEYBOARD_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/io/event/InputEvent.h>
|
#include<hgl/io/event/InputEvent.h>
|
||||||
@ -7,15 +7,15 @@ namespace hgl
|
|||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 按键枚举定义
|
* 按键枚举定义
|
||||||
*/
|
*/
|
||||||
enum class KeyboardButton
|
enum class KeyboardButton
|
||||||
{
|
{
|
||||||
NONE=0,
|
NONE=0,
|
||||||
//主键盘区
|
//主键盘区
|
||||||
Esc, ///<ESC
|
Esc, ///<ESC
|
||||||
|
|
||||||
//F功能键
|
//F功能键
|
||||||
F1, ///<F1
|
F1, ///<F1
|
||||||
F2, ///<F2
|
F2, ///<F2
|
||||||
F3, ///<F3
|
F3, ///<F3
|
||||||
@ -29,26 +29,26 @@ namespace hgl
|
|||||||
F11, ///<F11
|
F11, ///<F11
|
||||||
F12, ///<F12
|
F12, ///<F12
|
||||||
|
|
||||||
Grave, //<`号(主键盘数字键1左边的按钮)
|
Grave, //<`号(主键盘数字键1左边的按钮)
|
||||||
|
|
||||||
//10个数字
|
//10个数字
|
||||||
_0, ///<数字键0
|
_0, ///<数字键0
|
||||||
_1, ///<数字键1
|
_1, ///<数字键1
|
||||||
_2, ///<数字键2
|
_2, ///<数字键2
|
||||||
_3, ///<数字键3
|
_3, ///<数字键3
|
||||||
_4, ///<数字键4
|
_4, ///<数字键4
|
||||||
_5, ///<数字键5
|
_5, ///<数字键5
|
||||||
_6, ///<数字键6
|
_6, ///<数字键6
|
||||||
_7, ///<数字键7
|
_7, ///<数字键7
|
||||||
_8, ///<数字键8
|
_8, ///<数字键8
|
||||||
_9, ///<数字键9
|
_9, ///<数字键9
|
||||||
|
|
||||||
Minus, ///< - (减号)
|
Minus, ///< - (减号)
|
||||||
Equals, ///< = (等号)
|
Equals, ///< = (等号)
|
||||||
BackSlash, ///< \ (反斜杠)
|
BackSlash, ///< \ (反斜杠)
|
||||||
BackSpace, ///< 退格键
|
BackSpace, ///< 退格键
|
||||||
|
|
||||||
Tab, ///<Tab键
|
Tab, ///<Tab键
|
||||||
|
|
||||||
A, ///<A
|
A, ///<A
|
||||||
B, ///<B
|
B, ///<B
|
||||||
@ -80,66 +80,66 @@ namespace hgl
|
|||||||
LeftBracket, ///<[
|
LeftBracket, ///<[
|
||||||
RightBracket, ///<]
|
RightBracket, ///<]
|
||||||
|
|
||||||
CapsLock, ///<大写锁定键
|
CapsLock, ///<大写锁定键
|
||||||
|
|
||||||
Semicolon, ///<; (分号)
|
Semicolon, ///<; (分号)
|
||||||
Apostrophe, ///<' (单引号)
|
Apostrophe, ///<' (单引号)
|
||||||
Enter, ///<回车键
|
Enter, ///<回车键
|
||||||
|
|
||||||
LeftShift, ///<左边的Shift键
|
LeftShift, ///<左边的Shift键
|
||||||
|
|
||||||
Comma, ///<, (逗号)
|
Comma, ///<, (逗号)
|
||||||
Period, ///<. (句号)
|
Period, ///<. (句号)
|
||||||
Slash, ///</ (除号)
|
Slash, ///</ (除号)
|
||||||
RightShift, ///<右边的Shift键
|
RightShift, ///<右边的Shift键
|
||||||
|
|
||||||
LeftCtrl, ///<左边的Ctrl键
|
LeftCtrl, ///<左边的Ctrl键
|
||||||
LeftOS, ///<左边的OS键(Win/Apple键)
|
LeftOS, ///<左边的OS键(Win/Apple键)
|
||||||
LeftAlt, ///<左边的Alt键
|
LeftAlt, ///<左边的Alt键
|
||||||
Space, ///<空格键
|
Space, ///<空格键
|
||||||
RightAlt, ///<右边的Alt键
|
RightAlt, ///<右边的Alt键
|
||||||
RightOS, ///<右边的OS键(Win/Apple键)
|
RightOS, ///<右边的OS键(Win/Apple键)
|
||||||
RightMenu, ///<右边的Menu键
|
RightMenu, ///<右边的Menu键
|
||||||
RightCtrl, ///<右边的Ctrl键
|
RightCtrl, ///<右边的Ctrl键
|
||||||
|
|
||||||
//中键盘区
|
//中键盘区
|
||||||
PrintScreen, ///<打印屏幕键
|
PrintScreen, ///<打印屏幕键
|
||||||
ScrollLock, ///<滚动锁定键
|
ScrollLock, ///<滚动锁定键
|
||||||
Pause, ///<暂停键
|
Pause, ///<暂停键
|
||||||
|
|
||||||
Insert, ///<插入键
|
Insert, ///<插入键
|
||||||
Delete, ///<删除键
|
Delete, ///<删除键
|
||||||
Home, ///<行首键
|
Home, ///<行首键
|
||||||
End, ///<行尾键
|
End, ///<行尾键
|
||||||
PageUp, ///<向前翻页键
|
PageUp, ///<向前翻页键
|
||||||
PageDown, ///<向后翻页键
|
PageDown, ///<向后翻页键
|
||||||
|
|
||||||
Up, ///<↑光标键
|
Up, ///<↑光标键
|
||||||
Down, ///<↓光标键
|
Down, ///<↓光标键
|
||||||
Left, ///<←光标键
|
Left, ///<←光标键
|
||||||
Right, ///<→光标键
|
Right, ///<→光标键
|
||||||
|
|
||||||
//小键盘区
|
//小键盘区
|
||||||
NumLock, ///<小键盘 数字锁定键
|
NumLock, ///<小键盘 数字锁定键
|
||||||
|
|
||||||
NumAdd, ///<小键盘 +
|
NumAdd, ///<小键盘 +
|
||||||
NumSubtract, ///<小键盘 -
|
NumSubtract, ///<小键盘 -
|
||||||
NumMultiply, ///<小键盘 *
|
NumMultiply, ///<小键盘 *
|
||||||
NumDivide, ///<小键盘 /
|
NumDivide, ///<小键盘 /
|
||||||
|
|
||||||
Num0, ///<小键盘 0
|
Num0, ///<小键盘 0
|
||||||
Num1, ///<小键盘 1
|
Num1, ///<小键盘 1
|
||||||
Num2, ///<小键盘 2
|
Num2, ///<小键盘 2
|
||||||
Num3, ///<小键盘 3
|
Num3, ///<小键盘 3
|
||||||
Num4, ///<小键盘 4
|
Num4, ///<小键盘 4
|
||||||
Num5, ///<小键盘 5
|
Num5, ///<小键盘 5
|
||||||
Num6, ///<小键盘 6
|
Num6, ///<小键盘 6
|
||||||
Num7, ///<小键盘 7
|
Num7, ///<小键盘 7
|
||||||
Num8, ///<小键盘 8
|
Num8, ///<小键盘 8
|
||||||
Num9, ///<小键盘 9
|
Num9, ///<小键盘 9
|
||||||
|
|
||||||
NumDecimal, ///<小键盘 . (小数点/删除键)
|
NumDecimal, ///<小键盘 . (小数点/删除键)
|
||||||
NumEnter, ///<小键盘 回车键
|
NumEnter, ///<小键盘 回车键
|
||||||
|
|
||||||
ENUM_CLASS_RANGE(NONE,NumEnter)
|
ENUM_CLASS_RANGE(NONE,NumEnter)
|
||||||
};//enum KeyboardButton
|
};//enum KeyboardButton
|
||||||
@ -227,7 +227,7 @@ namespace hgl
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 某按键是否按下状态
|
* 某按键是否按下状态
|
||||||
*/
|
*/
|
||||||
const bool HasPressed(const KeyboardButton &kb)const
|
const bool HasPressed(const KeyboardButton &kb)const
|
||||||
{
|
{
|
||||||
@ -237,7 +237,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设定当前时间
|
* 设定当前时间
|
||||||
*/
|
*/
|
||||||
void SetCurTime(const double &ct)
|
void SetCurTime(const double &ct)
|
||||||
{
|
{
|
||||||
@ -245,7 +245,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取按键按下的时间
|
* 获取按键按下的时间
|
||||||
*/
|
*/
|
||||||
const double GetPressedTime(const KeyboardButton &kb)const
|
const double GetPressedTime(const KeyboardButton &kb)const
|
||||||
{
|
{
|
||||||
|
144
inc/hgl/type/Gradient.h
Normal file
144
inc/hgl/type/Gradient.h
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/type/DataType.h>
|
||||||
|
#include<hgl/type/List.h>
|
||||||
|
#include<hgl/util/sort/Sort.h>
|
||||||
|
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
template<typename P,typename T> struct GradientStop
|
||||||
|
{
|
||||||
|
P pos;
|
||||||
|
T data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ½¥±äÀà
|
||||||
|
*/
|
||||||
|
template<typename P,typename T> class Gradient
|
||||||
|
{
|
||||||
|
using GS=GradientStop<P,T>;
|
||||||
|
|
||||||
|
List<GS> stop_list;
|
||||||
|
|
||||||
|
bool dirty;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void Sort()
|
||||||
|
{
|
||||||
|
if(!dirty||stop_list.GetCount()<2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Comparator<GS> comp;
|
||||||
|
|
||||||
|
hgl::Sort(stop_list,&comp);
|
||||||
|
|
||||||
|
dirty=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Gradient()
|
||||||
|
{
|
||||||
|
dirty=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Add(const P &pos,const T &data)
|
||||||
|
{
|
||||||
|
GS gs;
|
||||||
|
|
||||||
|
gs.pos=pos;
|
||||||
|
gs.data=data;
|
||||||
|
|
||||||
|
stop_list.Add(gs);
|
||||||
|
dirty=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
stop_list.Clear();
|
||||||
|
dirty=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool GetLowest(P &pos)const
|
||||||
|
{
|
||||||
|
GS gs;
|
||||||
|
|
||||||
|
if(stop_list.First(gs))
|
||||||
|
{
|
||||||
|
pos=gs.pos;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool GetHighest(P &pos)const
|
||||||
|
{
|
||||||
|
GS gs;
|
||||||
|
|
||||||
|
if(stop_list.Last(gs))
|
||||||
|
{
|
||||||
|
pos=gs.pos;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Get(T &reuslt,const T &start,const T &end,const float &pos)
|
||||||
|
{
|
||||||
|
result=start+(end-start)*pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void Get(T &result,const P &pos)
|
||||||
|
{
|
||||||
|
const uint count=stop_list.GetCount();
|
||||||
|
|
||||||
|
if(count<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Sort();
|
||||||
|
|
||||||
|
GS *cp=stop_list.GetData();
|
||||||
|
GS *pp;
|
||||||
|
|
||||||
|
if(count<2||pos<=cp->pos)
|
||||||
|
{
|
||||||
|
result=cp->data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pos>=cp[count-1].pos)
|
||||||
|
{
|
||||||
|
result=cp[count-1].data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp=cp;
|
||||||
|
++cp;
|
||||||
|
for(uint i=1;i<count;i++)
|
||||||
|
{
|
||||||
|
if(pos<=cp->pos)
|
||||||
|
{
|
||||||
|
Get(result,pp->data,cp->data,float(pos-pp->pos)/float(cp->pos-pp->pos));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
++pp;
|
||||||
|
++cp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};//class Gradient
|
||||||
|
|
||||||
|
#define HGL_GRADIENT_DEFINE(name,P,T) using name=Gradient<P,T>; \
|
||||||
|
using name##Stop=GradientStop<P,T>; \
|
||||||
|
\
|
||||||
|
int Comparator<name##Stop>::compare(const name##Stop &a,const name##Stop &b)const \
|
||||||
|
{ \
|
||||||
|
return a.pos-b.pos; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
template<> void name::Get(T &result,const T &start,const T &end,const float &pos)
|
||||||
|
}//namespace hgl
|
@ -24,7 +24,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool List<T>::Begin(T &ti)const
|
bool List<T>::First(T &ti)const
|
||||||
{
|
{
|
||||||
if(!items||count<=0)
|
if(!items||count<=0)
|
||||||
return(false);
|
return(false);
|
||||||
@ -34,7 +34,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool List<T>::End(T &ti)const
|
bool List<T>::Last(T &ti)const
|
||||||
{
|
{
|
||||||
if(!items||count<=0)
|
if(!items||count<=0)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -83,8 +83,8 @@ namespace hgl
|
|||||||
void Set(int,const T &); ///<设置指定索引处的数据
|
void Set(int,const T &); ///<设置指定索引处的数据
|
||||||
bool Rand(T &)const; ///<随机取得一个数据
|
bool Rand(T &)const; ///<随机取得一个数据
|
||||||
|
|
||||||
virtual bool Begin(T &)const; ///<取第一个数据
|
virtual bool First(T &)const; ///<取第一个数据
|
||||||
virtual bool End(T &)const; ///<取最后一个数据
|
virtual bool Last(T &)const; ///<取最后一个数据
|
||||||
|
|
||||||
virtual void Enum(void (*enum_func)(int,T &)) ///<枚举所有数据成员
|
virtual void Enum(void (*enum_func)(int,T &)) ///<枚举所有数据成员
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ namespace hgl
|
|||||||
|
|
||||||
virtual int Release(const K &,bool zero_clear=false); ///<释放一个数据
|
virtual int Release(const K &,bool zero_clear=false); ///<释放一个数据
|
||||||
virtual int Release(V *,bool zero_clear=false); ///<释放一个数据
|
virtual int Release(V *,bool zero_clear=false); ///<释放一个数据
|
||||||
};//template<typename F,typename T> class ResManage
|
};//template<typename K,typename V> class ResManage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用int类做数标致的资源管理器
|
* 使用int类做数标致的资源管理器
|
||||||
@ -82,7 +82,10 @@ namespace hgl
|
|||||||
|
|
||||||
return id_count++;
|
return id_count++;
|
||||||
}
|
}
|
||||||
};//template<typename F,typename T> class IDResManage:public ResManage<F,T>
|
};//template<typename K,typename V> class IDResManage:public ResManage<K,V>
|
||||||
|
|
||||||
|
template<typename V> using ID32ResManage=IDResManage<uint32,V>;
|
||||||
|
template<typename V> using ID64ResManage=IDResManage<uint64,V>;
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#include<hgl/type/ResManage.cpp>
|
#include<hgl/type/ResManage.cpp>
|
||||||
#endif//HGL_RES_MANAGE_INCLUDE
|
#endif//HGL_RES_MANAGE_INCLUDE
|
||||||
|
@ -130,11 +130,29 @@ namespace hgl
|
|||||||
BASE_STRING_NUMBER_CONSTRUCT(int64, itos);
|
BASE_STRING_NUMBER_CONSTRUCT(int64, itos);
|
||||||
BASE_STRING_NUMBER_CONSTRUCT(uint64,utos);
|
BASE_STRING_NUMBER_CONSTRUCT(uint64,utos);
|
||||||
|
|
||||||
BASE_STRING_NUMBER_CONSTRUCT(float, ftos);
|
|
||||||
BASE_STRING_NUMBER_CONSTRUCT(double,ftos);
|
|
||||||
|
|
||||||
#undef BASE_STRING_NUMBER_CONSTRUCT
|
#undef BASE_STRING_NUMBER_CONSTRUCT
|
||||||
|
|
||||||
|
#define BASE_STRING_FLOAT_CONSTRUCT(type,func) \
|
||||||
|
String(const type num)=delete; \
|
||||||
|
static String<T> floatOf(const type value,const uint frac_num) \
|
||||||
|
{ \
|
||||||
|
StringInstance<T> *si=new StringInstance<T>(); \
|
||||||
|
\
|
||||||
|
const int len=8*sizeof(type); \
|
||||||
|
\
|
||||||
|
T *tmp_str=new T[len]; \
|
||||||
|
\
|
||||||
|
func(tmp_str,len,frac_num,value); \
|
||||||
|
si->InitFromInstance(tmp_str,hgl::strlen(tmp_str)); \
|
||||||
|
\
|
||||||
|
return String<T>(si); \
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_STRING_FLOAT_CONSTRUCT(float, ftos);
|
||||||
|
BASE_STRING_FLOAT_CONSTRUCT(double,ftos);
|
||||||
|
|
||||||
|
#undef BASE_STRING_FLOAT_CONSTRUCT
|
||||||
|
|
||||||
String(const int *value,int N)=delete;
|
String(const int *value,int N)=delete;
|
||||||
|
|
||||||
static String<T> numberOf(const int *value,int N)
|
static String<T> numberOf(const int *value,int N)
|
||||||
@ -246,7 +264,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据一个C指针风格字符串设置当前字符串内容
|
* 根据一个C指针风格字符串设置当前字符串内容(当前字符串指针的数据会被复制创建)
|
||||||
* @param str 字符串内容,在len<0的情况下,需以0为结尾
|
* @param str 字符串内容,在len<0的情况下,需以0为结尾
|
||||||
* @param len 字符串长度,如果str以0为结尾,可以为负值,将启用自动计算长度
|
* @param len 字符串长度,如果str以0为结尾,可以为负值,将启用自动计算长度
|
||||||
*/
|
*/
|
||||||
@ -263,7 +281,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据一个C指针风格字符串设置当前字符串内容
|
* 根据一个C指针风格字符串设置当前字符串内容(基于一块已经分配好的内存,初始化后当前指针的内存会被使用)
|
||||||
* @param str 字符串内容,在len<0的情况下,需以0为结尾
|
* @param str 字符串内容,在len<0的情况下,需以0为结尾
|
||||||
* @param len 字符串长度
|
* @param len 字符串长度
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user