📄 tree_utils.h
字号:
Read the export settings, for a specified format, into a tree node.
Parameters:
trSettings = tree node to receive the settings
lpcszFormat = pointer to the image format whose settings are to be read
Return:
true for success, false for error
*/
bool tree_read_image_export_settings(TreeNode &trSettings, LPCSTR lpcszFormat);
/** >Import Export
Write the export settings, for a specified format, into a tree node.
Parameters:
trSettings = tree node containing the settings
lpcszFormat = pointer to the image format whose settings are to be written
Return:
true for success, false for error
*/
bool tree_write_image_export_settings(TreeNode &trSettings, LPCSTR lpcszFormat, bool bClearSections=false);
/** >Import Export
Get the image export settings from a page.
Parameters:
trSettings = tree node to receive the settings
pg = page to get the settings from
lpcszFormat = pointer to the image format
Return:
true for success, false for error
*/
bool tree_get_page_image_export_settings(TreeNode &trSettings, Page &pg, LPCSTR lpcszFormat);
/** >Import Export
Set the image export settings into a page.
Parameters:
trSettings = tree node containing the settings
pg = page to set the settings into
lpcszFormat = pointer to the image format
Return:
true for success, false for error
*/
bool tree_set_page_image_export_settings(TreeNode &trSettings, Page &pg, LPCSTR lpcszFormat, bool bClearSection=false);
/**#
It dumps into the appropriate output (output log and/or note window) according to the
settings in the tree the trRep.Contents.Header.Table branch.
Returns:
true if OK, otherwise false.
*/
bool tree_header_table_report(TreeNode &trRep);
/**#
It retrieves the information from trRep.Settings about where the report should go
(output log and/or a Note window) and how, and creates, if needed, the Note window
for output.
Paramaters:
trRep=the Reporting branch.
dwTarget=(output) it receives the information about where the report should go as a
combination of bits:
enum {
TYPETARGET_NAMED_WINDOW = 0x00000002UL, // to the particular Notes window
TYPETARGET_OUTPUTLOG = 0x00000004UL, // to output log
};
strNoteWnd=the name of the note window
pbAppendToNote=the address of a BOOL to optionally return the information whether the report should
be appended to the note window or the current contents of the note window should be replaced.
*/
bool tree_reporting_prepare_targets(TreeNode &trRep, DWORD &dwTarget, string &strNoteWnd, BOOL *pbAppendToNote = NULL);
enum {SETTINGS_MAIN, SETTINGS_GUI};
/**# >Operation
*/
void save_default_settings(TreeNode& tr, LPCSTR lpcszClassName, int nCategory = SETTINGS_MAIN);
/**# >Operation
*/
BOOL load_default_settings(Tree& tr, LPCSTR lpcszClassName, int nCategory = SETTINGS_MAIN);
/** >System
Save the given array of boolean values into a single DWORD in the registry.
Parameters:
lpcszDlgName = name of the dialog, this is used as the section name in the registry under /Dialogs/lpcszDlgName
vbValues = array of 1 and 0 that each will be assigned to a bit in the DWORD value saved into registry
lpcszValName = Value name in registry to save, if not specified, CheckBoxes will be used
Return:
True for success, false for error.
*/
bool save_default_checkboxes(LPCSTR lpcszDlgName, const vector<byte>& vbValues, LPCSTR lpcszKey = NULL);
/** >System
Setrive a array of boolean values saved by save_default_checkboxes in the registry.
Parameters:
lpcszDlgName = name of the dialog, this is used as the section name in the registry under /Dialogs/lpcszDlgName
vbValues = array of 1 and 0 that each will represent each bit in the DWORD value saved into registry
lpcszValName = Value name in registry to save, if not specified, CheckBoxes will be used
Return:
True for success, false if lpcszDlgName section does not have the item in registry.
*/
bool load_default_checkboxes(LPCSTR lpcszDlgName, vector<byte>& vbValues, LPCSTR lpcszValName = NULL);
/**#
*/
bool dlg_save_to_registry(LPCSTR lpcszSecName, LPCSTR lpcszValName, DWORD dwVal);
/**#
*/
bool dlg_load_registry(LPCSTR lpcszSecName, LPCSTR lpcszValName, DWORD& dwVal);
//---- CPY 10/21/03 QA70-4680 v7.5727 TREE_BRANCHESOPEN_CLOSE_REMEMBERED
// following class written by Xuan Sun
/** >Utility
This Class can be used to compress byte vectors (1 and 0s) to hex strings, and to decompress
hex strings back to byte vectors.
Note: Since it converts every 4 bits to a hex char, so if there is less than 4 bits,
0's will be filled in. For example {1,0,1,0,1,1} will be converted to "AC", because
1010=10=A, and 1100=12=C, notice that two 0's are filled at the end in "1100". "AC"
will be decompressed to {1,0,1,0,1,1,0,0}
*/
class BitsHex
{
public:
/**
convert a vector of 1's and 0's to a hex string
*/
bool BitsToHexStr(const vector<byte>& vn, string& strHex)
{
byte bb=0;
byte bTemp=0;
int jj=0;
strHex.Empty();
for(int ii=0;ii<vn.GetSize();ii++)
{
bTemp=vn[ii];
bTemp<<=(7-jj);
bb=bb|bTemp;
jj+=1;
//Convert every 4 bytes to one hex char
if(jj>=4 || ii==(vn.GetSize()-1))
{
strHex += byteToHex(bb);
jj=0;
bb=0;
}
}
return true;
}
/**
convert a hex string to a vector of 1's and 0's
*/
bool HexStrToBits(const string& strHex, vector<byte>& vn)
{
int nHex;
char cHex;
byte bTest;
vn.SetSize(0);
for(int ii=0; ii<strHex.GetLength(); ii++)
{
cHex = strHex[ii];
// convert the hex to int first
nHex = hexToInt(cHex);
if (nHex<0)
return false;
bTest=1;
bTest<<=3;
for(int jj=0; jj<4; jj++)
{
//put 1's and 0's in the vector
vn.Add((nHex&bTest)?1:0);
bTest>>=1;
//printf("%d",vn[vn.GetSize()-1]);
}
}
//printf("\n");
return true;
}
/**
a little utility function
*/
void vector_out(const vector<byte>& vn)
{
for(int ii = 0; ii < vn.GetSize(); ii++)
printf("%d", vn[ii]);
printf("\n");
}
private:
/**
convert a hex to an int(0 to 15), if error return -1
*/
int hexToInt(char cHex)
{
int nInt;
if(cHex>='0' && cHex<='9')
nInt = cHex - '0';
else if(cHex>='a' && cHex<='z')
nInt = cHex - 'a' + 10;
else if(cHex>='A' && cHex<='Z')
nInt = cHex - 'A' + 10;
else
return -1;
return nInt;
}
/**
use the high four bits to convert to a hex char
*/
char byteToHex(byte bb)
{
char cHex;
byte bTest = 1;
bTest<<=4;
int nConvert=0;
for(int ii=0; ii<4; ii++)
{
if(bTest&bb)
{
// convert byte to int first
nConvert += 1<<ii;
}
bTest<<=1;
}
if(nConvert<=9)
{
cHex = '0'+ nConvert;
}
else
{
cHex = 'A'+ (nConvert-10);
}
return cHex;
}
};
//---- end TREE_BRANCHESOPEN_CLOSE_REMEMBERED
#endif //_TREE_UTILS.H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -