Trace::Trace( Writer &dout, const char *function_name, int line_mask, bool do_trace) : Traceback(function_name), m_diagWriter(dout), m_startCpuTime(0.0), m_startMemAlloc(0), m_lineMask(line_mask), m_do_trace(do_trace), m_flags((dout.isTracing() || (dout.shouldTrace(m_lineMask) && (s_traceListExists && (s_traceList.empty() || prefix_find(s_traceList, m_functionSpec))))) ? IN_TRACE_LIST : 0) { if (m_do_trace && (m_flags & IN_TRACE_LIST)) { m_diagWriter.incTraceDepth(); m_diagWriter.m(m_lineMask) << m_functionSpec << (std::uncaught_exception() ? " (throw unwinding) " : "") << push << dendl; if (dout.shouldPrint(LOG_TRACE_STATS)) { m_startCpuTime = sierra::Env::cpu_now(); m_startMemAlloc = stk::get_heap_used(); } } }
void ConsoleTools::listTypes(bool load, bool useNames){ Writer *writer = null; try{ writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput); ParserFactory pf(catalogPath); HRCParser *hrcParser = pf.getHRCParser(); fprintf(stderr, "\nloading file types...\n"); for(int idx = 0;; idx++){ FileType *type = hrcParser->enumerateFileTypes(idx); if (type == null) break; if (useNames){ writer->write(StringBuffer(type->getName())+"\n"); }else{ if (type->getGroup() != null){ writer->write(StringBuffer(type->getGroup()) + ": "); } writer->write(type->getDescription()); writer->write(DString("\n")); } if (load) type->getBaseScheme(); } delete writer; }catch(Exception &e){ delete writer; fprintf(stderr, "%s\n", e.getMessage()->getChars()); } }
virtual StringResultBase* Stringify(const ParseResultBase* parseResult) const { const JzonParseResult* pr = static_cast<const JzonParseResult*>(parseResult); JzonStringResult* sr = new JzonStringResult; Writer writer; writer.writeString(pr->root, sr->s); return sr; }
int main(int argc, char* argv[]) { String name, outputPath; if (argc < 2) { std::cout << "Invalid arguments" << std::endl; std::cout << std::endl; std::cout << "Usage: SPMBuild input_file [output_filename]" << std::endl; return -1; } String path = argv[1]; auto split = SplitString(path, "/\\"); name = split.back(); if (argc > 2) { outputPath = argv[2]; } else { outputPath = name.substr(0, name.size() - 4) + ".spm"; std::cout << "Output path not specified. Outputting to " << outputPath << std::endl; } Mesh* mesh = new Mesh(); mesh->LoadMesh(path); Writer* writer = new Writer(name, POSITION | NORMAL | UV | BINORMAL | TANGENT | JOINTWEIGHT | JOINTINDEX, mesh->m_Entries, mesh->m_BoneInfo); writer->Write(outputPath); return 0; }
void Command::Save (Writer &writer) const { // this will only get used if saved as XML (probably never) writer.Stream() << writer.ind() << "<Command " << "gcode=\"" << toGCode() << "\" />"; writer.Stream()<< std::endl; }
void Constraint::Save (Writer &writer) const { std::string encodeName = encodeAttribute(Name); writer.Stream() << writer.ind() << "<Constrain " << "Name=\"" << encodeName << "\" " << "Type=\"" << (int)Type << "\" "; if(this->Type==InternalAlignment) writer.Stream() << "InternalAlignmentType=\"" << (int)AlignmentType << "\" " << "InternalAlignmentIndex=\"" << InternalAlignmentIndex << "\" "; writer.Stream() << "Value=\"" << Value << "\" " << "First=\"" << First << "\" " << "FirstPos=\"" << (int) FirstPos << "\" " << "Second=\"" << Second << "\" " << "SecondPos=\"" << (int) SecondPos << "\" " << "Third=\"" << Third << "\" " << "ThirdPos=\"" << (int) ThirdPos << "\" " << "LabelDistance=\"" << LabelDistance << "\" " << "LabelPosition=\"" << LabelPosition << "\" " << "IsDriving=\"" << (int)isDriving << "\" " << "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" />" << std::endl; }
void stringify(Writer& writer, const std::vector<T>& v) { writer.StartArray(); for (const auto& e : v) { stringify(writer, e); } writer.EndArray(); }
int main(void) { char data = ' '; int id = 0; cout << "pid: " << getpid() << endl; cout << "digite id do reader: "; cin >> id; cout << "id = " << id << endl; Writer *wr = new Writer(id); signal(SIGCONT, sigusr); kill(id, SIGCONT); while (data != '.') { cout << "digite o char: "; cin >> data; wr->Write(data); } wr->~Writer(); }
bool write(Writer &w) const { MSS_BEGIN(bool); auto fix = 0u; //Copy of field is intentional for (Range field: fields) { auto write_field = [&](Writer &w1){ MSS_BEGIN(bool); if (!field.empty()) { w.text(field.front()); field.pop_front(); while (!field.empty()) { w.text(' '); w.text(field.front()); field.pop_front(); } } MSS_END(); }; MSS(w(fix, write_field)); ++fix; } MSS_END(); }
void Peer::onConnection(Exception& ex, Writer& writer,DataReader& parameters,DataWriter& response) { if(!connected) { _pWriter = &writer; // reset default protocol parameters _parameters.clear(); Parameters::ForEach forEach([this](const string& key,const string& value) { _parameters.setString(key,value); }); string buffer; _handler.iterate(String::Format(buffer,protocol,"."), forEach); ParameterWriter parameterWriter(_parameters); SplitWriter parameterAndResponse(parameterWriter,response); _handler.onConnection(ex, *this,parameters,parameterAndResponse); if (!ex) { (bool&)connected = ((Entities<Client>&)_handler.clients).add(*this); if (!connected) { ex.set(Exception::PROTOCOL, "Client ", Util::FormatHex(id, ID_SIZE, buffer), " exists already"); ERROR(ex.error()); _handler.onDisconnection(*this); } } if (!connected) { writer.abort(); _pWriter = NULL; } else { OnInitParameters::raise(_parameters); DEBUG("Client ",address.toString()," connection") } writer.open(); // open even if "ex" to send error messages! } else
static oc::result<void> _mtk_header_update_size(Writer &writer, File &file, uint64_t offset, uint32_t size) { uint32_t le32_size = mb_htole32(size); if (offset > SIZE_MAX - offsetof(MtkHeader, size)) { writer.set_fatal(); return MtkError::MtkHeaderOffsetTooLarge; } auto seek_ret = file.seek( static_cast<int64_t>(offset + offsetof(MtkHeader, size)), SEEK_SET); if (!seek_ret) { if (file.is_fatal()) { writer.set_fatal(); } return seek_ret.as_failure(); } auto ret = file_write_exact(file, &le32_size, sizeof(le32_size)); if (!ret) { if (file.is_fatal()) { writer.set_fatal(); } return ret.as_failure(); } return oc::success(); }
string WKTWriter::writeFormatted(const Geometry* geometry) { Writer sw; writeFormatted(geometry, true, &sw); return sw.toString(); }
int main(int argc, char* argv[]) { if (argc < 7) { usage(argv[0]); } std::string h5file = argv[1]; std::string immfile = argv[2]; std::string dataset = argv[3]; unsigned int buffer_count = atoi(argv[4]); unsigned int frames = atoi(argv[5]); unsigned int frames_per_buffer = atoi(argv[6]); BufferPool *pool = new BufferPool(buffer_count, 1024, 1024, frames_per_buffer); Queue<FrameBuffer*> *readconvert = new Queue<FrameBuffer*>(); Queue<FrameBuffer*> *convertwrite = new Queue<FrameBuffer*>(); Reader *reader = new Reader(h5file, dataset, 1024, 1024, frames, frames_per_buffer, pool, readconvert); Converter *converter = new Converter(readconvert, convertwrite, frames); Writer *writer = new Writer(immfile, convertwrite, pool, frames); writer->start(); converter->start(); reader->start(); reader->join(); converter->join(); writer->join(); printf("Done\n"); }
void produce_response(Writer& out, const int result) { out.write("{\"scans\":["); bool first = true; ScanEntry& entry = read_; while (!result && !wiced_rtos_pop_from_queue(&queue_, &entry, WICED_NEVER_TIMEOUT)) { if (entry.done) break; if (!*entry.ssid) continue; if (first) first = false; else write_char(out, ','); write_char(out, '{'); write_json_string(out, "ssid", entry.ssid); write_char(out, ','); write_json_int(out, "rssi", entry.rssi); write_char(out, ','); write_json_int(out, "sec", entry.security); write_char(out, ','); write_json_int(out, "ch", entry.channel); write_char(out, ','); write_json_int(out, "mdr", entry.max_data_rate); write_char(out, '}'); } out.write("]}"); wiced_rtos_deinit_queue(&queue_); }
void stringify(Writer& writer, const std::array<float, 4>& v) { writer.StartArray(); writer.Double(v[0]); writer.Double(v[1]); writer.Double(v[2]); writer.Double(v[3]); writer.EndArray(); }
void Serialize(Writer& writer) const { // This base class just write out name-value pairs, without wrapping within an object. writer.String("name"); writer.String(name_.c_str(), (SizeType)name_.length()); // Suppling length of string is faster. writer.String("age"); writer.Uint(age_); }
void MsgBuf::write_data(const std::vector<TradeMsg> messages, Writer& out) { for(std::vector<TradeMsg>::const_iterator it = messages.begin(); it != messages.end(); ++it) { out.save_binary((*it).get_type()); out.save_binary((*it).get_time()); out.save_binary((*it).get_len()); out.save_string((*it).get_msg()); } }
string WKTWriter::write(const Geometry* geometry) { Writer sw; writeFormatted(geometry, false, &sw); string res = sw.toString(); return res; }
void MatSerializableAdapter::writeTo(Writer& writer) const { assert(_cmat); writer.write("type", _cmat->type()); writer.write("cols", _cmat->cols); writer.write("rows", _cmat->rows); std::vector<double> data(_cmat->begin<double>(), _cmat->end<double>()); writer.write("data", data); }
void stringify(Writer& writer, const std::unordered_map<std::string, T>& m) { writer.StartObject(); for (const auto& p : m) { writer.Key(p.first.data(), static_cast<unsigned>(p.first.size())); stringify(writer, p.second); } writer.EndObject(); }
bool XSPF::write(const Entries &list) { Writer *writer = ioCtrl.rawPtr<Writer>(); const QString playlistPath = getPlaylistPath(writer->getUrl()); QByteArray buffer; QXmlStreamWriter xmlWriter(&buffer); xmlWriter.setAutoFormatting(true); xmlWriter.setAutoFormattingIndent(-1); xmlWriter.writeStartDocument(); xmlWriter.writeStartElement("playlist"); xmlWriter.writeStartElement("trackList"); for (const Entry &entry : list) { xmlWriter.writeStartElement("track"); if (entry.GID) startExtension(xmlWriter); QString url = entry.url; if (url.startsWith("file://") && url.mid(7, playlistPath.length()) == playlistPath) url.remove(0, playlistPath.length() + 7); xmlWriter.writeTextElement("location", url); if (!entry.name.isEmpty()) xmlWriter.writeTextElement("title", entry.name); if (entry.length >= 0.0) xmlWriter.writeTextElement("duration", QString::number(1000.0 * entry.length, 'f', 0)); if (entry.flags || entry.queue || entry.GID || entry.parent) { if (!entry.GID) startExtension(xmlWriter); if (entry.flags) xmlWriter.writeTextElement("f", QString::number(entry.flags)); if (entry.queue) xmlWriter.writeTextElement("q", QString::number(entry.queue)); if (entry.GID) xmlWriter.writeTextElement("g", QString::number(entry.GID)); if (entry.parent) xmlWriter.writeTextElement("p", QString::number(entry.parent)); xmlWriter.writeEndElement(); // extension } xmlWriter.writeEndElement(); // track } xmlWriter.writeEndElement(); // trackList xmlWriter.writeEndElement(); // playlist xmlWriter.writeEndDocument(); writer->write(buffer); return true; }
void TemplateParameterNodeList::Write(Writer& writer) { uint32_t n = static_cast<uint32_t>(templateParameterNodes.size()); writer.Write(n); for (uint32_t i = 0; i < n; ++i) { writer.Write(templateParameterNodes[i].get()); } }
void Skin::save (const gdx_cpp::files::FileHandle& skinFile) { String text = getJsonLoader(null).prettyPrint(this, true); Writer writer = skinFile.writer(false); try { writer.write(text); writer.close(); } catch (IOException ex) { } }
bool medDataReaderWriter::write(const QString& path,medAbstractData* data) { Writer dwriter = writer(path,data); if (!dwriter.isNull()) { dwriter->setData(data); dwriter->write(path); return true; } return false; }
/**Generic template for arrays. Writes a JSON array, using write_json for each element. * * iterable may be any value that can be used with the C++11 range-based for loop. */ template<typename T> void write_json_array(Writer &writer, const T &iterable) { writer.start_arr(); for (auto &i : iterable) { writer.value(i); } writer.end_arr(); }
void SpawnPoint::save(Writer& writer){ writer.start_list("spawnpoint"); writer.write("x",pos.x); writer.write("y",pos.y); writer.write("name",name,false); writer.end_list("spawnpoint"); }
string WKTWriter::write(const Geometry *geometry) { Writer sw; // try { writeFormatted(geometry,false,&sw); // } catch (const IOException ex) { // Assert::shouldNeverReachHere(); // } string res=sw.toString(); return res; }
void TemplateParameterNode::Write(Writer& writer) { writer.Write(id.get()); bool hasDefaultTemplateArgument = defaultTemplateArgument != nullptr; writer.Write(hasDefaultTemplateArgument); if (hasDefaultTemplateArgument) { writer.Write(defaultTemplateArgument.get()); } }
//try to add questionsheet void QuestionSheetEditor::on_buttonBox_accepted() { questionsheet->setQuestions(questions); Writer writer; QString jsonRequest = writer.writeQuestionSheet(questionsheet); HttpsClient *httpsClient = new HttpsClient(this); httpsClient->setTask("addSheet"); httpsClient->setJsonRequest(jsonRequest); httpsClient->execute(); }
Writer* demoWriterCreator(Stage& prev, const Options& options) { s_demoflag = options.getOption("flag").getValue<int>(); Options optsW; optsW.add("filename", "temp.las", "file to write to"); Writer* writer = new pdal::drivers::las::Writer(optsW); writer->setInput(&prev); return writer; }