void EventTemplateDataXmlLogger::outputEntity(std::ostream& out, const LinguisticAnalysisStructure::AnalysisGraph* graph, LinguisticGraphVertex v, const AnnotationData* annotationData) const { LinguisticAnalysisStructure::Token* token=get(vertex_token, *(graph->getGraph()), v); if (token==0) { LOGINIT("LP::EventAnalysis"); LWARN << "EventTemplateDataXmlLogger: no token for vertex " << v; return; } out << " <entityOccurrence" << " pos=\"" << token->position() << "\"" << " len=\"" << token->length() << "\""; string str(""),norm(""); str=xmlString(Common::Misc::limastring2utf8stdstring(token->stringForm())); // check if vertex corresponds to a specific entity found std::set< AnnotationGraphVertex > matches = annotationData->matches(graph->getGraphId(),v,"annot"); for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin(); it != matches.end(); it++) { AnnotationGraphVertex vx=*it; if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity"))) { const SpecificEntityAnnotation* se = annotationData->annotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")). pointerValue<SpecificEntityAnnotation>(); const Automaton::EntityFeatures& features=se->getFeatures(); for (Automaton::EntityFeatures::const_iterator featureItr=features.begin(),features_end=features.end(); featureItr!=features_end; featureItr++) { if (featureItr->getName()=="value") { norm=xmlString(featureItr->getValueString()); } } } } if (! str.empty()) { out << " string=\"" << str << "\""; out << " norm=\"" << norm << "\""; out << ">" << str ; } out << "</entityOccurrence>" << endl; }
void Xml::tag(const QString& name, QVariant data) { QString ename(name.split(' ')[0]); putLevel(); switch(data.type()) { case QVariant::Bool: case QVariant::Char: case QVariant::Int: case QVariant::UInt: *this << "<" << name << ">"; *this << data.toInt(); *this << "</" << ename << ">\n"; break; case QVariant::Double: *this << "<" << name << ">"; *this << data.value<double>(); *this << "</" << ename << ">\n"; break; case QVariant::String: *this << "<" << name << ">"; *this << xmlString(data.value<QString>()); *this << "</" << ename << ">\n"; break; case QVariant::Color: { QColor color(data.value<QColor>()); *this << QString("<%1 r=\"%2\" g=\"%3\" b=\"%4\"/>\n").arg(name).arg(color.red()).arg(color.green()).arg(color.blue()); } break; case QVariant::Rect: { QRect r(data.value<QRect>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::RectF: { QRectF r(data.value<QRectF>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::PointF: { QPointF p(data.value<QPointF>()); *this << QString("<%1 x=\"%2\" y=\"%3\"/>\n").arg(name).arg(p.x()).arg(p.y()); } break; case QVariant::SizeF: { QSizeF p(data.value<QSizeF>()); *this << QString("<%1 w=\"%2\" h=\"%3\"/>\n").arg(name).arg(p.width()).arg(p.height()); } break; default: printf("Xml::tag: unsupported type %d\n", data.type()); // abort(); break; } }
string Node::XMLString() const { std::ostringstream stream; StreamOutputBuffer buf(stream); xmlNodeDumpOutput(buf, _xml->doc, _xml, 0, 0, nullptr); return xmlString(stream.str().c_str()); }
QString Xml::xmlString(const QString& s) { QString escaped; escaped.reserve(s.size()); for (int i = 0; i < s.size(); ++i) { ushort c = s.at(i).unicode(); escaped += xmlString(c); } return escaped; }
string Node::XMLString() const { std::ostringstream stream; StreamOutputBuffer buf(stream); xmlNodeDumpOutput(buf.xmlBuffer(), _xml->doc, _xml, 0, 1, "UTF-8"); buf.flush(); return xmlString(stream.str().c_str()); }
bool sensorsFromURDF(const std::string & urdfFilename, const iDynTree::Model & undirectedTree, SensorsList & sensors) { std::ifstream ifs(urdfFilename.c_str()); std::string xmlString( (std::istreambuf_iterator<char>(ifs) ), (std::istreambuf_iterator<char>() ) ); return sensorsFromURDFString(xmlString,undirectedTree,sensors); }
void podcast::xmlParse() { //time variable for added column in db if(xml.size() > 0) { QString xmlString(xml); QXmlStreamReader readXml(xmlString); QString title, fileName; QUrl url; QDateTime currentDateTime = QDateTime::currentDateTime(); QDateTime datePublished; QString datePublishedStr; QString datePublishedMonthM; episode *tempEpisode; while(readXml.atEnd() == false && readXml.hasError() == false) { readXml.readNext(); if(readXml.isStartElement() == true) { if(readXml.name() == "title") { title = readXml.readElementText(); } else if(readXml.name() == "pubDate") { //fixes months datePublishedStr = readXml.readElementText(); datePublishedMonthM = FixMonth(datePublishedStr.mid(8, 3)); datePublishedStr = datePublishedStr.mid(5, 20); datePublishedStr = datePublishedStr.mid(0,2) + " " + datePublishedMonthM + " " + datePublishedStr.mid(7,13); datePublished = QDateTime::fromString(datePublishedStr, "dd M yyyy hh:mm:ss"); } else if(readXml.name() == "enclosure") { QXmlStreamAttributes attrib = readXml.attributes(); QString urlStr = attrib.value("url").toString(); url = QUrl(urlStr); QFileInfo fileInfo(url.path()); fileName = fileInfo.fileName(); } } else { if(readXml.name() == "item") { tempEpisode = new episode(0, id, title, fileName, url, false, currentDateTime, datePublished); episodes.append(tempEpisode); } } } qDebug() << episodes.size(); podcast::xmlAddToDB(); } }
void Xml::tag(const QString& name, QVariant data) { QString ename(name.split(' ')[0]); putLevel(); switch(data.type()) { case QVariant::Bool: case QVariant::Char: case QVariant::Int: case QVariant::UInt: *this << "<" << name << ">"; *this << data.toInt(); *this << "</" << ename << ">\n"; break; case QVariant::Double: *this << "<" << name << ">"; *this << data.value<double>(); *this << "</" << ename << ">\n"; break; case QVariant::String: *this << "<" << name << ">"; *this << xmlString(data.value<QString>()); *this << "</" << ename << ">\n"; break; case QVariant::Color: { QColor color(data.value<QColor>()); *this << QString("<%1 r=\"%2\" g=\"%3\" b=\"%4\" a=\"%5\"/>\n") .arg(name).arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); } break; case QVariant::Rect: { const QRect& r(data.value<QRect>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::RectF: { const QRectF& r(data.value<QRectF>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::PointF: { const QPointF& p(data.value<QPointF>()); *this << QString("<%1 x=\"%2\" y=\"%3\"/>\n").arg(name).arg(p.x()).arg(p.y()); } break; case QVariant::SizeF: { const QSizeF& p(data.value<QSizeF>()); *this << QString("<%1 w=\"%2\" h=\"%3\"/>\n").arg(name).arg(p.width()).arg(p.height()); } break; default: { const char* type = data.typeName(); if (strcmp(type, "Ms::Spatium") == 0) { *this << "<" << name << ">"; *this << data.value<Spatium>().val(); *this << "</" << ename << ">\n"; } else if (strcmp(type, "Ms::Fraction") == 0) { const Fraction& f = data.value<Fraction>(); *this << QString("<%1>%2/%3</%1>\n").arg(name).arg(f.numerator()).arg(f.denominator()); } else { qFatal("Xml::tag: unsupported type %d %s", data.type(), type); } } break; } }
// The following function is executed concurrently with other threads void processXmlRequest(ThreadParams *params) { PFC *pfc = params->pfc; get_mip()->IOBASE=64; int bytes_per_big = (MIRACL/8)*(get_mip()->nib-1); char buffer[BUF_SIZE]; memset(buffer, 0, BUF_SIZE); cout << endl << "------------------------------" << endl; cout << "sockfd: " << params->sockfd << endl; // Read out socket. int n = recv(params->sockfd, buffer, sizeof(buffer),0); if (n < 0) error("ERROR reading from socket"); //string ext_pvt_key = extract(buffer, s, pfc); string xmlString(buffer); string messageType = getMessageType(xmlString); cout << "messageType: " << messageType << endl; cout << "Received XML Message:" << endl << buffer << endl; string xmlResult; if(messageType.compare("encryption")==0) { PlaintextMessage plainMes = getPlaintextMessage(xmlString, pfc); cout << "plainMes.getMessage()" << endl << plainMes.getMessage() << endl; EncryptedMessage encMes = plainMes.encrypt(params->P, params->Ppub, pfc); string strEncMes = encMes.getMessage(); cout << endl << "Encryption result:" << endl << strEncMes << endl; //strcpy(buffer, ext_pvt_key.c_str()); xmlResult = encodeToXmlResult(strEncMes); //string bye_mes("<?xml version='1.0' encoding='UTF-8' standalone='no'?><scramble><result>My custom result here</result></scramble>"); strcpy(buffer, xmlResult.c_str()); n = send(params->sockfd, buffer, sizeof(buffer), 0); if (n < 0) error("ERROR writing to socket"); } else if(messageType.compare("bye")==0) { //*closeSocket = true; } else if(messageType.compare("decryption")==0) { EncryptedMessage encMes = getEncryptedMessage(xmlString); cout << "encMes.getMessage()" << endl << encMes.getMessage() << endl; PlaintextMessage plainMes = encMes.decrypt(params->P, params->Ppub, params->D, params->pfc); string strPlainMes = plainMes.getMessage(); cout << endl << "Decryption result:" << endl << strPlainMes << endl; string url = getUrl(xmlString); xmlResult = encodeToXmlResult(strPlainMes, url); strcpy(buffer, xmlResult.c_str()); n = send(params->sockfd, buffer, sizeof(buffer), 0); if (n < 0) error("ERROR writing to socket"); } cout << "------------------------------" << endl; close(params->sockfd); delete params; }
void XmlWriter::tag(const QString& name, QVariant data) { QString ename(name.split(' ')[0]); putLevel(); switch(data.type()) { case QVariant::Bool: case QVariant::Char: case QVariant::Int: case QVariant::UInt: *this << "<" << name << ">"; *this << data.toInt(); *this << "</" << ename << ">\n"; break; case QVariant::Double: *this << "<" << name << ">"; *this << data.value<double>(); *this << "</" << ename << ">\n"; break; case QVariant::String: *this << "<" << name << ">"; *this << xmlString(data.value<QString>()); *this << "</" << ename << ">\n"; break; case QVariant::Color: { QColor color(data.value<QColor>()); *this << QString("<%1 r=\"%2\" g=\"%3\" b=\"%4\" a=\"%5\"/>\n") .arg(name).arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); } break; case QVariant::Rect: { const QRect& r(data.value<QRect>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::RectF: { const QRectF& r(data.value<QRectF>()); *this << QString("<%1 x=\"%2\" y=\"%3\" w=\"%4\" h=\"%5\"/>\n").arg(name).arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } break; case QVariant::PointF: { const QPointF& p(data.value<QPointF>()); *this << QString("<%1 x=\"%2\" y=\"%3\"/>\n").arg(name).arg(p.x()).arg(p.y()); } break; case QVariant::SizeF: { const QSizeF& p(data.value<QSizeF>()); *this << QString("<%1 w=\"%2\" h=\"%3\"/>\n").arg(name).arg(p.width()).arg(p.height()); } break; default: { const char* type = data.typeName(); if (strcmp(type, "Ms::Spatium") == 0) { *this << "<" << name << ">"; *this << data.value<Spatium>().val(); *this << "</" << ename << ">\n"; } else if (strcmp(type, "Ms::Fraction") == 0) { const Fraction& f = data.value<Fraction>(); *this << QString("<%1>%2/%3</%1>\n").arg(name).arg(f.numerator()).arg(f.denominator()); } else if (strcmp(type, "Ms::Direction") == 0) *this << QString("<%1>%2</%1>\n").arg(name).arg(data.value<Direction>().toString()); else if (strcmp(type, "Ms::Align") == 0) { Align a = Align(data.toInt()); const char* h; if (a & Align::HCENTER) h = "center"; else if (a & Align::RIGHT) h = "right"; else h = "left"; const char* v; if (a & Align::BOTTOM) v = "bottom"; else if (a & Align::VCENTER) v = "center"; else if (a & Align::BASELINE) v = "baseline"; else v = "top"; *this << QString("<%1>%2,%3</%1>\n").arg(name).arg(h).arg(v); } else { qFatal("XmlWriter::tag: unsupported type %d %s", data.type(), type); } } break; } }
Token Lexer::xmlAtomImpl() { mark=idx; switch (idx[0]) { case 0: compiler->syntaxError(lineno, SYNTAXERR_XML_EOI_IN_MARKUP); case '<': switch (idx[1]) { case '!': if (idx[2] == '[' && idx[3] == 'C' && idx[4] == 'D' && idx[5] == 'A' && idx[6] == 'T' && idx[7] == 'A' && idx[8] == '[') { idx += 9; return xmlMarkup(T_XmlCDATA); } if (idx[2] == '-' && idx[3] == '-') { idx += 4; return xmlMarkup(T_XmlComment); } compiler->syntaxError(lineno, SYNTAXERR_XML_INVALID_LEFTBANG); case '?': idx += 2; return xmlMarkup(T_XmlProcessingInstruction); case '/': idx += 2; return T_XmlLeftAngleSlash; default: idx += 1; return T_XmlLeftAngle; } case '/': if (idx[1] == '>') { idx += 2; return T_XmlSlashRightAngle; } compiler->syntaxError(lineno, SYNTAXERR_XML_INVALID_SLASH); case '>': idx += 1; return T_XmlRightAngle; case '{': idx += 1; return T_XmlLeftBrace; case '}': idx += 1; return T_XmlRightBrace; case '=': idx += 1; return T_XmlEquals; case ' ': case '\t': case '\r': case '\n': return xmlWhitespace(); case '"': case '\'': return xmlString(); default: if (isXmlNameStart(idx[0])) return xmlName(); else return xmlText(); } }