📄 masterstring.h
字号:
}
inline bool FindStringLocationF(char* search,MasStrDataLoc* dloc)
{
return mstr_findstrlocf(str,search,dloc);
}
inline bool FindStringLocationB(char* search,MasStrDataLoc* dloc)
{
return mstr_findstrlocb(str,search,dloc);
}
inline void SearchRange(char* search,MasStrRange* mrang)
{
mstr_searchrange(str,search,mrang);
}
inline void SearchRangeEx(int startx,char* search,MasStrRange* mrang)
{
mstr_isearchrange(startx,str,search,mrang);
}
inline void CopyLeftRange(char* output, MasStrRange* mrang,int hi)
{
mstr_copyleftrange(str,output,mrang,hi);
}
inline void CopyRightRange(char* output, MasStrRange* mrang,int hi)
{
mstr_copyrightrange(str,output,mrang,hi);
}
inline void CopyMidRange(char* output,MasStrRange* mrang,int hi, MasStrRange* mrangx,int hix)
{
mstr_copymidrange(str,output,mrang,hi,mrangx,hix);
}
inline int GetHexValue()
{
return mstr_hextoint(str);
}
inline int GetDecValue()
{
return atoi(str);
}
inline int ConvertToInteger()
{
return atoi(str);
}
inline bool IsHex()
{
return mstr_ishex(str);
}
inline void qprint()
{
cout << str;
}
inline void qmsg()
{
MessageBox(0,str,"QMSG",MB_ICONINFORMATION);
}
inline void ClearString()
{
for(int z = 0; z < GetStringLength(); z++)
{
str[z] = 0;
}
}
inline void SetWindowText(HWND hwnd)
{
SendMessage(hwnd,WM_SETTEXT,strlen(str),(LPARAM)(LPCSTR)str);
}
inline void AddToList(HWND hwnd)
{
SendMessage(hwnd,LB_ADDSTRING,strlen(str),(LPARAM)(LPCSTR)str);
}
inline void AddToCombo(HWND hwnd)
{
SendMessage(hwnd,CB_ADDSTRING,strlen(str),(LPARAM)(LPCSTR)str);
}
inline void CopyTextFromHWND(HWND hwnd)
{
char* buffer;
int len;
len = SendMessage(hwnd,WM_GETTEXTLENGTH,0,0);
buffer = new char[len+1];
SendMessage(hwnd,WM_GETTEXT,len,(LPARAM)(LPCSTR)buffer);
set(len+1,buffer);
delete [] buffer;
}
inline void AttachTextFromHWND(HWND hwnd)
{
char* buffer;
int len;
len = SendMessage(hwnd,WM_GETTEXTLENGTH,0,0);
buffer = new char[len+1];
SendMessage(hwnd,WM_GETTEXT,len,(LPARAM)(LPCSTR)buffer);
add(buffer);
delete [] buffer;
}
inline void ReplaceCharacter(char findchr,char replace)
{
mstr_replacechar(str,findchr,replace);
}
inline void RandomizeString()
{
randomstr(str,255,strlen(str));
}
inline void ReplaceString(char* search, char* replacestr)
{
if(mstr_findstr(str,search) != -1)
{
char* output;
output = new char[strlen(str)+10];
mstr_replacestr(str,search,replacestr,output);
set(strlen(output)+10,output);
delete [] output;
output = 0;
}
}
inline void RemoveCharacters(char c)
{
char* output;
output = new char[strlen(str)+10];
mstr_removechar(str,output,c);
set(strlen(output)+10,output);
delete [] output;
output = 0;
}
inline void RemoveString(char* search)
{
if(mstr_findstr(str,search) != -1)
{
char* output;
output = new char[strlen(str)+10];
mstr_removestr(str,output,search);
set(strlen(output)+10,output);
delete [] output;
output = 0;
}
}
inline void RemoveSingleInstanceOfString(char* search)
{
if(mstr_findstr(str,search) != -1)
{
char* output;
output = new char[strlen(str)+10];
rmvstrx(str,output,search);
set(strlen(output)+10,search);
delete [] output;
output = 0;
}
}
inline void SaveToFile(char* filename)
{
mstr_savestr(filename,str);
}
inline void LoadStringFromFile(char* filename)
{
if(getfilestringlength(filename) == -1)
{
return; // failure file not found
}
char* temp;
temp = new char[getfilestringlength(filename)+20];
mstr_loadstr(filename,temp);
set(strlen(temp)+20,temp);
delete [] temp;
temp = 0;
}
inline bool IsStringValid()
{
return mstr_isstrvalid(str);
}
inline int ReverseString() // reverse the string
{
char* temp;
temp = new char[GetStringLength()+10];
reversestring(str,temp);
set(strlen(temp)+10,temp);
delete [] temp;
temp = 0;
}
inline bool StringCompare(char* buff)
{
return mstr_mstrcmp(str,buff);
}
inline bool StringCompare_NOCASE(char* buff)
{
return mstr_mstrcmpl(str,buff);
}
inline bool IsInsideString(char* buff)
{
return mstr_insidestr(str,buff);
}
inline bool IsInsideString_NOCASE(char* buff)
{
return mstr_insidestrl(str,buff);
}
inline void SeperateString(char* lbuff,int lpos,char* rbuff,int rpos)
{
mstr_strsep(str,lbuff,lpos,rbuff,rpos);
}
inline void AsmTrim()
{
// trim string as tho it were assembly language source
char* output;
output = new char[GetStringLength()+10];
asmtrim(str,output);
set(strlen(output)+10,output);
delete [] output;
output = 0;
}
inline void TrimComments(char start_c,char stop_c)
{
char* output;
output = new char[GetStringLength()+10];
trimcom(str,output,start_c,stop_c);
set(strlen(output)+10,output);
delete [] output;
output = 0;
}
};
// MasterString Item Structure
struct ListItem
{
int list_index;
inline void setindex(int i)
{
list_index = i;
}
inline int getindex()
{
return list_index;
}
};
struct MasterStringItem : MasterString,ListItem
{
bool on;
inline MasterStringListItem()
{
on = false;
}
inline void seton(bool x)
{
on = x;
}
inline bool geton()
{
return on;
}
};
// example of a list using MasterStrings
struct MasterStringList
{
MasterStringItem* item;
bool ion;
int array_size;
int off;
inline MasterStringList()
{
ion = false;
off = 0;
}
inline ~MasterStringList()
{
if(ion == true)
{
delete [] item;
item = NULL;
}
}
inline MasterStringList(int size)
{
createList(size);
}
inline void createList(int size)
{
item = new MasterStringItem[size];
ion = true;
array_size = size;
}
inline int GetArraySize()
{
return array_size;
}
inline char* GetListStringPointerByIndex(int index)
{
return item[index].get();
}
inline int AddString(char* buffer)
{
item[off].set(strlen(buffer)+10,buffer);
int xoff = off;
off++;
return xoff;
}
inline int GetListLength()
{
return off;
}
inline void GetString(int index,char* output)
{
strcpy(output,item[index].get());
}
inline void Clear()
{
for(int i = 0; i < off; i++)
{
item[i].ClearString();
}
off = 0;
}
};
struct MasterEntry : ListItem
{
MasterString name;
MasterString value;
bool on_switch;
inline MasterEntry()
{
name = "";
value = "";
on_switch = false;
}
inline bool amion()
{
return on_switch;
}
};
// easy to use INI object, using MasterStrings
struct MasterINI
{
MasterEntry* masEntry;
bool mas_on;
int array_size;
int off_count;
// constructors/deconstructors
inline MasterINI()
{
masEntry = 0;
mas_on = false;
off_count = 0;
}
inline MasterINI(int size)
{
set(size);
}
inline ~MasterINI()
{
if(mas_on)
{
delete [] masEntry;
masEntry = 0;
}
}
inline set(int size)
{
if(mas_on == true)
{
delete [] masEntry;
masEntry = 0;
}
masEntry = new MasterEntry[size];
mas_on = true;
array_size = size;
off_count = 0;
}
inline int getsize()
{
return array_size;
}
inline void Create(int size)
{
set(size);
}
inline bool AddEntry(char* name,char* value)
{
if(off_count < getsize())
{
masEntry[off_count].name = name;
masEntry[off_count].value = value;
masEntry[off_count].list_index = off_count;
off_count++;
return true;
}
return false;
}
inline bool GetEntry(char* name,char* output_value)
{
for(int i = 0; i < getsize(); i++)
{
if(findstr(masEntry[i].name.get(),name) != -1)
{
stringcopy(output_value,masEntry[i].value.get());
return true;
}
}
strcpy(output_value,"*NULL*");
return false;
}
};
bool SaveMasterINI(char* filename,MasterINI* mini); // Save INI
bool LoadMasterINI(char* filename,MasterINI* mini); // Load INI
struct MasCharList // char list based on the \n (breaks strings into lines) (for use with MasAsm)
{
MasterString* list;
bool list_on;
int array_size;
int list_len;
inline MasCharList()
{
list = 0;
list_on = false;
}
inline MasCharList(char* buff)
{
BuildList(buff);
}
inline ~MasCharList()
{
if(list_on == true)
{
delete [] list;
list = 0;
}
}
inline void BuildList(char* buff)
{
int size;
size = countlines(buff) + 1;
list = new MasterString[size];
list_on = true;
array_size = size;
// format the characters into this array
int pre_pos = 0;
int acount = 0;
while(1)
{
int find_x;
find_x = ifindstr(pre_pos,buff,"\n");
if(find_x == -1)
{
break;// all done !
}
char* temp;
temp = new char[strlen(buff)+1];
midcopy(buff,temp,pre_pos,find_x);
pre_pos = find_x;
// add
list[acount] = temp;
acount++;
delete [] temp;
temp = 0;
}
list_len = acount;
}
inline int GetLength()
{
return list_len;
}
inline MasterString* GetMasterString(int index)
{
return (MasterString*)&list[index];
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -