本文整理汇总了C++中Xml类的典型用法代码示例。如果您正苦于以下问题:C++ Xml类的具体用法?C++ Xml怎么用?C++ Xml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Xml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: midiControllerType
void MidiController::write(int level, Xml& xml) const
{
ControllerType t = midiControllerType(_num);
if(t == Velo)
return;
QString type(int2ctrlType(t));
int h = (_num >> 8) & 0x7f;
int l = _num & 0x7f;
QString sl;
if (isPerNoteController())
sl = "pitch";
else
sl.setNum(l);
xml.nput(level, "<Controller name=\"%s\"", Xml::xmlString(_name).toLatin1().constData());
if(t != Controller7)
xml.nput(" type=\"%s\"", type.toLatin1().constData());
int mn = 0;
int mx = 0;
switch (t)
{
case RPN:
case NRPN:
xml.nput(" h=\"%d\"", h);
xml.nput(" l=\"%s\"", sl.toLatin1().constData());
mx = 127;
break;
case Controller7:
xml.nput(" l=\"%s\"", sl.toLatin1().constData());
mx = 127;
break;
case Controller14:
case RPN14:
case NRPN14:
xml.nput(" h=\"%d\"", h);
xml.nput(" l=\"%s\"", sl.toLatin1().constData());
mx = 16383;
break;
case Pitch:
mn = -8192;
mx = 8191;
break;
case PolyAftertouch:
mn = 0;
mx = 127;
break;
case Aftertouch:
mn = 0;
mx = 127;
break;
case Program:
case Velo: // Cannot happen
break;
}
if(t == Program)
{
if(_initVal != CTRL_VAL_UNKNOWN && _initVal != 0xffffff)
xml.nput(" init=\"0x%x\"", _initVal);
}
else
{
if(_minVal != mn)
xml.nput(" min=\"%d\"", _minVal);
if(_maxVal != mx)
xml.nput(" max=\"%d\"", _maxVal);
if(_initVal != CTRL_VAL_UNKNOWN)
xml.nput(" init=\"%d\"", _initVal);
}
if(_showInTracks != (ShowInDrum | ShowInMidi))
xml.nput(" showType=\"%d\"", _showInTracks);
xml.put(" />");
}
示例2: setAttr
int Msg_Define::setAttr(Xml &xml, TiXmlNode *node){
std::string type, value, comt, sub1, sub2, key;
std::string label = xml.get_key(node);
if(label == "arg"){
type = trans_to_base_name(xml.get_attr_str(node, "type"));
}
else if(label == "struct"){
type = trans_to_base_name(xml.get_attr_str(node, "type"));
}
else if(label == "vector"){
type = trans_to_base_name(label);
sub1 = trans_to_base_name(xml.get_attr_str(node, "type"));
}
else if(label == "map"){
type = trans_to_base_name(label);
sub1 = trans_to_base_name(xml.get_attr_str(node, "key_type"));
sub2 = trans_to_base_name(xml.get_attr_str(node, "type"));
key = xml.get_attr_str(node, "key_name");
}
else if(label == "unordered_map"){
type = trans_to_base_name(label);
sub1 = trans_to_base_name(xml.get_attr_str(node, "key_type"));
sub2 = trans_to_base_name(xml.get_attr_str(node, "type"));
key = xml.get_attr_str(node, "key_name");
}
value = xml.get_attr_str(node, "name");
if((comt = xml.get_attr_str(node, "desc")) != "" )
comt = "//" + comt;
typeName_.push_back(type);
subType1_.push_back(sub1);
subType2_.push_back(sub2);
keyName_.push_back(key);
valueName_.push_back(value);
comment_.push_back(comt);
return 0;
}
示例3: GetType
Format* GetType(void* file_pointer, size_t file_size, const string& filename) {
if (depth > max_depth)
return new Format(file_pointer, file_size);
if (!filename.empty()) {
size_t dot = filename.find_last_of('.');
if (dot != string::npos) {
string ext = filename.substr(dot + 1);
// toupper
for (auto& c : ext)
c &= ~0x20;
if (ext == "HTML" || ext == "HTM" || ext == "JS" || ext == "CSS") {
VerbosePrint(ext, " detected.");
return new DataURI(file_pointer, file_size);
}
if (ext == "VCF" || ext == "VCARD") {
VerbosePrint(ext, " detected.");
return new Vcf(file_pointer, file_size);
}
if (ext == "MHT" || ext == "MHTML" || ext == "MIM" || ext == "MIME" || ext == "EML") {
VerbosePrint(ext, " detected.");
return new Mime(file_pointer, file_size);
}
}
}
if (memcmp(file_pointer, Png::header_magic, sizeof(Png::header_magic)) == 0) {
VerbosePrint("PNG detected.");
return new Png(file_pointer, file_size);
} else if (memcmp(file_pointer, Jpeg::header_magic, sizeof(Jpeg::header_magic)) == 0) {
VerbosePrint("JPEG detected.");
return new Jpeg(file_pointer, file_size);
} else if (memcmp(file_pointer, Lua::header_magic, sizeof(Lua::header_magic)) == 0) {
VerbosePrint("Lua detected.");
return new Lua(file_pointer, file_size);
} else if (memcmp(file_pointer, Zip::header_magic, sizeof(Zip::header_magic)) == 0) {
VerbosePrint("ZIP detected.");
return new Zip(file_pointer, file_size);
} else if (memcmp(file_pointer, Pe::header_magic, sizeof(Pe::header_magic)) == 0) {
VerbosePrint("PE detected.");
return new Pe(file_pointer, file_size);
} else if (memcmp(file_pointer, Gz::header_magic, sizeof(Gz::header_magic)) == 0) {
VerbosePrint("GZ detected.");
return new Gz(file_pointer, file_size);
} else if (memcmp(file_pointer, Ico::header_magic, sizeof(Ico::header_magic)) == 0) {
VerbosePrint("ICO detected.");
return new Ico(file_pointer, file_size);
} else if (memcmp(file_pointer, Dwf::header_magic, sizeof(Dwf::header_magic)) == 0) {
VerbosePrint("DWF detected.");
return new Dwf(file_pointer, file_size);
} else if (memcmp(file_pointer, Gft::header_magic, sizeof(Gft::header_magic)) == 0) {
VerbosePrint("GFT detected.");
return new Gft(file_pointer, file_size);
} else if (memcmp(file_pointer, Rdb::header_magic, sizeof(Rdb::header_magic)) == 0) {
VerbosePrint("RDB detected.");
return new Rdb(file_pointer, file_size);
} else if (memcmp(file_pointer, Swf::header_magic, sizeof(Swf::header_magic)) == 0 ||
memcmp(file_pointer, Swf::header_magic_deflate, sizeof(Swf::header_magic_deflate)) == 0 ||
memcmp(file_pointer, Swf::header_magic_lzma, sizeof(Swf::header_magic_lzma)) == 0) {
VerbosePrint("SWF detected.");
return new Swf(file_pointer, file_size);
} else {
// Search for vcard magic which might not be at the very beginning.
const string vcard_magic = "BEGIN:VCARD";
const char* fp = static_cast<char*>(file_pointer);
const char* search_end = fp + std::min(static_cast<size_t>(1024), file_size);
if (std::search(fp, search_end, vcard_magic.begin(), vcard_magic.end()) < search_end) {
VerbosePrint("VCF detected.");
return new Vcf(file_pointer, file_size);
}
// tar file does not have header magic
// ustar is optional
{
Tar* t = new Tar(file_pointer, file_size);
// checking first record checksum
if (t->IsValid()) {
VerbosePrint("tar detected.");
return t;
}
delete t;
}
// XML file does not have header magic
// have to parse and see if there are any errors.
{
Xml* x = new Xml(file_pointer, file_size);
if (x->IsValid()) {
VerbosePrint("XML detected.");
return x;
}
delete x;
}
}
VerbosePrint("Format not supported!");
// for unsupported format, just memmove it.
return new Format(file_pointer, file_size);
}
示例4: switch
void Patch::read(Xml& xml)
{
typ = -1;
hbank = -1;
lbank = -1;
prog = 0;
drum = false;
keys.clear();
keyswitches.clear();
for (;;)
{
Xml::Token token = xml.parse();
const QString& tag = xml.s1();
switch (token)
{
case Xml::Error:
case Xml::End:
return;
case Xml::TagStart:
xml.unknown("Patch");
break;
case Xml::Attribut:
if (tag == "name")
name = xml.s2();
else if (tag == "mode")
typ = xml.s2().toInt();
else if (tag == "hbank")
hbank = xml.s2().toInt();
else if (tag == "lbank")
lbank = xml.s2().toInt();
else if (tag == "prog")
prog = xml.s2().toInt();
else if (tag == "drum")
drum = xml.s2().toInt();
else if(tag == "keys")
{
QStringList klist = ((QString)xml.s2()).split(QString(" "), QString::SkipEmptyParts);
for (QStringList::Iterator it = klist.begin(); it != klist.end(); ++it)
{
int val = (*it).toInt();
keys.append(val);
}
}
else if(tag == "keyswitches")
{
QStringList klist = ((QString)xml.s2()).split(QString(" "), QString::SkipEmptyParts);
for (QStringList::Iterator it = klist.begin(); it != klist.end(); ++it)
{
int val = (*it).toInt();
keyswitches.append(val);
}
}
break;
case Xml::TagEnd:
if (tag == "Patch")
return;
default:
break;
}
}
}
示例5: createFromXml
void MindGlobalCircuitRegionDef::createFromXml( Xml xml ) {
id = xml.getAttribute( "id" );
role = xml.getAttribute( "role" );
}
示例6: switch
void CtrlList::read(Xml& xml)
{
QLocale loc = QLocale::c();
bool ok;
for (;;)
{
Xml::Token token = xml.parse();
const QString& tag = xml.s1();
switch (token)
{
case Xml::Error:
case Xml::End:
return;
case Xml::Attribut:
if (tag == "id")
{
//_id = xml.s2().toInt();
_id = loc.toInt(xml.s2(), &ok);
if (!ok)
{
printf("CtrlList::read failed reading _id string: %s\n", xml.s2().toLatin1().constData());
initColor(0); //Set the default color if we have an error
}
else {
initColor(_id);
}
}
else if (tag == "cur")
{
//_curVal = xml.s2().toDouble();
_curVal = loc.toDouble(xml.s2(), &ok);
if (!ok)
printf("CtrlList::read failed reading _curVal string: %s\n", xml.s2().toLatin1().constData());
}
else if(tag == "visible")
{
_visible = (bool)xml.s2().toInt();
}
else if(tag == "color")
{
;//xml.skip(tag);
}
else
printf("unknown tag %s\n", tag.toLatin1().constData());
break;
case Xml::Text:
{
// Changed by Tim. Users in some locales reported corrupt reading,
// because of the way floating point is represented (2,3456 not 2.3456).
/*
QByteArray ba = tag.toLatin1();
const char* s = ba;.constData();
int frame;
double val;
for (;;) {
char* endp;
while (*s == ' ' || *s == '\n')
++s;
if (*s == 0)
break;
frame = strtol(s, &endp, 10);
s = endp;
while (*s == ' ' || *s == '\n')
++s;
val = strtod(s, &endp);
add(frame, val);
s = endp;
++s;
}
*/
// Added by Tim. p3.3.6
//printf("CtrlList::read tag:%s\n", tag.toLatin1().constData());
int len = tag.length();
int frame;
double val;
int i = 0;
for (;;)
{
while (i < len && (tag[i] == ',' || tag[i] == ' ' || tag[i] == '\n'))
++i;
if (i == len)
break;
QString fs;
while (i < len && tag[i] != ' ')
{
fs.append(tag[i]);
++i;
}
if (i == len)
break;
// Works OK, but only because if current locale fails it falls back on 'C' locale.
// So, let's skip the fallback and force use of 'C' locale.
//frame = fs.toInt(&ok);
frame = loc.toInt(fs, &ok);
//.........这里部分代码省略.........
示例7: writeProperties
void TextLine::writeProperties(Xml& xml, const TextLine* proto) const
{
if (_beginHook) {
if (proto == 0 || proto->beginHookHeight() != _beginHookHeight)
xml.tag("beginHookHeight", _beginHookHeight.val());
if (proto == 0 || proto->beginHookType() != _beginHookType)
xml.tag("beginHookType", int(_beginHookType));
}
if (_endHook) {
if (proto == 0 || proto->endHookHeight() != _endHookHeight)
xml.tag("endHookHeight", _endHookHeight.val());
if (proto == 0 || proto->endHookType() != _endHookType)
xml.tag("endHookType", int(_endHookType));
}
if (proto == 0 || proto->lineWidth() != _lineWidth)
xml.tag("lineWidth", _lineWidth.val());
if (proto == 0 || proto->lineStyle() != _lineStyle)
xml.tag("lineStyle", _lineStyle);
if (proto == 0 || proto->lineColor() != _lineColor)
xml.tag("lineColor", _lineColor);
if (proto == 0 || proto->beginTextPlace() != _beginTextPlace)
xml.pTag("beginTextPlace", _beginTextPlace);
if (proto == 0 || proto->continueTextPlace() != _continueTextPlace)
xml.pTag("continueTextPlace", _continueTextPlace);
SLine::writeProperties(xml);
if (_beginText) {
xml.stag("beginText");
_beginText->writeProperties(xml);
xml.etag();
}
if (_continueText) {
xml.stag("continueText");
_continueText->writeProperties(xml);
xml.etag();
}
if (_beginSymbol != -1) {
xml.tag("beginSymbol", Sym::id2name(_beginSymbol));
xml.tag("beginSymbolOffset", _beginSymbolOffset);
}
if (_continueSymbol != -1) {
xml.tag("continueSymbol", Sym::id2name(_continueSymbol));
xml.tag("continueSymbolOffset", _continueSymbolOffset);
}
if (_endSymbol != -1) {
xml.tag("endSymbol", Sym::id2name(_endSymbol));
xml.tag("endSymbolOffset", _endSymbolOffset);
}
}
示例8: fileOpen
void LOS::importPartToTrack(QString& filename, unsigned tick, Track* track)
{
bool popenFlag = false;
FILE* fp = fileOpen(this, filename, ".mpt", "r", popenFlag, false, false);
if (fp)
{
Xml xml = Xml(fp);
bool firstPart = true;
int posOffset = 0;
int notDone = 0;
int done = 0;
bool end = false;
song->startUndo();
for (;;)
{
Xml::Token token = xml.parse();
const QString& tag = xml.s1();
switch (token)
{
case Xml::Error:
case Xml::End:
end = true;
break;
case Xml::TagStart:
if (tag == "part")
{
// Read the part.
Part* p = 0;
p = readXmlPart(xml, track);
// If it could not be created...
if (!p)
{
// Increment the number of parts not done and break.
++notDone;
break;
}
// Increment the number of parts done.
++done;
if (firstPart)
{
firstPart = false;
posOffset = tick - p->tick();
}
p->setTick(p->tick() + posOffset);
p->setColorIndex(track->getDefaultPartColor());
audio->msgAddPart(p, false);
}
else
xml.unknown("LOS::importPartToTrack");
break;
case Xml::TagEnd:
break;
default:
end = true;
break;
}
if (end)
break;
}
fclose(fp);
song->endUndo(SC_PART_INSERTED);
if (notDone)
{
int tot = notDone + done;
QMessageBox::critical(this, QString("LOS"),
QString().setNum(notDone) + (tot > 1 ? (tr(" out of ") + QString().setNum(tot)) : QString("")) +
(tot > 1 ? tr(" parts") : tr(" part")) +
tr(" could not be imported.\nLikely the track is the wrong type."));
}
return;
}
}
示例9: write
void NoteDot::write(Xml& xml) const
{
xml.stag(name());
Element::writeProperties(xml);
xml.etag();
}
示例10: write
void TextLine::write(Xml& xml) const
{
xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(id()));
writeProperties(xml);
xml.etag();
}
示例11: write
void StaffTypeTablature::write(Xml& xml, int idx) const
{
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
StaffType::writeProperties(xml);
xml.tag("durations", _genDurations);
xml.tag("durationFontName", _durationFontName);
xml.tag("durationFontSize", _durationFontSize);
xml.tag("durationFontY", _durationFontUserY);
xml.tag("fretFontName", _fretFontName);
xml.tag("fretFontSize", _fretFontSize);
xml.tag("fretFontY", _fretFontUserY);
xml.tag("linesThrough", _linesThrough);
xml.tag("onLines", _onLines);
xml.tag("timesig", _genTimesig);
xml.tag("upsideDown", _upsideDown);
xml.tag("useNumbers", _useNumbers);
xml.etag();
}
示例12: write
void Audio::write(Xml& xml) const
{
xml.stag("Audio");
xml.tag("path", _path);
xml.etag();
}
示例13: log
void Blaster::gotDoc4 ( void *state, TcpSocket *s){
StateBD *st=(StateBD *)state;
st->m_numUrlDocsReceived++;
if (!s) {
//Shouldn't happen, but still putting a checkpoint
log (LOG_WARN,"blaster: Got a null s in gotDoc4."
"Happened because ip could not be found for gigablast"
"server");
if (st->m_numUrlDocsReceived==st->m_numUrlDocsSent){
m_launched--;
// Free stateBD
freeStateBD(st);
}
return;
}
// bail if got cut off
if ( s->m_readOffset == 0 ) {
log("blasterDiff : lost the Request in gotDoc4");
if (st->m_numUrlDocsReceived==st->m_numUrlDocsSent){
m_launched--;
freeStateBD(st);
}
return;
}
char *reply = s->m_readBuf ;
int32_t size = s->m_readOffset;
HttpMime mime;
mime.set ( reply , size , NULL );
char *content = reply + mime.getMimeLen();
int32_t contentLen = size - mime.getMimeLen();
//int16_t csEnum = get_iana_charset(mime.getCharset(),
// mime.getCharsetLen());
/* if (csEnum == csUnknown)
log(LOG_DEBUG, "blaster: Unknown charset : %s", mime.getCharset());*/
Xml xml;
if (!xml.set(
content,
contentLen,
false,
0,
false,
TITLEREC_CURRENT_VERSION,
true, // setparents
0, // niceness
CT_XML )){
log(LOG_WARN,"blaster: Couldn't set XML Class in gotDoc4");
}
Links links;
Url *url=mime.getLocationUrl();
if (!links.set(0,//siterec xml
&xml,
url,
false,
NULL,
TITLEREC_CURRENT_VERSION,
0,
false,
NULL)){
log(LOG_WARN, "blaster: Coudn't set Links class in gotDoc4");
}
for (int32_t i=0;i<links.getNumLinks();i++){
char *ss=links.getLink(i);
char *p;
// This page *should* always be a gigablast page. So not adding
// checks for msn or yahoo or google page.
p=strstr(ss,"google.");
if(p) continue;
p=strstr(ss,"cache:"); //googles cache page
if(p) continue;
p= strstr(ss,"gigablast.");
if(p) continue;
p= strstr(ss,"web.archive.org");//older copies on gigablast
if(p) continue;
p= strstr(ss,"search.yahoo.com");//from gigablast search
if(p) continue;
p= strstr(ss,"search.msn.com");//from gigablast search
if(p) continue;
p= strstr(ss,"s.teoma.com");//from gigablast search
if(p) continue;
p= strstr(ss,"search.dmoz.org");//from gigablast search
if(p) continue;
p= strstr(ss,"www.answers.com");//from gigablast search
if(p) continue;
if (m_verbose)
log(LOG_WARN,"blaster: Link Present on server2=%s",ss);
}
// So if one of the links that is returned is the exact url,
// then we know that the url is present.So get the url from the
// mime, search for it in the links that are returned.
char tmp[1024];
char *sendBuf=s->m_sendBuf;
char *p1,*p2;
// First get the Host, which is the domain. Since socket s is going to
// be useless after this function, changing m_sendBuf instead of using
// more space
p1=strstr(sendBuf,"%3A");
//.........这里部分代码省略.........
示例14: write
void PageFormat::write(Xml& xml) const
{
xml.stag("page-layout");
// convert inch to 1/10 spatium units
// 20 - font design size in point
// SPATIUM = 20/4
// qreal t = 10 * PPI / (20 / 4);
qreal t = 2 * PPI;
xml.tag("page-height", _size.height() * t);
xml.tag("page-width", _size.width() * t);
const char* type = "both";
if (_twosided) {
type = "even";
xml.stag(QString("page-margins type=\"%1\"").arg(type));
xml.tag("left-margin", evenLeftMargin() * t);
xml.tag("right-margin", evenRightMargin() * t);
xml.tag("top-margin", evenTopMargin() * t);
xml.tag("bottom-margin", evenBottomMargin() * t);
xml.etag();
type = "odd";
}
xml.stag(QString("page-margins type=\"%1\"").arg(type));
xml.tag("left-margin", oddLeftMargin() * t);
xml.tag("right-margin", oddRightMargin() * t);
xml.tag("top-margin", oddTopMargin() * t);
xml.tag("bottom-margin", oddBottomMargin() * t);
xml.etag();
xml.etag();
}
示例15: writeProperties
void DurationElement::writeProperties(Xml& xml) const
{
Element::writeProperties(xml);
if (tuplet())
xml.tag("Tuplet", tuplet()->id());
}