本文整理汇总了C++中astring类的典型用法代码示例。如果您正苦于以下问题:C++ astring类的具体用法?C++ astring怎么用?C++ astring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了astring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}
}
示例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;
}
示例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());
}
}
示例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 (*.*)|*.*|");
}
示例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);
}
示例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();
}
示例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;
}
}