本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
示例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"));
}
示例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);
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例14: getXNodes
xmlNodeSetPtr getXNodes(xmlXPathContextPtr context, const gchar *xpath) {
xmlXPathObjectPtr xobj = xmlXPathEvalExpression(BAD_CAST(xpath), context);
xmlNodeSetPtr ret = xobj->nodesetval;
xmlXPathFreeNodeSetList(xobj);
return ret;
}
示例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);
}
}