當前位置: 首頁>>代碼示例>>C++>>正文


C++ BAD_CAST函數代碼示例

本文整理匯總了C++中BAD_CAST函數的典型用法代碼示例。如果您正苦於以下問題:C++ BAD_CAST函數的具體用法?C++ BAD_CAST怎麽用?C++ BAD_CAST使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BAD_CAST函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: gen_nc_xml

int gen_nc_xml(const struct nc_state_t *nc_state_param)
{
    int ret = EUCA_ERROR;
    char path[MAX_PATH] = "";
    xmlDocPtr doc = NULL;
    xmlNodePtr nc = NULL;
    xmlNodePtr version = NULL;
    xmlNodePtr enabled = NULL;

    INIT();

    pthread_mutex_lock(&xml_mutex);
    {
        doc = xmlNewDoc(BAD_CAST "1.0");
        nc = xmlNewNode(NULL, BAD_CAST "nc");
        xmlDocSetRootElement(doc, nc);

        version = xmlNewChild(nc, NULL, BAD_CAST "version", BAD_CAST(nc_state_param->version));
        enabled = xmlNewChild(nc, NULL, BAD_CAST "enabled", BAD_CAST(nc_state_param->is_enabled ? "true" : "false"));

        snprintf(path, sizeof(path), EUCALYPTUS_NC_STATE_FILE, nc_state.home);
        ret = write_xml_file(doc, "global", path, "nc");
        xmlFreeDoc(doc);
    }
    pthread_mutex_unlock(&xml_mutex);

    return (ret);
}
開發者ID:NalaGinrut,項目名稱:eucalyptus,代碼行數:28,代碼來源:xml.c

示例2: while

BOOL CLibXmlXmlParser::SetElementValue( LPCTSTR strElementName, LPCTSTR strValue )
{
    BOOL bResult = FALSE;


    if( this->m_pXMLRootNode )
    {
        xmlNodePtr pChild = this->m_pXMLRootNode->children;
        while( pChild )
        {
            if( xmlStrcmp( pChild->name , BAD_CAST(strElementName) ) == 0 )
            {
                break;
            }
            pChild = pChild->next;
        }
        if( !pChild )
        {
            //			pChild = xmlNewNode(NULL , BAD_CAST ( strEleName ));
            pChild = xmlNewChild( this->m_pXMLRootNode, NULL, BAD_CAST(strElementName), BAD_CAST(strValue) );
        }
        if( pChild )
        {
            xmlNodeSetContent( pChild,  BAD_CAST( strValue ) );
            //pChild->content = BAD_CAST( strValue );
        }
        bResult = ( NULL != pChild );
    }

    // 寫完保存。
    bResult &= this->SaveXML();
    return bResult;
}
開發者ID:dalinhuang,項目名稱:ffmpeg-port,代碼行數:33,代碼來源:libxmlxmlparser.cpp

示例3: parseHttpStyle

static int parseHttpStyle(xmlDocPtr doc, xmlNodePtr cur)
{
	xmlChar * temp;
	int ret=1;
	cur = cur->xmlChildrenNode;
	while(cur!=NULL){
		if(!xmlStrcmp(cur->name,(const xmlChar *)"packetLength")){
			temp = xmlNodeListGetString(doc,cur->xmlChildrenNode,1);
			if(temp!=NULL){
				httpConTemp->packetLength=atoi((char *)temp);
				if(httpConTemp->packetLength>MAXLENGTH)
					httpConTemp->packetLength=MAXLENGTH;
			}
			else{
				printf("X Error: read xml 'style.packetLength' Wrong.\n");
				ret &= 0;
			}
			xmlFree(temp);
		}
		else if(!xmlStrcmp(cur->name,(const xmlChar *)"dataHeader")){
			parseHttpDataHeader(doc,cur);
		}
		else if(!xmlStrcmp(cur->name,(const xmlChar *)"data")){
			temp = xmlGetProp(cur,BAD_CAST("random"));
			if(xmlStrcmp(temp,BAD_CAST("true"))==0)
				httpConTemp->dataRandom = 1;
			else
				httpConTemp->dataRandom = 2;
			xmlFree(temp);
			parseHttpData(doc,cur,httpConTemp->dataRandom);
		}
		cur = cur->next;
	}
	return ret;
}
開發者ID:bannerzhu,項目名稱:mygit,代碼行數:35,代碼來源:xmlctr.c

示例4: xmlNewNode

/**\brief Save this Planet to an xml node
 */
xmlNodePtr Planet::ToXMLNode(string componentName) {
	char buff[256];
	xmlNodePtr section = xmlNewNode(NULL, BAD_CAST componentName.c_str() );

	xmlNewChild(section, NULL, BAD_CAST "name", BAD_CAST this->GetName().c_str() );
	xmlNewChild(section, NULL, BAD_CAST "alliance", BAD_CAST this->GetAlliance()->GetName().c_str() );
	snprintf(buff, sizeof(buff), "%d", (int)this->GetWorldPosition().GetX() );
	xmlNewChild(section, NULL, BAD_CAST "x", BAD_CAST buff );
	snprintf(buff, sizeof(buff), "%d", (int)this->GetWorldPosition().GetY() );
	xmlNewChild(section, NULL, BAD_CAST "y", BAD_CAST buff );
	xmlNewChild(section, NULL, BAD_CAST "landable", BAD_CAST (this->GetLandable()?"1":"0") );
	snprintf(buff, sizeof(buff), "%d", this->GetTraffic() );
	xmlNewChild(section, NULL, BAD_CAST "traffic", BAD_CAST buff );
	xmlNewChild(section, NULL, BAD_CAST "image", BAD_CAST this->GetImage()->GetPath().c_str() );
	snprintf(buff, sizeof(buff), "%d", this->GetMilitiaSize() );
	xmlNewChild(section, NULL, BAD_CAST "militia", BAD_CAST buff );
	snprintf(buff, sizeof(buff), "%d", this->GetInfluence() );
	xmlNewChild(section, NULL, BAD_CAST "sphereOfInfluence", BAD_CAST buff );
	list<Technology*> techs = this->GetTechnologies();
	for( list<Technology*>::iterator it = techs.begin(); it!=techs.end(); ++it ){
		xmlNewChild(section, NULL, BAD_CAST "technology", BAD_CAST (*it)->GetName().c_str() );
	}

	return section;
}
開發者ID:Maka7879,項目名稱:Epiar,代碼行數:27,代碼來源:planets.cpp

示例5: xml_out_string

static void
xml_out_string (xmlTextWriterPtr xml, const char *name, const char *value)
{
    xmlTextWriterStartElement (xml, BAD_CAST ("option"));
    xmlTextWriterWriteAttribute (xml, BAD_CAST ("name"), BAD_CAST (name));
    xmlTextWriterWriteAttribute (xml, BAD_CAST ("value"), BAD_CAST (value));
    xmlTextWriterEndElement (xml);
}
開發者ID:7sevenx7,項目名稱:snes9x,代碼行數:8,代碼來源:gtk_config.cpp

示例6: contact_core

History::Contact::Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
			   boost::shared_ptr<xmlDoc> _doc,
			   xmlNodePtr _node):
  contact_core(_contact_core), doc(_doc), node(_node)
{
  xmlChar* xml_str = NULL;

  xml_str = xmlGetProp (node, (const xmlChar *)"type");
  if (xml_str != NULL) {

    m_type = (call_type)(xml_str[0] - '0'); // FIXME: I don't like it!
    xmlFree (xml_str);
  }

  xml_str = xmlGetProp (node, (const xmlChar *)"uri");
  if (xml_str != NULL) {

    uri = (const char *)xml_str;
    xmlFree (xml_str);
  }

  for (xmlNodePtr child = node->children ;
       child != NULL ;
       child = child->next) {

    if (child->type == XML_ELEMENT_NODE
        && child->name != NULL) {

      if (xmlStrEqual (BAD_CAST ("name"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  name = (const char *)xml_str;
        xmlFree (xml_str);
      }

      if (xmlStrEqual (BAD_CAST ("call_start"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  call_start = (time_t) atoi ((const char *) xml_str);
        xmlFree (xml_str);
      }

      if (xmlStrEqual (BAD_CAST ("call_duration"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  call_duration = (const char *) xml_str;
        xmlFree (xml_str);
      }
    }
  }
}
開發者ID:Klom,項目名稱:ekiga,代碼行數:54,代碼來源:history-contact.cpp

示例7: xen_init

void
xen_init(void)
{
    responsePath =
        xmlXPathCompile(
            BAD_CAST(
                "/methodResponse/params/param/value/struct/member/value"));
    faultPath =
        xmlXPathCompile(
            BAD_CAST("/methodResponse/fault/value/struct/member/value"));
}
開發者ID:Angel666,項目名稱:android_hardware_intel,代碼行數:11,代碼來源:xen_common.c

示例8: xml_out_binding

static void
xml_out_binding (xmlTextWriterPtr xml, const char *name, unsigned int value)
{
    char string[1024];
    snprintf (string, 1024, "%u", value);

    xmlTextWriterStartElement (xml, BAD_CAST ("binding"));
    xmlTextWriterWriteAttribute (xml, BAD_CAST ("name"), BAD_CAST (name));
    xmlTextWriterWriteAttribute (xml, BAD_CAST ("binding"), BAD_CAST (string));
    xmlTextWriterEndElement (xml);
}
開發者ID:7sevenx7,項目名稱:snes9x,代碼行數:11,代碼來源:gtk_config.cpp

示例9: parsePacketTime

static int parsePacketTime (xmlDocPtr doc, xmlNodePtr cur)
{
	xmlChar * temp;
	int flag_ptime_random;
	int ptime_value,ptime_meth;
	int ret=1;
	temp = xmlGetProp(cur,BAD_CAST("random"));
	if(temp!=NULL){
		if(xmlStrcmp(temp,BAD_CAST("false"))==0)
			flag_ptime_random = 2;
		else
			flag_ptime_random = 1;
		xmlFree(temp);
		cur = cur->xmlChildrenNode;
		while(cur!=NULL){
			if(flag_ptime_random==2&&!xmlStrcmp(cur->name,(const xmlChar *)"value")){
				temp=xmlNodeListGetString(doc,cur->xmlChildrenNode,1);
				if(temp!=NULL){
					ptime_value = atoi((char *)temp);
				}
				else{
					printf("X Error: read xml 'packetTime.value' Wrong.\n");
					ret &= 0;
				}
				xmlFree(temp);
			}
			else if(flag_ptime_random==1&&!xmlStrcmp(cur->name,(const xmlChar *)"scope")){
				ret &= parsePacketTimeScope(doc,cur);
			}
			else if(flag_ptime_random==1&&!xmlStrcmp(cur->name,(const xmlChar *)"meth")){
				temp=xmlNodeListGetString(doc,cur->xmlChildrenNode,1);
				if(temp!=NULL){
					ptime_meth = atoi((char *)temp);
				}
				else{
					printf("X Error: read xml 'packetTime.meth' Wrong.\n");
					ret &= 0;
				}
				xmlFree(temp);
			}
			cur = cur->next;
		}
		ddosc->packetTimels = get_packetTime(flag_ptime_random,
											ptime_value,
											ptime_from,ptime_to,ptime_meth);
	}
	else{
		printf("X Error: read xml 'packetTime.random' Wrong.\n");
		xmlFree(temp);
		return 0;
	}
	return ret;
}
開發者ID:bannerzhu,項目名稱:mygit,代碼行數:53,代碼來源:xmlctr.c

示例10: core

History::Contact::Contact (Ekiga::ServiceCore &_core,
			   xmlNodePtr _node):
  core(_core), node(_node)
{
  xmlChar *xml_str;

  contact_core
    = dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));

  xml_str = xmlGetProp (node, (const xmlChar *)"type");
  if (xml_str != NULL)
    m_type = (call_type)(xml_str[0] - '0'); // FIXME: I don't like it!
  xmlFree (xml_str);

  xml_str = xmlGetProp (node, (const xmlChar *)"uri");
  if (xml_str != NULL)
    uri = (const char *)xml_str;
  xmlFree (xml_str);

  for (xmlNodePtr child = node->children ;
       child != NULL ;
       child = child->next) {

    if (child->type == XML_ELEMENT_NODE
        && child->name != NULL) {

      if (xmlStrEqual (BAD_CAST ("name"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  name = (const char *)xml_str;
        xmlFree (xml_str);
      }

      if (xmlStrEqual (BAD_CAST ("call_start"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  call_start = (time_t) atoi ((const char *) xml_str);
        xmlFree (xml_str);
      }

      if (xmlStrEqual (BAD_CAST ("call_duration"), child->name)) {

        xml_str = xmlNodeGetContent (child);
	if (xml_str != NULL)
	  call_duration = (const char *) xml_str;
        xmlFree (xml_str);
      }
    }
  }
}
開發者ID:nightfly19,項目名稱:renyang-learn,代碼行數:52,代碼來源:history-contact.cpp

示例11: xar_link_lookup

static xar_file_t xar_link_lookup(xar_t x, dev_t dev, ino_t ino, xar_file_t f) {
	char key[32];
	xar_file_t ret;

	memset(key, 0, sizeof(key));
	snprintf(key, sizeof(key)-1, "%08" DEV_HEXSTRING "%08" INO_HEXSTRING, DEV_CAST dev, INO_CAST ino);
	ret = xmlHashLookup(XAR(x)->ino_hash, BAD_CAST(key));
	if( ret == NULL ) {
		xmlHashAddEntry(XAR(x)->ino_hash, BAD_CAST(key), XAR_FILE(f));
		return NULL;
	}
	return ret;
}
開發者ID:ALEXGUOQ,項目名稱:DocSets-for-iOS,代碼行數:13,代碼來源:stat.c

示例12: cluster_getparam

/*------------------------------------------------------------------------------*/
static void
cluster_getparam(int thr_nb, void *data, cl_error_desc_t *err_desc)
{
  xmlDocPtr doc = NULL;
  xmlNodePtr exanodes_node;
  int ret;

  exalog_debug("getparam");

  /* Create XML document */

  doc = xmlNewDoc(BAD_CAST("1.0"));
  if (doc == NULL)
  {
    set_error(err_desc, -EXA_ERR_XML_INIT, "Failed to create result document");
    return;
  }

  exanodes_node = xmlNewNode(NULL, BAD_CAST("Exanodes"));
  if (exanodes_node == NULL)
  {
    set_error(err_desc, -EXA_ERR_XML_INIT,
	      "Failed to create node in result document");
    xmlFreeDoc(doc);
    return;
  }

  xmlDocSetRootElement(doc, exanodes_node);


  ret = build_response(exanodes_node);

  if (ret ==  EXA_SUCCESS)
    {
      xmlChar *xmlchar_doc;
      int buf_size;

      xmlDocDumpFormatMemory(doc, &xmlchar_doc, &buf_size, 1);

      send_payload_str((char *)xmlchar_doc);

      xmlFree(xmlchar_doc);
    }

  xmlFreeDoc(doc);

  set_error(err_desc, ret, NULL);
}
開發者ID:OznOg,項目名稱:OpenExanodes,代碼行數:49,代碼來源:exa_getparam.c

示例13: config_get_value

const char * config_get_value(const char * _xpath) {
    xmlXPathObjectPtr xmlobject = NULL;
    const xmlChar * xpath = BAD_CAST(_xpath);
    const xmlChar * value = NULL;
    
    
    /* Rquete XPath*/
    xmlobject = xmlXPathEval(xpath, config->context);

    if (!xmlobject)
        return NULL;
    
    if (xmlobject->type == XPATH_NODESET) { 
        if (xmlobject->nodesetval) { 
            /* nodeNr = nb nodes in struct nodesetval */ 
            if (xmlobject->nodesetval->nodeNr > 0) {
                xmlNodePtr n;
		
                n = xmlobject->nodesetval->nodeTab[0];
                if ((n->type == XML_TEXT_NODE) || 
                    (n->type == XML_CDATA_SECTION_NODE))
                    value = n->content;
            }
        }
    }
    
    xmlXPathFreeObject(xmlobject);
    
    return (char *)value;
}
開發者ID:frs69wq,項目名稱:Simbatch,代碼行數:30,代碼來源:simbatch_config.c

示例14: getXNodes

xmlNodeSetPtr getXNodes(xmlXPathContextPtr context, const gchar *xpath) {
  xmlXPathObjectPtr xobj = xmlXPathEvalExpression(BAD_CAST(xpath), context);
  xmlNodeSetPtr ret = xobj->nodesetval;
  xmlXPathFreeNodeSetList(xobj);

  return ret;
}
開發者ID:twouters,項目名稱:apt-dater,代碼行數:7,代碼來源:keyfiles.c

示例15: details

LM::Bank::Bank (boost::shared_ptr<Ekiga::PersonalDetails> details_,
		boost::shared_ptr<Dialect> dialect_,
		boost::shared_ptr<Cluster> cluster_):
  details(details_), cluster(cluster_), dialect(dialect_), doc (NULL)
{
  gchar* c_raw = gm_conf_get_string (JABBER_KEY);

  if (c_raw != NULL) { // we already have it in store

    const std::string raw = c_raw;
    doc = xmlRecoverMemory (raw.c_str (), raw.length ());
    xmlNodePtr root = xmlDocGetRootElement (doc);
    if (root == NULL) {

      root = xmlNewDocNode (doc, NULL, BAD_CAST "list", NULL);
      xmlDocSetRootElement (doc, root);
    }

    for (xmlNodePtr child = root->children; child != NULL; child = child->next) {

      if (child->type == XML_ELEMENT_NODE && child->name != NULL && xmlStrEqual (BAD_CAST ("entry"), child->name)) {

	boost::shared_ptr<Account> account (new Account (details, dialect, cluster, child));
	add (account);
      }
    }
    g_free (c_raw);

  } else { // create a new XML document

    doc = xmlNewDoc (BAD_CAST "1.0");
    xmlNodePtr root = xmlNewDocNode (doc, NULL, BAD_CAST "list", NULL);
    xmlDocSetRootElement (doc, root);
  }
}
開發者ID:Klom,項目名稱:ekiga,代碼行數:35,代碼來源:loudmouth-bank.cpp


注:本文中的BAD_CAST函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。