本文整理汇总了C++中Reference::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ Reference::assign方法的具体用法?C++ Reference::assign怎么用?C++ Reference::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reference
的用法示例。
在下文中一共展示了Reference::assign方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notes_get_references_from_editor
void notes_get_references_from_editor(GtkTextBuffer * textbuffer, vector < Reference > &references, vector < ustring > &messages)
/*
Gets all references from the notes editor.
Normalizes them.
Produces messages on trouble.
Handles notes that span more than one chapter.
*/
{
// Get all lines from the textbuffer.
vector < ustring > lines;
textbuffer_get_lines(textbuffer, lines);
// When discovering a reference from a user's entry, use previous values,
// so that it becomes quicker for a user to enter new references.
// If Leviticus 10:11 is already there, and the user wishes to add verse
// 12 also, he just enters 12 on a line, and that' it.
Reference previousreference;
for (unsigned int i = 0; i < lines.size(); i++) {
if (!lines[i].empty()) {
// Normalize reference.
Reference reference;
if (reference_discover(previousreference, lines[i], reference)) {
ustring ch1, vs1, ch2, vs2;
if (chapter_span_discover(lines[i], ch1, vs1, ch2, vs2)) {
// We cross the chapter boundaries.
// Store as two or more references,
// the first one going up to the end of the chapter,
// and the second one starting at the next chapter verse 1,
// and any chapter in-between.
extern Settings *settings;
ProjectConfiguration *projectconfig = settings->projectconfig(settings->genconfig.project_get());
Reference ref(reference.book_get(), convert_to_int(ch1), vs1);
ustring lastverse = versification_get_last_verse(projectconfig->versification_get(), reference.book_get(), convert_to_int(ch1));
ref.verse_append("-" + lastverse);
references.push_back(ref);
for (unsigned int ch = convert_to_int(ch1) + 1; ch < convert_to_int(ch2); ch++) {
Reference ref(reference.book_get(), ch, "1");
ustring lastverse = versification_get_last_verse(projectconfig->versification_get(), reference.book_get(), ch);
ref.verse_append("-" + lastverse);
references.push_back(ref);
}
ref.chapter_set(convert_to_int(ch2));
ref.verse_set("1-" + vs2);
references.push_back(ref);
// Store values to discover next reference.
previousreference.book_set(reference.book_get());
previousreference.chapter_set(convert_to_int(ch2));
previousreference.verse_set(vs2);
} else {
// We've a normal reference.
// Store reference.
references.push_back(reference);
// Store values to discover next reference.
previousreference.assign(reference);
}
} else {
messages.push_back(_("Reference ") + lines[i] + _(" is not valid and has been removed."));
}
}
}
}
示例2: bibleworks_reference_get_decode
bool bibleworks_reference_get_decode (ustring response, Reference& reference)
{
// If BibleWorks was not running it might get started at this point, but the value it returns is empty as a result of a timeout.
if (response.empty())
return false;
// The response could be, e.g.: "OK Jer 39:10" (without the quotes).
replace_text (response, ":", " ");
Parse parse (response);
if (parse.words.size() != 4)
return false;
reference.assign(books_bibleworks_to_id (parse.words[1]), // book
convert_to_int (parse.words[2]), // chapter
parse.words[3]); // verse
return true;
}
示例3: kjv_import_sword
void kjv_import_sword (const ustring& textfile, const ustring& database)
{
// Show the progress. KJV has 31102 verses.
ProgressWindow progresswindow (_("Importing King James Bible"), false);
progresswindow.set_iterate (0, 1, 31102);
gchar * contents;
g_file_get_contents(textfile.c_str(), &contents, NULL, NULL);
if (!contents)
return;
// Create the database, put it in fast mode.
unix_unlink (database.c_str());
sqlite3 *db;
sqlite3_open(database.c_str(), &db);
sqlite3_exec(db, "create table kjv (book integer, chapter integer, verse integer, item integer, fragment text, lemma text);", NULL, NULL, NULL);
sqlite3_exec(db, "PRAGMA synchronous=OFF;", NULL, NULL, NULL);
// Parse input.
xmlParserInputBufferPtr inputbuffer;
inputbuffer = xmlParserInputBufferCreateMem(contents, strlen (contents), XML_CHAR_ENCODING_NONE);
xmlTextReaderPtr reader = xmlNewTextReader(inputbuffer, NULL);
if (reader) {
bool within_relevant_element = false;
Reference reference (0, 0, "0");
unsigned int item_number = 0;
ustring textfragment;
ustring lemmata;
while ((xmlTextReaderRead(reader) == 1)) {
switch (xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT:
{
xmlChar *element_name = xmlTextReaderName(reader);
// Deal with a verse element.
if (!xmlStrcmp(element_name, BAD_CAST "verse")) {
progresswindow.iterate();
char *attribute;
attribute = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "osisID");
if (attribute) {
Parse parse (attribute, false, ".");
if (parse.words.size() == 3) {
reference.assign(books_osis_to_id (parse.words[0]), // book
convert_to_int (parse.words[1]), // chapter
parse.words[2]); // verse
} else {
gw_critical (attribute);
}
free(attribute);
}
item_number = 0;
}
// Deal with a w element.
if (!xmlStrcmp(element_name, BAD_CAST "w")) {
within_relevant_element = true;
item_number++;
textfragment.clear();
lemmata.clear();
char *attribute;
attribute = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "lemma");
if (attribute) {
lemmata = attribute;
free(attribute);
}
}
break;
}
case XML_READER_TYPE_TEXT:
{
if (within_relevant_element) {
xmlChar *text = xmlTextReaderValue(reader);
if (text) {
textfragment = (const char *)text;
xmlFree(text);
textfragment = textfragment.casefold();
}
}
break;
}
case XML_READER_TYPE_END_ELEMENT:
{
xmlChar *element_name = xmlTextReaderName(reader);
if (!xmlStrcmp(element_name, BAD_CAST "w")) {
replace_text (lemmata, "strong:", "");
char *sql;
sql = g_strdup_printf("insert into kjv values (%d, %d, %d, %d, '%s', '%s');",
reference.book_get(), reference.chapter_get(), convert_to_int (reference.verse_get()),
item_number,
double_apostrophy (textfragment).c_str(), lemmata.c_str());
sqlite3_exec(db, sql, NULL, NULL, NULL);
g_free(sql);
within_relevant_element = false;
}
break;
}
}
}
}
if (reader)
xmlFreeTextReader(reader);
if (inputbuffer)
xmlFreeParserInputBuffer(inputbuffer);
//.........这里部分代码省略.........