本文整理汇总了C++中parse_name函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_name函数的具体用法?C++ parse_name怎么用?C++ parse_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:hoglet67,项目名称:PiTubeDirect,代码行数:35,代码来源:syntax.c
示例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;
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:32,代码来源:parsexml.cpp
示例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;
}
开发者ID:gmridul,项目名称:genomeseq,代码行数:31,代码来源:fastqwrapper.cpp
示例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;
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:57,代码来源:parsexml.cpp
示例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();
}
开发者ID:BackupTheBerlios,项目名称:japi-svn,代码行数:53,代码来源:document.cpp
示例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;
}
开发者ID:TheRayTracer,项目名称:XML-input-stream,代码行数:53,代码来源:xml_istream.cpp
示例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);
}
开发者ID:ezrec,项目名称:vasm,代码行数:34,代码来源:syntax.c
示例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);
}
开发者ID:Zhuikov,项目名称:ProgrammingCourse,代码行数:34,代码来源:5_strings.c
示例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);
}
}
开发者ID:AntoineBlais,项目名称:paparazzi,代码行数:27,代码来源:wiki_gen.c
示例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);
}
开发者ID:derhass,项目名称:glx_hook,代码行数:32,代码来源:glx_hook.c
示例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);
}
开发者ID:GNUnet,项目名称:gnunet,代码行数:16,代码来源:dnsparser.c
示例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 ) );
}
开发者ID:svn2github,项目名称:simulationcraft-ffxiv,代码行数:27,代码来源:sc_xml.cpp
示例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;
}
}
开发者ID:soramimi,项目名称:twicpps,代码行数:30,代码来源:json.cpp
示例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);
}
开发者ID:docbrown,项目名称:3dml,代码行数:31,代码来源:Parser.cpp
示例15: parse_name
tree
xml_html_parser::parse_closing () {
s += 2;
string name= parse_name ();
(void) parse_until (">");
return tuple ("end", name);
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:7,代码来源:parsexml.cpp
示例16: tuple
tree
xml_html_parser::parse_doctype () {
s += 9;
tree dt= tuple ("doctype");
skip_space ();
dt << parse_name ();
skip_space ();
if (test (s, "SYSTEM")) dt << parse_system ();
else if (test (s, "PUBLIC")) dt << parse_public ();
skip_space ();
if (test (s, "[")) {
s += 1;
while (s) {
skip_space ();
if (test (s, "]")) { s += 1; break; }
else if (test (s, "<!ELEMENT")) dt << parse_element ();
else if (test (s, "<!ATTLIST")) dt << parse_cdata ();
else if (test (s, "<!ENTITY")) parse_entity_decl ();
else if (test (s, "<!NOTATION")) a << parse_notation ();
else if (test (s, "<?")) dt << parse_pi ();
else if (test (s, "<!--")) dt << parse_comment ();
else if (s[0] == '&' || s[0] == '%') (void) parse_entity ();
else s += 1;
}
}
skip_space ();
if (test (s, ">")) s += 1;
return dt;
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:31,代码来源:parsexml.cpp
示例17: int_s_t
T FunctionHandlerDDL<T>::operator () (std::vector<std::string> const & args) const
{
obj_t funcObj = LevelObject::create();
obj_t returnType = LevelObject::create(type_t::type_type(), type_t::type_auto<T>());
funcObj->addObject(name_t::name_return_type, returnType);
obj_t argcObj = LevelObject::create(type_t::type_shortint(), int_s_t(args.size()));
funcObj->addObject(name_t(key_name_argc()), argcObj);
for (size_t index = 0; index < args.size(); ++index)
{
// TODO: Should make an arg_t for undefined types.
obj_t argObj;
if (index < _argt.size())
obj_t argObj = LevelObject::create(_argt[index], args[index]);
else
obj_t argObj = LevelObject::create(type_t::type_string(), string_t(args[index]));
name_t argName(parse_name(key_name_arg() + make_string(index)));
funcObj->addObject(argName, argObj);
}
funcObj->addData(_data);
obj_t returnValue = funcObj->getObject(name_t::name_return_value);
return convert<T, obj_t>(returnValue);
}
开发者ID:DavidPH,项目名称:DH-dlc,代码行数:29,代码来源:FunctionHandlerDDL.cpp
示例18: parse_name
void reader::implementation::parse_attribute(Attribute& attribute)
{
parse_name(attribute.name);
/*!re2c
space* '=' space*
{
}
else
{
throw_error();
}
*/
marker = cursor;
/*!re2c
["] [^"]* ["] | ['] [^']* [']
{
attribute.value = std::string(marker + 1, cursor - 1);
return;
}
else
{
throw_error();
}
*/
}
开发者ID:purpleKarrot,项目名称:xml,代码行数:25,代码来源:re2c.in.hpp
示例19: parse_name
void helper_t<obj_t *>::parse(in_t::ptr_t &ptr, obj_t *&val) {
string_t name = parse_name(ptr);
obj_t *obj = phantom::obj_find(name);
if(!obj)
error(ptr, "name not found");
val = obj;
}
开发者ID:Civil,项目名称:phantom,代码行数:8,代码来源:obj.C
示例20: handle_incdir
static void handle_incdir(char *s)
{
char *name;
if (name = parse_name(&s))
new_include_path(name);
eol(s);
}
开发者ID:ezrec,项目名称:vasm,代码行数:8,代码来源:syntax.c
注:本文中的parse_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论