本文整理汇总了C++中parse_name函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_name函数的具体用法?C++ parse_name怎么用?C++ parse_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_section
static void handle_section(char *s)
{
char *name,*attr,*new,*p;
uint32_t mem=0;
section *sec;
if(!(name=parse_name(&s))){
syntax_error(20); /* section name */
return;
}
if(*s==','){
s=skip(s+1);
if(*s!='\"')
general_error(6,'\"'); /* quote expected */
if(attr=parse_name(&s)){
if(*s==','){
p=s=skip(s+1);
if(*s=='@'||*s=='%'){
/* ELF section type "progbits" or "nobits" */
s++;
if(new=parse_identifier(&s)){
if(!strcmp(new,"nobits")){
myfree(new);
if(strchr(attr,'u')==NULL){
new=mymalloc(strlen(attr)+2);
sprintf(new,"u%s",attr);
myfree(attr);
attr=new;
}
}else{
if(strcmp(new,"progbits"))
syntax_error(14); /* invalid sectiont type ignored */
myfree(new);
}
}
示例2: skip_space
void
xml_html_parser::parse_entity_decl () {
s += 8;
skip_space ();
bool parameter= test (s, "%");
if (parameter) { s += 1; skip_space (); }
string name= parse_name ();
if (parameter) name= "%" * name * ";";
else name= "&" * name * ";";
skip_space ();
if (test (s, "SYSTEM") || test (s, "PUBLIC")) {
// TODO: allow for loading of external entities using wget
if (test (s, "SYSTEM")) (void) parse_system ();
else (void) parse_public ();
skip_space ();
if (test (s, "NDATA")) {
s += 5;
skip_space ();
(void) parse_name ();
}
}
else {
string val= parse_quoted ();
val= expand_entities (val);
entities (name) = val;
// cout << name << " := " << val << "\n";
}
skip_space ();
if (test (s, ">")) s += 1;
}
示例3: read_fastq
int read_fastq(char *fname1, char *fname2, Reads &reads) {
std::ifstream f1(fname1),f2(fname2);
if (!f1.is_open()) {
std::cerr << "ERROR: could not open file " << fname1 << "\n";
exit(-1);
}
if (!f2.is_open()) {
std::cerr << "ERROR: could not open file " << fname2 << "\n";
exit(-1);
}
std::string p1,p2;
Read r1, r2;
int count=0,num=0;
while(std::getline(f1,p1) && std::getline(f2,p2)) {
//std::cout << p1 << "\t\t\t" << p2 << "\n";
if(count==0) {
r1.name = parse_name(p1);
r2.name = parse_name(p2);
}
if(count==1) {
r1.seq = p1;
r2.seq = p2;
reads.push_back(r1);
reads.push_back(r2);
num++;
}
count+=1;
count%=4;
}
return num;
}
示例4: parse_string
string
xml_html_parser::transcode (string s2) {
s= parse_string (s2);
string encoding;
if (test (s, "<?")) {
s += 2;
string target= parse_name ();
skip_space ();
if (target == "xml") {
// since html==true implies we can accept horribly broken HTML, the
// presence of an XML prolog is not enough to clear the flag.
/* html= false; */
while (s && !test (s, "?>")) {
string attname= parse_name ();
skip_space ();
if (!test (s, "=")) break;
s += 1;
skip_space ();
string val;
if (test (s, "\"")) {
s += 1;
val= parse_until ("\"");
skip_space ();
}
else if (test (s, "'")) {
s += 1;
val= parse_until ("'");
skip_space ();
}
if (attname == "encoding") {
encoding= upcase_all (val);
break;
}
}
}
}
if (N(encoding) != 0) {
// cout << "encoding was specified\n" ;
string s3= convert (s2, encoding, "UTF-8");
if (N(s3) == 0)
/* conversion from specified charset failed, do nothing (and pray) */ ;
else return s3;
}
else {
// cout << "guess encoding\n" ;
if (check_encoding (s2, "UTF-8"))
/* input encoding seems to be utf-8, do nothing */ ;
else {
string s3= convert (s2, "ISO-8859-1", "UTF-8");
if (N(s3) != 0) return s3;
}
}
return s2;
}
示例5: parse_name
void document_imp::StartElementHandler(
const XML_Char* name,
const XML_Char** atts)
{
string element, ns, prefix;
parse_name(name, element, ns, prefix);
node_ptr n;
n.reset(new node(element, ns, prefix));
if (cur.empty())
{
cur.push(n);
root = cur.top();
}
else
{
cur.top()->add_child(n);
cur.push(n);
}
for (const char** att = atts; *att; att += 2)
{
if (not att[0] or not att[1])
break;
parse_name(att[0], element, ns, prefix);
if (not prefix.empty())
element = prefix + ':' + element;
attribute_ptr attr(new xml::attribute(element, att[1]));
cur.top()->add_attribute(attr);
}
const string name_prefix("xmlns:");
for (vector<pair<string,string> >::iterator ns = namespaces.begin(); ns != namespaces.end(); ++ns)
{
string name;
if (ns->first.empty())
name = "xmlns";
else
name = name_prefix + ns->first;
attribute_ptr attr(new xml::attribute(name, ns->second));
cur.top()->add_attribute(attr);
}
namespaces.clear();
}
示例6: assert
bool xml_istream::parse_empty_tag(const string& s, string& open, map<string, string>& attributes)
{
bool ok = false;
open.clear();
attributes.clear();
size_t length = s.length();
size_t k = s.rfind("/>");
assert(s.find('<') == 0 && (k + 2) == length);
size_t i = 1;
if (parse_name(s, i, open) != false)
{
ok = true;
parse_ws(s, i);
while (i < k && ok != false)
{
string attribute, value;
ok = false;
if (parse_name(s, i, attribute) != false)
{
if (parse_eq(s, i) != false)
{
char ch = s[i];
if (ch == '\'' || ch == '"')
{
++i;
for (; i < k && s[i] != ch; ++i)
{
value += s[i];
}
if (s[i] == ch)
{
attributes[attribute] = value;
ok = true;
}
}
}
}
++i;
parse_ws(s, i);
}
}
return ok;
}
示例7: handle_section
static void handle_section(char *s)
{
char *name,*attr;
if(!(name=parse_name(&s)))
return;
if(*s==','){
s=skip(s+1);
attr=s;
if(*s!='\"')
syntax_error(7);
else
s++;
attr=s;
while(*s&&*s!='\"')
s++;
attr=cnvstr(attr,s-attr);
s=skip(s+1);
}else{
attr="";
if(!strcmp(name,textname)) attr=textattr;
if(!strcmp(name,dataname)) attr=dataattr;
if(!strcmp(name,sdataname)) attr=sdataattr;
if(!strcmp(name,sdata2name)) attr=sdata2attr;
if(!strcmp(name,rodataname)) attr=rodataattr;
if(!strcmp(name,bssname)) attr=bssattr;
if(!strcmp(name,sbssname)) attr=sbssattr;
if(!strcmp(name,tocdname)) attr=tocdattr;
}
new_section(name,attr,1);
switch_section(name,attr);
eol(s);
}
示例8: results_of_competition
void results_of_competition(){
FILE* f;
char str[40];
int results [3];
short int i, max;
struct Competitors participant, first, second, third;
first.res = -1;
second.res = -1;
third.res = -1;
f = fopen("competition.txt", "r");
while (fgets(str, 40, f) != NULL) {
i = parse_name(str, &participant);
parse_results(i, str, results);
max = -1;
for (i = 0; i < 3; ++i){
if (results[i] > max) max = results[i];
}
participant.res = max;
place_participants(first, third, second, participant);
}
fclose(f);
if (first.res != -1) printf("I место: %s, результат: %d\n", first.name, first.res);
if (second.res != -1) printf("II место: %s, результат: %d\n", second.name, second.res);
if (third.res != -1) printf("III место: %s, результат: %d\n", third.name, third.res);
}
示例9: print_subsys
void print_subsys(char* file)
{
char line[256];
FILE* fp = 0;
parse_name(file);
fp = fopen(file , "r");
if ( fp != NULL)
{
while (fgets(line, sizeof(line), fp) != NULL)
{
if (empty_line(line) == 0)
{
printf(" ");
fputs(line,stdout);
}
}
fclose(fp);
}
else
{
printf("Error opening '%s'\n",file);
}
}
示例10: GH_verbose
static void GH_verbose(int level, const char *fmt, ...)
{
static int verbosity=-1;
static FILE *output_stream=NULL;
static int stream_initialized=0;
va_list args;
if (verbosity < 0) {
verbosity=get_envi("GH_VERBOSE", GH_MSG_LEVEL_DEFAULT);
}
if (level > verbosity) {
return;
}
if (!stream_initialized) {
const char *file=getenv("GH_VERBOSE_FILE");
if (file) {
char buf[PATH_MAX];
parse_name(buf, sizeof(buf), file, 0);
output_stream=fopen(buf,"a+t");
}
if (!output_stream)
output_stream=GH_DEFAULT_OUTPUT_STREAM;
stream_initialized=1;
}
fprintf(output_stream,"GH: ");
va_start(args, fmt);
vfprintf(output_stream, fmt, args);
va_end(args);
fflush(output_stream);
}
示例11: GNUNET_DNSPARSER_parse_name
/**
* Parse name inside of a DNS query or record.
*
* @param udp_payload entire UDP payload
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the name to parse in the udp_payload (to be
* incremented by the size of the name)
* @return name as 0-terminated C string on success, NULL if the payload is malformed
*/
char *
GNUNET_DNSPARSER_parse_name (const char *udp_payload,
size_t udp_payload_length,
size_t *off)
{
return parse_name (udp_payload, udp_payload_length, off, 0);
}
示例12: create_parameter
void xml_node_t::create_parameter( const std::string& input,
std::string::size_type& index )
{
// required format: name="value"
std::string name_str;
if ( ! parse_name( name_str, input, index ) )
return;
assert( input[ index ] == '=' );
index++;
char quote = input[ index ];
assert( quote == '"' || quote == '\'' );
index++;
std::string::size_type start = index;
while ( input[ index ] != quote )
{
assert( input[ index ] );
index++;
}
std::string value_str = input.substr( start, index - start );
index++;
simplify_xml( value_str );
parameters.push_back( xml_parm_t( name_str, value_str ) );
}
示例13: while
int JSON::parse_array(const char *begin, const char *end, bool withname, std::vector<JSON::Node> *children)
{
children->clear();
char const *ptr = begin;
while (1) {
int n;
Node node;
if (withname) {
n = parse_name(ptr, end, &node);
if (n > 0) {
ptr += n;
ptr += scan_space(ptr, end);
if (*ptr == ':') {
ptr++;
}
}
}
n = parse_value(ptr, end, &node);
if (node.type != Type::Unknown) {
children->push_back(node);
}
ptr += n;
ptr += scan_space(ptr, end);
if (ptr < end && *ptr == ',') {
ptr++;
continue;
}
return ptr - begin;
}
}
示例14: parse_block_type
static blocktype
parse_block_type(void)
{
char new_file_token_str[256];
blocktype block_type;
// Parse the file token string as a name.
if (!parse_name(file_token_str, new_file_token_str, false))
expected_token("a valid block type");
// Now verify it's a valid block type.
if (!stricmp(new_file_token_str, "structural"))
block_type = STRUCTURAL_BLOCK;
else if (!stricmp(new_file_token_str, "multifaceted sprite"))
block_type = MULTIFACETED_SPRITE;
else if (!stricmp(new_file_token_str, "angled sprite"))
block_type = ANGLED_SPRITE;
else if (!stricmp(new_file_token_str, "revolving sprite"))
block_type = REVOLVING_SPRITE;
else if (!stricmp(new_file_token_str, "facing sprite"))
block_type = FACING_SPRITE;
else if (!stricmp(new_file_token_str, "player sprite"))
block_type = PLAYER_SPRITE;
else
expected_token("block type 'structural', 'multifaceted sprite', "
"'angled sprite', 'revolving sprite', 'facing sprite' or "
"'player sprite'");
return(block_type);
}
示例15: parse_name
tree
xml_html_parser::parse_closing () {
s += 2;
string name= parse_name ();
(void) parse_until (">");
return tuple ("end", name);
}