//Print method void BookRecord::print()const { string tempTitle, tempAuthor, tempPublisher; if(getTitle().length() > 22) tempTitle = getTitle().substr(0,22); else tempTitle = getTitle(); if(getAuthor().length() > 22) tempAuthor = getAuthor().substr(0,22); else tempAuthor = getAuthor(); if(getPublisher().length() > 22) tempPublisher = getPublisher().substr(0,22); else tempPublisher = getPublisher(); //Re-initialize our output settings cout.setf(ios::left, ios::adjustfield); cout << setfill(' '); //Print the title, author, and publisher cout << setw(22) << tempTitle << " "; cout << setw(22) << tempAuthor << " "; cout << setw(22) << tempPublisher << " "; //Prints the ISBN number cout.setf(ios::right, ios::adjustfield); cout << setw(10) << setfill('0') << getISBN(); cout << setfill(' ') << " "; }
int DocumentDatabase::insertDocument(sqlite3* db, int styleID, std::string title, std::string publishDate) { std::string str = "INSERT INTO Documents (StyleID,Title,PublishDate) VALUES('" + std::to_string(styleID) + "','" + title + "','" + publishDate + "');"; int DocID = insert(db, str); addToDocumentList(DocID, getAuthor(styleID), title, publishDate, 0, 0); return DocID; }
TEST_F(TestSaveLoadSchema, SchemaAuthor) { const umf::umf_string TEST_SCHEMA_WITH_AUTHOR_NAME = "Schema with author"; const umf::umf_string TEST_AUTHOR_NAME = "< the \"Author\" >"; { umf::MetadataStream stream; auto schemaWithAuthor = std::shared_ptr<umf::MetadataSchema>(new umf::MetadataSchema(TEST_SCHEMA_WITH_AUTHOR_NAME, TEST_AUTHOR_NAME)); auto desc1 = std::shared_ptr<umf::MetadataDesc>(new umf::MetadataDesc(TEST_DESC_NAME, umf::Variant::type_string)); schemaWithAuthor->add(desc1); stream.addSchema(schema); stream.addSchema(schemaWithAuthor); stream.saveTo(SCHEMA_TEST_FILE); stream.close(); } { umf::MetadataStream stream; stream.open(SCHEMA_TEST_FILE, umf::MetadataStream::ReadOnly); auto schemaNames = stream.getAllSchemaNames(); ASSERT_EQ(2u, schemaNames.size()); for (auto schema = schemaNames.begin(); schema != schemaNames.end(); schema++) { auto desc = stream.getSchema(*schema); auto author = desc->getAuthor(); if(*schema == TEST_SCHEMA_WITH_AUTHOR_NAME) ASSERT_EQ(author, TEST_AUTHOR_NAME); else ASSERT_EQ(author, ""); } } }
void PFPFile::list() const /*!\brief Chunks auf STDOUT auflisten * * Diese Funktion listet die Namen und Größen aller Chunks auf STDOUT aus. * * \since Version 6.1.0 */ { printf("PFP-File Version 3 ============================================\n"); printf("ID: %s, Version: %i.%i, Komprimierung: ",(const char*)id,mainversion,subversion); switch(comp) { case 0: printf ("keine\n"); break; case 1: printf ("Zlib\n"); break; case 2: printf ("Bzip2\n"); break; default: printf ("unbekannt\n"); break; } String Tmp; Tmp=getName(); if (Tmp.notEmpty()) printf("Name: %s\n",(const char*)Tmp); Tmp=getAuthor(); if (Tmp.notEmpty()) printf("Author: %s\n",(const char*)Tmp); Tmp=getDescription(); if (Tmp.notEmpty()) printf("Description: %s\n",(const char*)Tmp); Tmp=getCopyright(); if (Tmp.notEmpty()) printf("Copyright: %s\n",(const char*)Tmp); Iterator it; Chunks.reset(it); printf ("\nChunks:\n"); while(Chunks.getNext(it)) { PFPChunk *chunk=it.value(); printf (" %s: %zu Bytes\n",(const char*)chunk->chunkname,chunk->chunksize); } printf("===============================================================\n"); }
LanguageResult ObjectsReputation::acceptable(shared_ptr<IPortalDatabase> database) const { LanguageResult result = EntryBase::acceptable(database); if(result.empty() == false) return result; if(reference->empty()) return LanguageResult("reference_required"); if(IPortalDatabase::getUserReputationID(getAuthor(), reference) != id) return LanguageResult("id_mismatch"); if(getAuthor() == reference) return LanguageResult("autovalutation"); if(score < OS_REPUTATION_MIN || score > OS_REPUTATION_MAX) return LanguageResult("score_outofrange"); return LanguageResult(); }
//Displas Book`s detail void book::display(){ cout<<"\nBook`s Detail:-"; cout<<"\nItem ID:"<<getID(); cout<<"\nTitle:"<<getTitle(); cout<<"\nPrice:RM"<<getPrice(); cout<<"\nQuantity:"<<getQuantity(); cout<<"\nAuthor:"<<getAuthor(); cout<<"\nPublisher:"<<getPublisher(); cout<<"\nISBN:"<<getISBN(); cout<<endl; }
void Printer::heading() { fillDisplay('=', 61); cout << endl << "\t\t" << getTitle() << ", " << getVersion() << ", " << getYear() << endl << endl << "This program lets you construct pitch sets, rows or matrixes" << endl << "from input, then display them to the console or outputs them" << endl << "to a file in your current working directory. Please choose" << endl << "from the options below." << endl << endl << "** This program can be downloaded and used freely but is" << endl << "provided with no warranties." << endl << endl << right << setfill(' ') << setw(46) << "by " << getAuthor() << endl << setw(60) << getEmail() << endl << setw(60) << getWeb() << endl; fillDisplay('=', 61); }
BOOL AP_Win32Dialog_Annotation::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/) { const XAP_StringSet * pSS = m_pApp->getStringSet(); setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_Annotation_Title)); // localize controls _DSX(BTN_OK, DLG_OK); _DSX(BTN_CANCEL, DLG_Cancel); _DS(TEXT_TITLE, DLG_Annotation_Title_LBL); _DS(TEXT_AUTHOR, DLG_Annotation_Author_LBL); _DS(TEXT_DESCRIPTION, DLG_Annotation_Description_LBL); _set_text(AP_RID_DIALOG_ANNOTATION_EDIT_TITLE, getTitle ()); _set_text(AP_RID_DIALOG_ANNOTATION_EDIT_AUTHOR, getAuthor ()); _set_text(AP_RID_DIALOG_ANNOTATION_EDIT_DESCRIPTION, getDescription ()); centerDialog(); return 1; // 1 == we did not call SetFocus() }
bool ObjectsPrivateMessage::validate(shared_ptr<IPortalDatabase> database) const { if(EntryBase::validate(database) == false) return false; // La chiave di criptazione deve essere valida if(session->empty()) return false; // Nota: un messaggio senza oggetto valido if(content->empty()) return false; // Verifica che il destinatario sia valido if(adressee->empty()) return false; // Verifica che il destinatario non coincida col mittente if(adressee == getAuthor()) return false; return true; }
static void GUINewMode(void) { int Max, Sel; sprintf(modetext,"0x%08lx", getAudioMode()); infoargs[0] = modetext; infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); sprintf(drivertext, "Devs:AHI/%s.audio", getDriver()); infoargs[4] = drivertext; infoargs[5] = getVersion(); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, ~0, TAG_DONE); if(infolist) FreeBrowserNodes2(infolist); infolist = BrowserNodes2(infotexts, infoargs); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, infolist, TAG_DONE); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); MySetGadgetAttrs(Window_Objs[ACTID_FREQ], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 1); Sel = min(Max, state.ChannelsSelected); MySetGadgetAttrs(Window_Objs[ACTID_CHANNELS], SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_MONVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); MySetGadgetAttrs(Window_Objs[ACTID_GAIN], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); MySetGadgetAttrs(Window_Objs[ACTID_INPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. MySetGadgetAttrs(Window_Objs[SHOWID_FREQ], GA_Text, getFreq(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_CHANNELS], GA_Text, getChannels(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTVOL], GA_Text, getOutVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_MONVOL], GA_Text, getMonVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_GAIN], GA_Text, getGain(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_INPUT], GA_Text, getInput(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTPUT], GA_Text, getOutput(), TAG_DONE ); }
static void GUINewMode(void) { int Max, Sel; infoargs[0] = (char *) getAudioMode(); infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); infoargs[4] = getDriver(); infoargs[5] = getVersion(); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MODE], window, NULL, INFO_TextFormat, (ULONG) "0x%08lx\n" "%s\n" "%s\n" "%s\n" "Devs:AHI/%s.audio\n" "%s", INFO_Args, (ULONG) &infoargs, TAG_DONE ); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_FREQ], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_CHANNELS], window, NULL, SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_MONVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_GAIN], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_INPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_FREQ], window, NULL, INFO_TextFormat, (ULONG) getFreq(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_CHANNELS], window, NULL, INFO_TextFormat, (ULONG) getChannels(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTVOL], window, NULL, INFO_TextFormat, (ULONG) getOutVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MONVOL], window, NULL, INFO_TextFormat, (ULONG) getMonVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_GAIN], window, NULL, INFO_TextFormat, (ULONG) getGain(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_INPUT], window, NULL, INFO_TextFormat, (ULONG) getInput(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTPUT], window, NULL, INFO_TextFormat, (ULONG) getOutput(), TAG_DONE ); }
static void GUINewMode(void) { int Max, Sel, Dis; char* buffer; char* arg1 = getRecord(); char* arg2 = getAuthor(); char* arg3 = getCopyright(); char* arg4 = getDriver(); char* arg5 = getVersion(); char* arg6 = getAnnotation(); buffer = AllocVec( strlen( arg1 ) + strlen( arg2 ) + strlen( arg3 ) + strlen( arg4 ) + strlen( arg5 ) + strlen( arg6 ) + 128, MEMF_ANY); if( buffer != NULL ) { sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s\n%s", getAudioMode(), arg1, arg2, arg3, arg4, arg5, arg6 ); set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer); FreeVec(buffer); } Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); Dis = Max==0; set(MUIFreq, MUIA_Disabled, Dis); if( !Dis ) { set(MUIFreq, MUIA_Numeric_Max, Max); set(MUIFreq, MUIA_Numeric_Value, Sel); } set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq()); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); Dis = (Max == 0 || Max == 1) || state.ChannelsDisabled; set(MUIChannels, MUIA_Disabled, Dis); if( !Dis ) { set(MUIChannels, MUIA_Numeric_Max, Max); set(MUIChannels, MUIA_Numeric_Value, Sel); } set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels()); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); Dis = Max==0; set(MUIOutvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutvol, MUIA_Numeric_Max, Max); set(MUIOutvol, MUIA_Numeric_Value, Sel); } set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol()); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); Dis = Max==0; set(MUIMonvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIMonvol, MUIA_Numeric_Max, Max); set(MUIMonvol, MUIA_Numeric_Value, Sel); } set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol()); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); Dis = Max==0; set(MUIGain, MUIA_Disabled, Dis); if( !Dis ) { set(MUIGain, MUIA_Numeric_Max, Max); set(MUIGain, MUIA_Numeric_Value, Sel); } set(MUILGain, MUIA_Text_Contents, (ULONG) getGain()); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); Dis = Max==0; set(MUIInput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIInput, MUIA_Numeric_Max, Max); set(MUIInput, MUIA_Numeric_Value, Sel); } set(MUILInput, MUIA_Text_Contents, (ULONG) getInput()); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); Dis = Max==0; set(MUIOutput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutput, MUIA_Numeric_Max, Max); set(MUIOutput, MUIA_Numeric_Value, Sel); } set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput()); set(MUIPlay, MUIA_Disabled, getAudioMode() == AHI_INVALID_ID); }
UT_Error IE_Exp_EPUB::package() { GsfOutput* opf = gsf_outfile_new_child(GSF_OUTFILE(m_oebps), "book.opf", FALSE); if (opf == NULL) { UT_DEBUGMSG(("Can`t create book.opf\n")); return UT_ERROR; } GsfXMLOut* opfXml = gsf_xml_out_new(opf); // <package> gsf_xml_out_start_element(opfXml, "package"); if (m_exp_opt.bEpub2) { gsf_xml_out_add_cstr(opfXml, "version", "2.0"); } else { gsf_xml_out_add_cstr(opfXml, "version", "3.0"); } gsf_xml_out_add_cstr(opfXml, "xmlns", OPF201_NAMESPACE); gsf_xml_out_add_cstr(opfXml, "unique-identifier", "BookId"); if (!m_exp_opt.bEpub2) { gsf_xml_out_add_cstr(opfXml, "profile", EPUB3_PACKAGE_PROFILE); gsf_xml_out_add_cstr(opfXml, "xml:lang", getLanguage().c_str()); } // <metadata> gsf_xml_out_start_element(opfXml, "metadata"); gsf_xml_out_add_cstr(opfXml, "xmlns:dc", DC_NAMESPACE); gsf_xml_out_add_cstr(opfXml, "xmlns:opf", OPF201_NAMESPACE); // Generation of required Dublin Core metadata gsf_xml_out_start_element(opfXml, "dc:title"); gsf_xml_out_add_cstr(opfXml, NULL, getTitle().c_str()); gsf_xml_out_end_element(opfXml); gsf_xml_out_start_element(opfXml, "dc:identifier"); gsf_xml_out_add_cstr(opfXml, "id", "BookId"); gsf_xml_out_add_cstr(opfXml, NULL, getDoc()->getDocUUIDString()); gsf_xml_out_end_element(opfXml); gsf_xml_out_start_element(opfXml, "dc:language"); gsf_xml_out_add_cstr(opfXml, NULL, getLanguage().c_str()); gsf_xml_out_end_element(opfXml); gsf_xml_out_start_element(opfXml, "dc:creator"); gsf_xml_out_add_cstr(opfXml, "opf:role", "aut"); gsf_xml_out_add_cstr(opfXml, NULL, getAuthor().c_str()); gsf_xml_out_end_element(opfXml); // </metadata> gsf_xml_out_end_element(opfXml); // <manifest> gsf_xml_out_start_element(opfXml, "manifest"); gchar *basedir = g_filename_from_uri(m_oebpsDir.c_str(),NULL,NULL); UT_ASSERT(basedir); std::string _baseDir = basedir; std::vector<std::string> listing = getFileList(_baseDir); FREEP(basedir); for (std::vector<std::string>::iterator i = listing.begin(); i != listing.end(); i++) { std::string idStr = escapeForId(*i); std::string fullItemPath = m_oebpsDir + G_DIR_SEPARATOR_S + *i; gsf_xml_out_start_element(opfXml, "item"); if (m_pHmtlExporter->hasMathML((*i))) { gsf_xml_out_add_cstr(opfXml, "mathml", "true"); } gsf_xml_out_add_cstr(opfXml, "id", idStr.c_str()); gsf_xml_out_add_cstr(opfXml, "href", (*i).c_str()); gsf_xml_out_add_cstr(opfXml, "media-type", getMimeType(fullItemPath).c_str()); gsf_xml_out_end_element(opfXml); } // We`ll add navigation files manually gsf_xml_out_start_element(opfXml, "item"); gsf_xml_out_add_cstr(opfXml, "id", "ncx"); gsf_xml_out_add_cstr(opfXml, "href", "toc.ncx"); gsf_xml_out_add_cstr(opfXml, "media-type", "application/x-dtbncx+xml"); gsf_xml_out_end_element(opfXml); if (!m_exp_opt.bEpub2) { gsf_xml_out_start_element(opfXml, "item"); gsf_xml_out_add_cstr(opfXml, "id", "toc"); gsf_xml_out_add_cstr(opfXml, "href", "toc.xhtml"); gsf_xml_out_add_cstr(opfXml, "media-type", "application/xhtml+xml"); gsf_xml_out_end_element(opfXml); } // </manifest> gsf_xml_out_end_element(opfXml); // <spine> gsf_xml_out_start_element(opfXml, "spine"); gsf_xml_out_add_cstr(opfXml, "toc", "ncx"); if (!m_exp_opt.bEpub2) { gsf_xml_out_start_element(opfXml, "itemref"); gsf_xml_out_add_cstr(opfXml, "idref","toc"); gsf_xml_out_end_element(opfXml); } for(std::vector<std::string>::iterator i = m_opsId.begin(); i != m_opsId.end(); i++) { gsf_xml_out_start_element(opfXml, "itemref"); gsf_xml_out_add_cstr(opfXml, "idref", (*i).c_str()); gsf_xml_out_end_element(opfXml); } // </spine> gsf_xml_out_end_element(opfXml); // </package> gsf_xml_out_end_element(opfXml); gsf_output_close(opf); return compress(); }
UT_Error IE_Exp_EPUB::EPUB2_writeNavigation() { GsfOutput* ncx = gsf_outfile_new_child(GSF_OUTFILE(m_oebps), "toc.ncx", FALSE); if (ncx == NULL) { UT_DEBUGMSG(("Can`t create toc.ncx file\n")); return UT_ERROR; } GsfXMLOut* ncxXml = gsf_xml_out_new(ncx); // <ncx> gsf_xml_out_start_element(ncxXml, "ncx"); gsf_xml_out_add_cstr(ncxXml, "xmlns", NCX_NAMESPACE); gsf_xml_out_add_cstr(ncxXml, "version", "2005-1"); gsf_xml_out_add_cstr(ncxXml, "xml:lang", NULL); // <head> gsf_xml_out_start_element(ncxXml, "head"); // <meta name="dtb:uid" content=... > gsf_xml_out_start_element(ncxXml, "meta"); gsf_xml_out_add_cstr(ncxXml, "name", "dtb:uid"); gsf_xml_out_add_cstr(ncxXml, "content", getDoc()->getDocUUIDString()); // </meta> gsf_xml_out_end_element(ncxXml); // <meta name="epub-creator" content=... > gsf_xml_out_start_element(ncxXml, "meta"); gsf_xml_out_add_cstr(ncxXml, "name", "epub-creator"); gsf_xml_out_add_cstr(ncxXml, "content", "AbiWord (http://www.abisource.com/)"); // </meta> gsf_xml_out_end_element(ncxXml); // <meta name="dtb:depth" content=... > gsf_xml_out_start_element(ncxXml, "meta"); gsf_xml_out_add_cstr(ncxXml, "name", "dtb:depth"); gsf_xml_out_add_cstr(ncxXml, "content", "1"); // </meta> gsf_xml_out_end_element(ncxXml); // <meta name="dtb:totalPageCount" content=... > gsf_xml_out_start_element(ncxXml, "meta"); gsf_xml_out_add_cstr(ncxXml, "name", "dtb:totalPageCount"); gsf_xml_out_add_cstr(ncxXml, "content", "0"); // </meta> gsf_xml_out_end_element(ncxXml); // <meta name="dtb:totalPageCount" content=... > gsf_xml_out_start_element(ncxXml, "meta"); gsf_xml_out_add_cstr(ncxXml, "name", "dtb:maxPageCount"); gsf_xml_out_add_cstr(ncxXml, "content", "0"); // </meta> gsf_xml_out_end_element(ncxXml); // </head> gsf_xml_out_end_element(ncxXml); // <docTitle> gsf_xml_out_start_element(ncxXml, "docTitle"); gsf_xml_out_start_element(ncxXml, "text"); gsf_xml_out_add_cstr(ncxXml, NULL, getTitle().c_str()); gsf_xml_out_end_element(ncxXml); // </docTitle> gsf_xml_out_end_element(ncxXml); // <docAuthor> gsf_xml_out_start_element(ncxXml, "docAuthor"); gsf_xml_out_start_element(ncxXml, "text"); gsf_xml_out_add_cstr(ncxXml, NULL, getAuthor().c_str()); gsf_xml_out_end_element(ncxXml); // </docAuthor> gsf_xml_out_end_element(ncxXml); // <navMap> gsf_xml_out_start_element(ncxXml, "navMap"); if (m_pHmtlExporter->getNavigationHelper()->hasTOC()) { int lastItemLevel; int curItemLevel = 0; std::vector<int> tagLevels; int tocNum = 0; for (int currentItem = 0; currentItem < m_pHmtlExporter->getNavigationHelper()->getNumTOCEntries(); currentItem++) { lastItemLevel = curItemLevel; std::string itemStr = m_pHmtlExporter->getNavigationHelper() ->getNthTOCEntry(currentItem, &curItemLevel).utf8_str(); PT_DocPosition itemPos; m_pHmtlExporter->getNavigationHelper()->getNthTOCEntryPos(currentItem, itemPos); std::string itemFilename; if (m_exp_opt.bSplitDocument) { itemFilename = m_pHmtlExporter->getNavigationHelper() ->getFilenameByPosition(itemPos).utf8_str(); if (itemFilename.length() == 0 || (itemFilename[0] == '.')) { itemFilename = "index.xhtml"; } else { itemFilename += + ".xhtml"; } } else { itemFilename = "index.xhtml"; } if (std::find(m_opsId.begin(), m_opsId.end(), escapeForId(itemFilename)) == m_opsId.end()) { m_opsId.push_back(escapeForId(itemFilename)); tocNum = 0; } UT_DEBUGMSG(("Item filename %s at pos %d\n", itemFilename.c_str(),itemPos)); if ((lastItemLevel >= curItemLevel) && (currentItem != 0)) { while ((tagLevels.size() > 0) && (tagLevels.back() >= curItemLevel)) { gsf_xml_out_end_element(ncxXml); tagLevels.pop_back(); } } std::string navClass = UT_std_string_sprintf("h%d", curItemLevel); std::string navId = UT_std_string_sprintf("AbiTOC%d", tocNum); std::string navSrc = std::string(itemFilename.c_str()) + "#" + navId; gsf_xml_out_start_element(ncxXml, "navPoint"); gsf_xml_out_add_cstr(ncxXml, "playOrder", UT_std_string_sprintf("%d", currentItem + 1).c_str()); gsf_xml_out_add_cstr(ncxXml, "class", navClass.c_str()); gsf_xml_out_add_cstr(ncxXml, "id", navId.c_str()); gsf_xml_out_start_element(ncxXml, "navLabel"); gsf_xml_out_start_element(ncxXml, "text"); gsf_xml_out_add_cstr(ncxXml, NULL, itemStr.c_str()); gsf_xml_out_end_element(ncxXml); gsf_xml_out_end_element(ncxXml); gsf_xml_out_start_element(ncxXml, "content"); gsf_xml_out_add_cstr(ncxXml, "src", navSrc.c_str()); gsf_xml_out_end_element(ncxXml); tagLevels.push_back(curItemLevel); tocNum++; } closeNTags(ncxXml, tagLevels.size()); } else { m_opsId.push_back(escapeForId("index.xhtml")); gsf_xml_out_start_element(ncxXml, "navPoint"); gsf_xml_out_add_cstr(ncxXml, "playOrder", "1"); gsf_xml_out_add_cstr(ncxXml, "class", "h1"); gsf_xml_out_add_cstr(ncxXml, "id", "index"); gsf_xml_out_start_element(ncxXml, "navLabel"); gsf_xml_out_start_element(ncxXml, "text"); gsf_xml_out_add_cstr(ncxXml, NULL, getTitle().c_str()); gsf_xml_out_end_element(ncxXml); gsf_xml_out_end_element(ncxXml); gsf_xml_out_start_element(ncxXml, "content"); gsf_xml_out_add_cstr(ncxXml, "src", "index.xhtml"); gsf_xml_out_end_element(ncxXml); gsf_xml_out_end_element(ncxXml); } // </navMap> gsf_xml_out_end_element(ncxXml); // </ncx> gsf_xml_out_end_element(ncxXml); gsf_output_close(ncx); return UT_OK; }
int main( int argc, char *argv[] ) { try { _2Real::app::Engine testEngine; auto loadedBundle = testEngine.loadBundle( "TestBundle_BasicBlocksAndCustomTypes" ); // -------print the block metainfo--------- auto bundleinfo = loadedBundle.second; std::cout << "basic bundle info" << std::endl; std::cout << "description " << bundleinfo.getDescription() << std::endl; std::cout << "category " << bundleinfo.getCategory() << std::endl; std::cout << "author " << bundleinfo.getAuthor() << std::endl; std::cout << "contact " << bundleinfo.getContact() << std::endl; std::cout << "version " << bundleinfo.getVersion() << std::endl; std::cout << std::endl; // i know that these are custom types, so no need for casting around auto typeinfos = bundleinfo.getExportedTypes(); std::cout << "number of exported types : " << typeinfos.size() << std::endl; if ( !typeinfos.empty() ) std::cout << "--------------------------------" << std::endl; for ( auto it : typeinfos ) { printCustomTypeMetainfo( it ); std::cout << "--------------------------------" << std::endl; } std::cout << std::endl; auto blockinfos = bundleinfo.getExportedBlocks(); std::cout << "exported blocks " << blockinfos.size() << std::endl; for ( auto it : blockinfos ) { std::cout << "\t" << it.getName() << std::endl; std::cout << "\t" << it.getDescription() << std::endl; auto dependencies = it.getDependenciesByName(); std::cout << "\tdependencies\t"; for ( auto it : dependencies ) std::cout << it << " "; std::cout << std::endl; std::vector< _2Real::app::InletMetainfo > inletinfos = it.getInlets(); std::cout << "\tinlets " << inletinfos.size() << std::endl; for ( auto it : inletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; std::cout << "\t\tis multi " << std::boolalpha << it.isMulti() << std::endl; } std::vector< _2Real::app::OutletMetainfo > outletinfos = it.getOutlets(); std::cout << "\toutlets " << outletinfos.size() << std::endl; for ( auto it : outletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } std::vector< _2Real::app::ParameterMetainfo > paraminfos = it.getParameters(); std::cout << "\tparameters " << paraminfos.size() << std::endl; for ( auto it : paraminfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } } // -------create block instance--------- _2Real::app::TimerHandle timer = testEngine.createTimer( 5.0 ); _2Real::app::ThreadpoolHandle threadpool = testEngine.createThreadpool( _2Real::ThreadpoolPolicy::FIFO ); _2Real::app::BlockHandle counter = loadedBundle.first.createBlock( "counter", threadpool, std::vector< _2Real::app::BlockHandle >() ); _2Real::app::BlockIo counterio = counter.getBlockIo(); auto incInlet = std::dynamic_pointer_cast< _2Real::app::InletHandle >( counterio.mInlets[ 0 ] ); std::future< _2Real::BlockResult > setup = counter.setup(); handleFuture( setup ); std::future< _2Real::BlockResult > start = counter.startUpdating( timer ); handleFuture( start ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; else if ( line == "stop" ) { timer.stop(); } else if ( line == "start" ) { timer.start(); } } std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); std::future< _2Real::BlockResult > shutdown = counter.shutdown(); handleFuture( shutdown ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } testEngine.clear(); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } } catch ( _2Real::Exception &e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << " " << e.message() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } catch ( std::exception const& e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } return 0; }
int main( int argc, char *argv[] ) { try { _2Real::app::Engine testEngine; auto loadedBundle = testEngine.loadBundle( "TestBundle_BasicBlocksAndCustomTypes" ); // -------print the block metainfo--------- auto bundleinfo = loadedBundle.second; std::cout << "basic bundle info" << std::endl; std::cout << "description " << bundleinfo.getDescription() << std::endl; std::cout << "category " << bundleinfo.getCategory() << std::endl; std::cout << "author " << bundleinfo.getAuthor() << std::endl; std::cout << "contact " << bundleinfo.getContact() << std::endl; std::cout << "version " << bundleinfo.getVersion() << std::endl; std::cout << std::endl; // i know that these are custom types, so no need for casting around auto typeinfos = bundleinfo.getExportedTypes(); std::cout << "number of exported types : " << typeinfos.size() << std::endl; if ( !typeinfos.empty() ) std::cout << "--------------------------------" << std::endl; for ( auto it : typeinfos ) { printCustomTypeMetainfo( it ); std::cout << "--------------------------------" << std::endl; } std::cout << std::endl; auto blockinfos = bundleinfo.getExportedBlocks(); std::cout << "exported blocks " << blockinfos.size() << std::endl; for ( auto it : blockinfos ) { std::cout << "\t" << it.getName() << std::endl; std::cout << "\t" << it.getDescription() << std::endl; auto dependencies = it.getDependenciesByName(); std::cout << "\tdependencies\t"; for ( auto it : dependencies ) std::cout << it << " "; std::cout << std::endl; std::vector< _2Real::app::InletMetainfo > inletinfos = it.getInlets(); std::cout << "\tinlets " << inletinfos.size() << std::endl; for ( auto it : inletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; std::cout << "\t\tis multi " << std::boolalpha << it.isMulti() << std::endl; } std::vector< _2Real::app::OutletMetainfo > outletinfos = it.getOutlets(); std::cout << "\toutlets " << outletinfos.size() << std::endl; for ( auto it : outletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } std::vector< _2Real::app::ParameterMetainfo > paraminfos = it.getParameters(); std::cout << "\tparameters " << paraminfos.size() << std::endl; for ( auto it : paraminfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } } // -------create block instances--------- auto bundle = loadedBundle.first; auto threadpool = testEngine.createThreadpool( _2Real::ThreadpoolPolicy::FIFO ); auto counter = loadedBundle.first.createBlock( "counter", threadpool, std::vector< _2Real::app::BlockHandle >() ); auto io = counter.getBlockIo(); auto counterinfo = bundleinfo.getExportedBlock( "counter" ); auto inc = std::static_pointer_cast< _2Real::app::InletHandle >( counter.getBlockIo().mInlets[ 0 ] ); auto incinfo = counterinfo.getInlet( "increment" ); auto stringy = std::static_pointer_cast< _2Real::app::InletHandle >( counter.getBlockIo().mInlets[ 1 ] ); auto stringyinfo = counterinfo.getInlet( "stringy" ); auto multiinlet = std::static_pointer_cast< _2Real::app::MultiInletHandle >( counter.getBlockIo().mInlets[ 2 ] ); auto multiinletinfo = counterinfo.getInlet( "multi" ); std::deque< _2Real::app::InletHandle > subinlets; auto info = incinfo.getTypeMetainfo(); auto custominfo = std::static_pointer_cast< _2Real::app::CustomTypeMetainfo >( info ); auto basicinfo = stringyinfo.getTypeMetainfo(); uint32_t aNumber = 0; auto aSimple = custominfo->makeCustomData(); aSimple.set( "uint_field", aNumber ); std::string aString = ""; auto policy = counter.getUpdatePolicy(); policy.set( _2Real::DefaultUpdatePolicy::ANY ); auto timer = testEngine.createTimer( 4.0 ); timer.start(); std::future< _2Real::BlockResult > setup = counter.setup(); handleFuture( setup ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; else if ( line == "test" ) { //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.appeqnd( " next" ); //stringy->setValue( aString ); for ( auto it : subinlets ) { std::shared_ptr< _2Real::DataItem > data( new _2Real::DataItem( ( uint32_t ) 10 ) ); it.setValue( data ); } std::this_thread::sleep_for( std::chrono::milliseconds( 200 ) ); //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.append( " next" ); //stringy->setValue( aString );q std::this_thread::sleep_for( std::chrono::milliseconds( 200 ) ); //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.append( " next" ); //stringy->setqValue( aString ); } else if ( line == "policy" ) { std::future< _2Real::BlockResult > start = counter.startUpdating(); handleFuture( start ); } else if ( line == "timer" ) { std::future< _2Real::BlockResult > start = counter.startUpdating( timer ); handleFuture( start ); } else if ( line == "done" ) { std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); } else if ( line == "add" ) { _2Real::app::InletHandle subinlet = multiinlet->add(); subinlets.push_back( subinlet ); } else if ( line == "del" ) { if ( !subinlets.empty() ) { multiinlet->remove( subinlets.back() ); subinlets.pop_back(); } } } std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); std::future< _2Real::BlockResult > shutdown = counter.shutdown(); handleFuture( shutdown ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } testEngine.clear(); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } } catch ( _2Real::Exception &e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << " " << e.message() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } catch ( std::exception const& e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } return 0; }