本文整理汇总了C++中astring类的典型用法代码示例。如果您正苦于以下问题:C++ astring类的具体用法?C++ astring怎么用?C++ astring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了astring类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetBytes
static vector<char> GetBytes(astring filePath)
{
vector<char> bytes;
#ifdef _WIN32
ifstream fin(filePath.c_str(), ios::binary | ios::in);
#else
ifstream fin(ToUtf8String(filePath.c_str()).c_str(), ios::binary | ios::in);
#endif
ACE_ASSERT(!fin.fail(), "ファイルは開けませんでした");
while (!fin.eof())
{
char byte;
fin.read(&byte, 1);
if (!fin.eof())
{
bytes.push_back(byte);
}
}
fin.close();
return bytes;
}
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:26,代码来源:Generator.cpp
示例2: image_info_astring
void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string)
{
string.printf("%s\n\n", machine.system().description);
#if 0
if (mess_ram_size > 0)
{
char buf2[RAM_STRING_BUFLEN];
string.catprintf("RAM: %s\n\n", ram_string(buf2, mess_ram_size));
}
#endif
image_interface_iterator iter(machine.root_device());
for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
{
const char *name = image->filename();
if (name != NULL)
{
const char *base_filename;
const char *info;
char *base_filename_noextension;
base_filename = image->basename();
base_filename_noextension = strip_extension(base_filename);
// display device type and filename
string.catprintf("%s: %s\n", image->device().name(), base_filename);
// display long filename, if present and doesn't correspond to name
info = image->longname();
if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension)))
string.catprintf("%s\n", info);
// display manufacturer, if available
info = image->manufacturer();
if (info != NULL)
{
string.catprintf("%s", info);
info = stripspace(image->year());
if (info && *info)
string.catprintf(", %s", info);
string.catprintf("\n");
}
// display supported information, if available
switch(image->supported()) {
case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported\n"); break;
case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported\n"); break;
default : break;
}
if (base_filename_noextension != NULL)
free(base_filename_noextension);
}
else
{
string.catprintf("%s: ---\n", image->device().name());
}
}
}
开发者ID:Ander-son,项目名称:libretro-mame,代码行数:60,代码来源:imginfo.c
示例3: next
bool path_iterator::next(astring &buffer, const char *name)
{
// if none left, return FALSE to indicate we are done
if (m_index != 0 && *m_current == 0)
return false;
// copy up to the next semicolon
const char *semi = strchr(m_current, ';');
if (semi == NULL)
semi = m_current + strlen(m_current);
buffer.cpy(m_current, semi - m_current);
m_current = (*semi == 0) ? semi : semi + 1;
// append the name if we have one
if (name != NULL)
{
// compute the full pathname
if (buffer.len() > 0)
buffer.cat(PATH_SEPARATOR);
buffer.cat(name);
}
// bump the index and return TRUE
m_index++;
return true;
}
开发者ID:Gu1,项目名称:libretro-mame,代码行数:26,代码来源:fileio.c
示例4: parse_ini_file
bool core_options::parse_ini_file(core_file &inifile, int priority, int ignore_priority, astring &error_string)
{
// loop over lines in the file
char buffer[4096];
while (core_fgets(buffer, ARRAY_LENGTH(buffer), &inifile) != NULL)
{
// find the extent of the name
char *optionname;
for (optionname = buffer; *optionname != 0; optionname++)
if (!isspace((UINT8)*optionname))
break;
// skip comments
if (*optionname == 0 || *optionname == '#')
continue;
// scan forward to find the first space
char *temp;
for (temp = optionname; *temp != 0; temp++)
if (isspace((UINT8)*temp))
break;
// if we hit the end early, print a warning and continue
if (*temp == 0)
{
error_string.catprintf("Warning: invalid line in INI: %s", buffer);
continue;
}
// NULL-terminate
*temp++ = 0;
char *optiondata = temp;
// scan the data, stopping when we hit a comment
bool inquotes = false;
for (temp = optiondata; *temp != 0; temp++)
{
if (*temp == '"')
inquotes = !inquotes;
if (*temp == '#' && !inquotes)
break;
}
*temp = 0;
// find our entry
entry *curentry = m_entrymap.find(optionname);
if (curentry == NULL)
{
if (priority >= ignore_priority)
error_string.catprintf("Warning: unknown option in INI: %s\n", optionname);
continue;
}
// set the new data
validate_and_set_data(*curentry, optiondata, priority, error_string);
}
return true;
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:58,代码来源:options.c
示例5: parse_command_line
bool core_options::parse_command_line(int argc, char **argv, int priority, astring &error_string)
{
// reset the errors and the command
error_string.reset();
m_command.reset();
// iterate through arguments
int unadorned_index = 0;
bool retVal = true;
for (int arg = 1; arg < argc; arg++)
{
// determine the entry name to search for
const char *curarg = argv[arg];
bool is_unadorned = (curarg[0] != '-');
const char *optionname = is_unadorned ? core_options::unadorned(unadorned_index++) : &curarg[1];
// find our entry; if not found, indicate invalid option
entry *curentry = m_entrymap.find(optionname);
if (curentry == NULL)
{
error_string.catprintf("Error: unknown option: %s\n", curarg);
retVal = false;
if (!is_unadorned) arg++;
continue;
}
// process commands first
if (curentry->type() == OPTION_COMMAND)
{
// can only have one command
if (m_command)
{
error_string.catprintf("Error: multiple commands specified -%s and %s\n", m_command.cstr(), curarg);
return false;
}
m_command = curentry->name();
continue;
}
// get the data for this argument, special casing booleans
const char *newdata;
if (curentry->type() == OPTION_BOOLEAN)
newdata = (strncmp(&curarg[1], "no", 2) == 0) ? "0" : "1";
else if (is_unadorned)
newdata = curarg;
else if (arg + 1 < argc)
newdata = argv[++arg];
else
{
error_string.catprintf("Error: option %s expected a parameter\n", curarg);
return false;
}
// set the new data
validate_and_set_data(*curentry, newdata, priority, error_string);
}
return retVal;
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:58,代码来源:options.c
示例6: nvram_filename
static astring nvram_filename(running_machine &machine, astring &result)
{
if (rom_system_bios(machine) == 0 || rom_default_bios(machine) == rom_system_bios(machine)) {
result.printf("%s",machine.basename());
} else {
result.printf("%s_%d",machine.basename(),rom_system_bios(machine) - 1);
}
return result;
}
开发者ID:Luke-Nukem,项目名称:mame-144-vector_mod,代码行数:9,代码来源:generic.c
示例7: software_name_split
void device_image_interface::software_name_split(const char *swlist_swname, astring &swlist_name, astring &swname, astring &swpart)
{
// reset all output parameters
swlist_name.reset();
swname.reset();
swpart.reset();
// if no colon, this is the swname by itself
const char *split1 = strchr(swlist_swname, ':');
if (split1 == NULL)
{
swname.cpy(swlist_swname);
return;
}
// if one colon, it is the swname and swpart alone
const char *split2 = strchr(split1 + 1, ':');
if (split2 == NULL)
{
swname.cpy(swlist_swname, split1 - swlist_swname);
swpart.cpy(split1 + 1);
return;
}
// if two colons present, split into 3 parts
swlist_name.cpy(swlist_swname, split1 - swlist_swname);
swname.cpy(split1 + 1, split2 - (split1 + 1));
swpart.cpy(split2 + 1);
}
开发者ID:Eduardop,项目名称:mame,代码行数:29,代码来源:diimage.c
示例8: get_file_path
static astring get_file_path(astring &path)
{
int pos = path.rchr( 0, '\\');
if (pos!=-1) {
path = path.substr(0,pos+1);
} else {
pos = path.rchr( 0, '/');
path = path.substr(0,pos+1);
}
return path;
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:11,代码来源:chdcd.c
示例9: read
void read(PCWSTR path, astring &buf)
{
memory::auto_close<HANDLE> file(::CreateFileW(path, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
nullptr));
if (file != INVALID_HANDLE_VALUE) {
DWORD size = (DWORD)get_size(file);
buf.reserve(size);
CheckApi(::ReadFile(file, (PWSTR )buf.c_str(), buf.size(), &size, nullptr));
}
}
开发者ID:andrew-grechkin,项目名称:cpp,代码行数:11,代码来源:fsysx-file.cpp
示例10: split
/**
@brief 文字列分割
@note
http://shnya.jp/blog/?p=195 のコードを改造
*/
static std::vector<astring> split(const astring &str, const astring &delim)
{
std::vector<astring> res;
size_t current = 0, found, delimlen = delim.size();
while ((found = str.find(delim, current)) != astring::npos)
{
res.push_back(astring(str, current, found - current));
current = found + delimlen;
}
res.push_back(astring(str, current, str.size() - current));
return res;
}
开发者ID:altseed,项目名称:Altseed,代码行数:17,代码来源:asd.Model_IO.cpp
示例11: pad_astring_to_length
void debug_view_breakpoints::pad_astring_to_length(astring& str, int len)
{
int diff = len - str.len();
if (diff > 0)
{
astring buffer;
buffer.expand(diff);
for (int i = 0; i < diff; i++)
buffer.catprintf(" ");
str.catprintf("%s", buffer.cstr());
}
}
开发者ID:MisterTea,项目名称:MAMEHub,代码行数:12,代码来源:dvbpoints.c
示例12: build_generic_filter
void consolewin_info::build_generic_filter(device_image_interface *img, bool is_save, astring &filter)
{
// common image types
add_filter_entry(filter, "Common image types", img->file_extensions());
// compressed
if (!is_save)
filter.cat("Compressed Images (*.zip)|*.zip|");
// all files
filter.cat("All files (*.*)|*.*|");
}
开发者ID:relimited,项目名称:mame,代码行数:12,代码来源:consolewininfo.c
示例13: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &path)
{
astring modified(templatefile);
modified.replace(0, "<!--PATH-->", path.cstr());
core_fwrite(file, modified.cstr(), modified.len());
core_fclose(file);
}
开发者ID:CJBass,项目名称:mame2013-libretro,代码行数:7,代码来源:src2html.c
示例14: cbm_crt_get_card
void cbm_crt_get_card(astring &result, core_file *file)
{
// read the header
cbm_crt_header header;
core_fread(file, &header, CRT_HEADER_LENGTH);
if (memcmp(header.signature, CRT_SIGNATURE, 16) == 0)
{
UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
result.cpy(CRT_C64_SLOT_NAMES[hardware]);
return;
}
result.reset();
}
开发者ID:Ander-son,项目名称:libretro-mame,代码行数:16,代码来源:cbm_crt.c
示例15: read_metadata
chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, astring &output)
{
// wrap this for clean reporting
try
{
// if we didn't find it, just return
metadata_entry metaentry;
if (!metadata_find(searchtag, searchindex, metaentry))
throw CHDERR_METADATA_NOT_FOUND;
// read the metadata
// TODO: how to properly allocate a dynamic char buffer?
char* metabuf = new char[metaentry.length+1];
memset(metabuf, 0x00, metaentry.length+1);
file_read(metaentry.offset + METADATA_HEADER_SIZE, metabuf, metaentry.length);
output.cpy(metabuf);
delete[] metabuf;
return CHDERR_NONE;
}
// just return errors
catch (chd_error &err)
{
return err;
}
}
开发者ID:ErisBlastar,项目名称:PUAE,代码行数:26,代码来源:chd.cpp
示例16: output_footer_and_close_file
static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &title)
{
astring modified(templatefile);
modified.replace(0, "<!--TITLE-->", title.c_str());
core_fwrite(file, modified.c_str(), modified.len());
core_fclose(file);
}
开发者ID:relimited,项目名称:mame,代码行数:7,代码来源:regrep.c
示例17: get_default_card_software
void xegs_cart_slot_device::get_default_card_software(astring &result)
{
if (open_image_file(mconfig().options()))
{
const char *slot_string = "xegs";
dynamic_buffer head(0x10);
UINT32 len = core_fsize(m_file);
int type = A800_8K;
// check whether there is an header, to identify the cart type
if ((len % 0x1000) == 0x10)
{
core_fread(m_file, head, 0x10);
type = identify_cart_type(head);
}
if (type != A800_XEGS)
{
osd_printf_info("This game is not designed for XEGS. ");
if (type >= A5200_4K)
osd_printf_info("You might want to run it in A5200.\n");
else
osd_printf_info("You might want to run it in A800 or A800XL.\n");
}
slot_string = a800_get_slot(type);
clear();
result.cpy(slot_string);
}
else
software_get_default_slot(result, "xegs");
}
开发者ID:crazyquark,项目名称:mame,代码行数:33,代码来源:a800_slot.c
示例18: head
void a5200_cart_slot_device::get_default_card_software(astring &result)
{
if (open_image_file(mconfig().options()))
{
const char *slot_string = "a5200";
dynamic_buffer head(0x10);
UINT32 len = core_fsize(m_file);
int type = A5200_8K;
// check whether there is an header, to identify the cart type
if ((len % 0x1000) == 0x10)
{
core_fread(m_file, head, 0x10);
type = identify_cart_type(head);
astring info;
if (hashfile_extrainfo(*this, info) && info == "A13MIRRORING")
type = A5200_16K_2CHIPS;
}
if (type < A5200_4K)
osd_printf_info("This game is not designed for A5200. You might want to run it in A800 or A800XL.\n");
slot_string = a800_get_slot(type);
clear();
result.cpy(slot_string);
}
else
software_get_default_slot(result, "a5200");
}
开发者ID:crazyquark,项目名称:mame,代码行数:31,代码来源:a800_slot.c
示例19: rom
void sega8_cart_slot_device::get_default_card_software(astring &result)
{
if (open_image_file(mconfig().options()))
{
const char *slot_string = "rom";
UINT32 len = core_fsize(m_file), offset = 0;
dynamic_buffer rom(len);
int type;
core_fread(m_file, rom, len);
if ((len % 0x4000) == 512)
offset = 512;
type = get_cart_type(rom + offset, len - offset);
slot_string = sega8_get_slot(type);
//printf("type: %s\n", slot_string);
clear();
result.cpy(slot_string);
return;
}
software_get_default_slot(result, "rom");
}
开发者ID:Eduardop,项目名称:mame,代码行数:26,代码来源:sega8_slot.c
示例20: get_default_card_software
void apf_cart_slot_device::get_default_card_software(astring &result)
{
if (open_image_file(mconfig().options()))
{
const char *slot_string = "std";
UINT32 size = core_fsize(m_file);
int type = APF_STD;
// attempt to identify Space Destroyer, which needs 1K of additional RAM
if (size == 0x1800)
type = APF_SPACEDST;
if (size > 0x2000)
type = APF_BASIC;
slot_string = apf_get_slot(type);
//printf("type: %s\n", slot_string);
clear();
result.cpy(slot_string);
return;
}
software_get_default_slot(result, "std");
}
开发者ID:crazii,项目名称:mameplus,代码行数:25,代码来源:slot.c
注:本文中的astring类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论