本文整理汇总了C++中qstring类的典型用法代码示例。如果您正苦于以下问题:C++ qstring类的具体用法?C++ qstring怎么用?C++ qstring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了qstring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reconstruct_type
bool idaapi reconstruct_type(cfuncptr_t cfunc, qstring var_name, qstring type_name)
{
bool bResult = false;
// initialize type rebuilder
type_builder_t type_bldr;
type_bldr.expression_to_match.push_back(var_name.c_str());
// traverse the ctree structure
type_bldr.apply_to(&cfunc->body, NULL);
if (type_bldr.structure.size() != 0) {
tid_t struct_type_id = type_bldr.get_structure(type_name.c_str());
if(struct_type_id != 0 || struct_type_id != -1) {
tinfo_t new_type = create_typedef(type_name.c_str());
if(new_type.is_correct()) {
qstring type_str = type_name.c_str();
//if (new_type.print(&type_str, NULL, PRTYPE_DEF | PRTYPE_MULTI))
logmsg(DEBUG, ("New type created: %s\n", type_str.c_str()));
bResult = true;
}
}
} else {
warning("Failed to reconstruct type, no field references have been found...");
logmsg(DEBUG, "Failed to reconstruct type, no field references have been found...");
}
return bResult;
}
示例2: send_request
//--------------------------------------------------------------------------
// returns error code
int rpc_engine_t::send_request(qstring &s)
{
// if nothing is initialized yet or error occurred, silently fail
if ( irs == NULL || network_error_code != 0 )
return -1;
finalize_packet(s);
const char *ptr = s.c_str();
ssize_t left = s.length();
#ifdef DEBUG_NETWORK
rpc_packet_t *rp = (rpc_packet_t *)ptr;
int len = qntohl(rp->length);
show_hex(rp+1, len, "SEND %s %d bytes:\n", get_rpc_name(rp->code), len);
// msg("SEND %s\n", get_rpc_name(rp->code));
#endif
while ( left > 0 )
{
ssize_t code = irs_send(irs, ptr, left);
if ( code == -1 )
{
code = irs_error(irs);
network_error_code = code;
warning("irs_send: %s", winerr((int)code));
return (int)code;
}
left -= code;
ptr += code;
}
return 0;
}
示例3: dump_type_info
void idaapi dump_type_info(int file_id, const VTBL_info_t& vtbl_info, const qstring& type_name, const std::map<ea_t, VTBL_info_t>& vtbl_map) {
struc_t * struc_type = get_struc(get_struc_id(type_name.c_str()));
if (!struc_type)
return;
qstring file_entry_key;
qstring key_hash;
bool filtered = false;
get_struct_key(struc_type, vtbl_info, file_entry_key, filtered, vtbl_map);
get_hash_of_string(file_entry_key, key_hash);
if (filtered)
return;
qstring file_entry_val;
tinfo_t new_type = create_typedef(type_name.c_str());
if (new_type.is_correct() && new_type.print(&file_entry_val, NULL, PRTYPE_DEF | PRTYPE_1LINE)) {
qstring line;
line = key_hash + ";" + file_entry_key + ";";
line.cat_sprnt("%a;", vtbl_info.ea_begin);
line += file_entry_val + ";";
if (rtti_vftables.count(vtbl_info.ea_begin) != 0) {
VTBL_info_t vi = rtti_vftables[vtbl_info.ea_begin];
line += vi.vtbl_name;
}
line.rtrim();
line += "\r\n";
qwrite(file_id, line.c_str(), line.length());
}
}
示例4: HU_CenterMessage
//
// HU_CenterMessage
//
// haleyjd 04/27/04: rewritten to use qstring
//
void HU_CenterMessage(const char *s)
{
static qstring qstr(128);
int st_height = GameModeInfo->StatusBar->height;
qstr.clear();
// haleyjd 02/28/06: colored center message
if(centermsg_color)
{
qstr += centermsg_color;
centermsg_color = NULL;
}
qstr += s;
centermessage_widget.setMessage(qstr.constPtr(),
(SCREENWIDTH - V_FontStringWidth(hud_font, s)) / 2,
(SCREENHEIGHT - V_FontStringHeight(hud_font, s) -
((scaledwindow.height == SCREENHEIGHT) ? 0 : st_height - 8)) / 2,
leveltime + (message_timer * 35) / 1000);
// print message to console also
C_Printf("%s\n", s);
}
示例5: getZoneSize
//
// MetaObject::toString
//
// Virtual method for conversion of metaobjects into strings. As with the prior
// C implementation, the returned string pointer is a static buffer and should
// not be cached. The default toString method creates a hex dump representation
// of the object. This should be pretty interesting in C++...
// 04/03/11: Altered to use new ZoneObject functionality so that the entire
// object, including all subclasses, are dumped properly. Really cool ;)
//
const char *MetaObject::toString() const
{
static qstring qstr;
size_t bytestoprint = getZoneSize();
const byte *data = reinterpret_cast<const byte *>(getBlockPtr());
qstr.clearOrCreate(128);
if(!bytestoprint) // Not a zone object? Can only dump the base class.
{
bytestoprint = sizeof(*this);
data = reinterpret_cast<const byte *>(this); // Not evil, I swear :P
}
while(bytestoprint)
{
int i;
// print up to 12 bytes on each line
for(i = 0; i < 12 && bytestoprint; ++i, --bytestoprint)
{
byte val = *data++;
char bytes[4] = { 0 };
sprintf(bytes, "%02x ", val);
qstr += bytes;
}
qstr += '\n';
}
return qstr.constPtr();
}
示例6: show_citem_custom_view
bool idaapi show_citem_custom_view(void *ud, qstring ctree_item, qstring item_name)
{
HWND hwnd = NULL;
qstring form_name = "Ctree Item View: ";
form_name.append(item_name);
TForm *form = create_tform(form_name.c_str(), &hwnd);
func_ctree_info_t *si = new func_ctree_info_t(form);
istringstream s_citem_str(ctree_item.c_str());
string tmp_str;
while (getline(s_citem_str, tmp_str, ';'))
{
qstring tmp_qstr = tmp_str.c_str();
si->sv.push_back(simpleline_t(tmp_qstr));
}
simpleline_place_t s1;
simpleline_place_t s2(ctree_item.size());
si->cv = create_custom_viewer("Ctree Item View: ", NULL, &s1, &s2, &s1, 0, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_NOLINES);
set_custom_viewer_handlers(si->cv, NULL, NULL, NULL, NULL, NULL, NULL, si);
open_tform(form, FORM_ONTOP | FORM_RESTORE);
return false;
}
示例7: toString
result_t XmlComment::toString(qstring &retVal)
{
retVal = "<!--";
retVal.append(m_data.data());
retVal.append("-->");
return 0;
}
示例8: MakeMAPxy
//
// MakeMAPxy
//
// Utility to convert Hexen's map numbers into MAPxy map name strings.
//
static void MakeMAPxy(qstring &mapName)
{
char *endptr = NULL;
auto num = mapName.toLong(&endptr, 10);
if(*endptr == '\0' && num >= 1 && num <= 99)
mapName.Printf(9, "MAP%02d", num);
}
示例9: check_subtype
bool idaapi check_subtype(const VTBL_info_t &vtbl_info, const qstring &subtype_name) {
bool bResult = false;
qstring search_str;
search_str.sprnt("_%p", vtbl_info.ea_begin);
tid_t type_id = get_struc_id(subtype_name.c_str());
if (type_id != BADADDR) {
struc_t * struc_type = get_struc(type_id);
if (struc_type != NULL) {
// enumerate members
for (ea_t offset = get_struc_first_offset(struc_type); offset != BADADDR; offset = get_struc_next_offset(struc_type, offset)) {
member_t * member_info = get_member(struc_type, offset);
if (member_info != NULL) {
qstring member_name = get_member_name2(member_info->id);
if (member_name.find(search_str, 0) != -1) {
bResult = true;
break;
}
}
}
}
}
return bResult;
}
示例10: qstring
//
// INStatsManager::makeKey
//
// Make a key from a path and a lump name, even if the wad's not loaded.
//
void INStatsManager::getLevelKey(qstring &outstr,
const char *path, const char *mapName)
{
outstr = path;
outstr.normalizeSlashes();
outstr << "::" << qstring(mapName).toUpper();
}
示例11: add_struc
tid_t type_builder_t::get_structure(const qstring name)
{
tid_t struct_type_id = add_struc(BADADDR, name.c_str());
if (struct_type_id != 0 || struct_type_id != -1)
{
struc_t * struc = get_struc(struct_type_id);
if(struc != NULL)
{
opinfo_t opinfo;
opinfo.tid = struct_type_id;
int j = 0;
for(std::map<int, struct_filed>::iterator i = structure.begin(); i != structure.end() ; i ++)
{
VTBL_info_t vtbl;
flags_t member_flgs = 0;
if(i->second.size == 1)
member_flgs = byteflag();
else if (i->second.size == 2)
member_flgs = wordflag();
else if (i->second.size == 4)
member_flgs = dwrdflag();
else if (i->second.size == 8)
member_flgs = qwrdflag();
char field_name[258];
memset(field_name, 0x00, sizeof(field_name));
if((i->second.vftbl != BADADDR) && get_vbtbl_by_ea(i->second.vftbl, vtbl))
{
qstring vftbl_name = name;
vftbl_name.cat_sprnt("_VTABLE_%X_%p", i->second.offset, i->second.vftbl);
tid_t vtbl_str_id = create_vtbl_struct(vtbl.ea_begin, vtbl.ea_end, (char *)vftbl_name.c_str(), 0);
if (vtbl_str_id != BADADDR) {
sprintf_s(field_name, sizeof(field_name), "vftbl_%d_%p", j, i->second.vftbl);
int iRet = add_struc_member(struc, field_name, i->second.offset, member_flgs, NULL, i->second.size);
member_t * membr = get_member_by_name(struc, field_name);
if (membr != NULL) {
tinfo_t new_type = create_typedef((char *)vftbl_name.c_str());
if(new_type.is_correct()) {
smt_code_t dd = set_member_tinfo2(struc, membr, 0, make_pointer(new_type), SET_MEMTI_COMPATIBLE);
}
}
}
}
else
{
sprintf_s(field_name, sizeof(field_name), "field_%X", i->second.offset);
int iRet = add_struc_member(struc, field_name, i->second.offset, member_flgs, NULL, i->second.size);
}
j ++;
}
}
}
return struct_type_id;
}
示例12: ToTGA
bool ToTGA(quint8* data, int width, int height, int bytes, const qstring& file)
{
FILE* outfile = fopen(file.c_str(), "wb");
if (!outfile)
return false;
quint8 header[18];
memset(header, 0, 18);
header[2] = 2; // type
*((quint16*)(&header[12])) = (quint16)width;
*((quint16*)(&header[14])) = (quint16)height;
header[16] = bytes * 8;
fwrite(header, 1, 18, outfile);
if( bytes == 3 )
fwrite(data, 1, width * height * 3, outfile);
else
fwrite(data, 1, width * height * 4, outfile);
fclose(outfile);
return true;
}
示例13: FromBMP
bool FromBMP(quint8** out, int& outwidth, int& outheight, int& outbytes, const qstring& file)
{
FILE* infile = fopen(file.c_str(), "rb");;
if( !infile )
return false;
fseek(infile, 0, SEEK_END);
long length = ftell(infile);
fseek(infile, 0, SEEK_SET);
char* data = (char*)malloc(length);
if( !data )
{
fclose(infile);
return false;
}
fread(data, 1, length, infile);
fclose(infile);
size_t size = FromBMP(out, outwidth, outheight, outbytes, (size_t)length, data);
free(data);
return (0 != size);
}
示例14: openthirdpartytxurl
void transactionview::openthirdpartytxurl(qstring url)
{
if(!transactionview || !transactionview->selectionmodel())
return;
qmodelindexlist selection = transactionview->selectionmodel()->selectedrows(0);
if(!selection.isempty())
qdesktopservices::openurl(qurl::fromuserinput(url.replace("%s", selection.at(0).data(transactiontablemodel::txhashrole).tostring())));
}
示例15: func_name_has_prefix
inline bool func_name_has_prefix(qstring &prefix, ea_t startEA) {
qstring func_name;
if (prefix.length() <= 0)
return false;
if (get_func_name2(&func_name, startEA) == 0)
return false;
if (func_name.length() <= 0)
return false;
if (func_name.find(prefix.c_str(), 0) != 0)
return false;
return true;
}