本文整理汇总了C++中convert_to_string函数的典型用法代码示例。如果您正苦于以下问题:C++ convert_to_string函数的具体用法?C++ convert_to_string怎么用?C++ convert_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_to_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: search_logic_index_chapter
// Indexes a $bible $book $chapter for searching.
void search_logic_index_chapter (string bible, int book, int chapter)
{
Database_Bibles database_bibles;
string usfm = database_bibles.getChapter (bible, book, chapter);
string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
vector <string> index;
set <string> already_processed;
vector <int> verses = usfm_get_verse_numbers (usfm);
for (auto verse : verses) {
string raw_usfm = filter_string_trim (usfm_get_verse_text (usfm, verse));
// In case of combined verses, the bit of USFM may have been indexed already.
// Skip it in that case.
if (already_processed.find (raw_usfm) != already_processed.end ()) continue;
already_processed.insert (raw_usfm);
index.push_back (search_logic_verse_separator ());
index.push_back (convert_to_string (verse));
index.push_back (search_logic_index_separator ());
index.push_back (raw_usfm);
string usfm_lower = unicode_string_casefold (raw_usfm);
index.push_back (search_logic_index_separator ());
index.push_back (usfm_lower);
// Text filter for getting the plain text.
Filter_Text filter_text = Filter_Text (bible);
filter_text.text_text = new Text_Text ();
filter_text.initializeHeadingsAndTextPerVerse (true);
filter_text.addUsfmCode (raw_usfm);
filter_text.run (stylesheet);
string raw_plain;
// Add the clean verse texts.
map <int, string> texts = filter_text.getVersesText ();
for (auto & element : texts) {
raw_plain.append (element.second + "\n");
}
// Add any clean headings.
map <int, string> headings = filter_text.verses_headings;
for (auto & element : headings) {
raw_plain.append (element.second + "\n");
}
// Add any footnotes.
raw_plain.append (filter_text.text_text->getnote ());
// Clean up.
raw_plain = filter_string_trim (raw_plain);
index.push_back (search_logic_index_separator ());
index.push_back (raw_plain);
string plain_lower = unicode_string_casefold (raw_plain);
index.push_back (search_logic_index_separator ());
index.push_back (plain_lower);
}
index.push_back (search_logic_index_separator ());
// Store everything.
string path = search_logic_chapter_file (bible, book, chapter);
filter_url_file_put_contents (path, filter_string_implode (index, "\n"));
}
开发者ID:bibledit,项目名称:bibledit-windows,代码行数:75,代码来源:logic.cpp
示例2: mechon_mamre_action_page
//.........这里部分代码省略.........
}
// Look for the directory where all the html files reside.
if (keep_going) {
directory = gw_build_filename (directory, "c", "ct");
if (!g_file_test (directory.c_str(), G_FILE_TEST_IS_DIR)) {
messages.push_back ("Can't find data in directory " + directory);
}
messages.push_back ("Looking for data in directory " + directory);
}
// Get a list of the html files that have the data.
vector <ustring> files;
if (keep_going) {
ReadFiles rf (directory, "c", ".htm");
for (unsigned int i = 0; i < rf.files.size(); i++) {
ustring filename = gw_build_filename (directory, rf.files[i]);
// Check on a few characteristics.
if (mechon_mamre_copyright(filename)) {
unsigned int digitcount = digit_count_in_string(rf.files[i]);
if ((digitcount == 3) || (digitcount == 4)) {
files.push_back(filename);
}
}
}
}
// Create a new Bible into which to import the data.
ustring bible = "Hebrew Mechon Mamre";
if (keep_going) {
if (project_exists (bible)) {
messages.push_back ("A Bible called \"" + bible + "\" already exists");
keep_going = false;
} else {
project_create_restore (bible, "");
messages.push_back ("Creating a new Bible called \"" + bible + "\"");
// Make a couple of settings.
extern Settings * settings;
ProjectConfiguration * projectconfig = settings->projectconfig (bible);
projectconfig->versification_set ("Original");
projectconfig->editable_set (false);
projectconfig->right_to_left_set (true);
projectconfig->spelling_check_set (false);
}
}
// Store all the chapters 0 in each book.
if (keep_going) {
vector <unsigned int> books = books_type_to_ids(btOldTestament);
ProgressWindow progresswindow ("Creating books", false);
progresswindow.set_iterate (0, 1, books.size());
for (unsigned int bk = 0; bk < books.size(); bk++) {
progresswindow.iterate ();
vector <ustring> usfm;
usfm.push_back ("\\id " + books_id_to_paratext (books[bk]));
CategorizeChapterVerse ccv (usfm);
project_store_chapter (bible, books[bk], ccv);
}
}
// Store all the chapters.
if (keep_going) {
ProgressWindow progresswindow ("Importing chapters", false);
progresswindow.set_iterate (0, 1, files.size());
for (unsigned int i = 0; i < files.size(); i++) {
progresswindow.iterate ();
unsigned int book = 0;
unsigned int chapter = 0;
mechon_mamre_extract_book_chapter (files[i], book, chapter);
vector <ustring> contents = mechon_mamre_extract_contents (files[i], chapter);
CategorizeChapterVerse ccv (contents);
project_store_chapter (bible, book, ccv);
messages.push_back ("Importing " + books_id_to_english (book) + " " + convert_to_string (chapter) + " from file " + files[i]);
}
}
// Write accumulated messages.
htmlwriter.heading_open (3);
if (keep_going) {
htmlwriter.text_add ("Success! Bible \"" + bible + "\" was created");
} else {
htmlwriter.text_add ("Error!");
}
htmlwriter.heading_close ();
if (keep_going) {
htmlwriter.paragraph_open ();
htmlwriter.text_add ("To view the Hebrew text, open the Bible in the editor. Optionally set the font for better display of the Hebrew text. A donation made to Mechon Mamre will support their work.");
htmlwriter.paragraph_close ();
}
for (unsigned int i = 0; i < messages.size(); i++) {
htmlwriter.paragraph_open ();
htmlwriter.text_add (messages[i]);
htmlwriter.paragraph_close ();
}
// Write OK.
htmlwriter.paragraph_open ();
htmlwriter.hyperlink_add ("ok", "Ok");
htmlwriter.paragraph_close ();
}
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:mechonmamre.cpp
示例3: workbench_index
string workbench_index (void * webserver_request)
{
Webserver_Request * request = (Webserver_Request *) webserver_request;
vector <string> desktops = workbench_get_names (request);
// Set the requested desktop as the active one.
if (request->query.count ("bench")) {
unsigned int bench = convert_to_int (request->query ["bench"]);
if (bench < desktops.size ()) {
string workbench = desktops [bench];
request->database_config_user()->setActiveWorkbench (workbench);
}
}
// Check that the active desktop exists, else set the first available desktop as the active one.
{
string desktop = request->database_config_user ()->getActiveWorkbench ();
if (!in_array (desktop, desktops)) {
if (!desktops.empty ()) {
request->database_config_user ()->setActiveWorkbench (desktops [0]);
}
}
}
// Create default set of desktops if there are none.
bool create = desktops.empty ();
if (!create) {
create = (desktops [0] == workbench_get_default_name ());
}
if (create) {
workbench_create_defaults (webserver_request);
}
// In case the desktop is opened from a consultation note email,
// read the note, and set the active passage to the passage the note refers to.
int noteid = convert_to_int (request->query ["note"]);
if (noteid) {
Database_Notes database_notes (webserver_request);
vector <Passage> passages = database_notes.getPassages (noteid);
if (!passages.empty ()) {
Ipc_Focus::set (webserver_request, passages[0].book, passages[0].chapter, convert_to_int (passages[0].verse));
Navigation_Passage::recordHistory (webserver_request, passages[0].book, passages[0].chapter, convert_to_int (passages[0].verse));
}
}
string page;
Assets_Header header = Assets_Header (translate("Desktop"), request);
header.setNavigator ();
header.setFadingMenu (menu_logic_desktop_category (webserver_request));
page = header.run ();
Assets_View view;
map <int, string> urls = workbench_get_urls (request, true);
map <int, string> widths = workbench_get_widths (request);
for (unsigned int key = 0; key < 15; key++) {
string url = urls [key];
string width = widths [key];
int row = round (key / 5) + 1;
int column = key % 5 + 1;
string variable = "url" + convert_to_string (row) + convert_to_string (column);
view.set_variable (variable, url);
variable = "width" + convert_to_string (row) + convert_to_string (column);
view.set_variable (variable, width);
if (convert_to_int (width) > 0) view.enable_zone (variable);
}
map <int, string> heights = workbench_get_heights (request);
for (unsigned int key = 0; key < 3; key++) {
string height = heights [key];
int row = key + 1;
string variable = "height" + convert_to_string (row);
view.set_variable (variable, height);
if (convert_to_int (height) > 0) view.enable_zone (variable);
}
string workbenchwidth = workbench_get_entire_width (request);
if (!workbenchwidth.empty ()) {
workbenchwidth.insert (0, "width: ");
workbenchwidth.append (";");
}
view.set_variable ("workbenchwidth", workbenchwidth);
// The rendered template disables framekillers through the "sandbox" attribute on the iframe elements.
page += view.render ("workbench", "index");
page += Assets_Page::footer ();
return page;
}
开发者ID:alerque,项目名称:bibledit,代码行数:96,代码来源:index.cpp
示例4: manage_users
string manage_users (void * webserver_request)
{
Webserver_Request * request = (Webserver_Request *) webserver_request;
bool user_updated = false;
bool privileges_updated = false;
string page;
Assets_Header header = Assets_Header (translate("Users"), webserver_request);
header.addBreadCrumb (menu_logic_settings_menu (), menu_logic_settings_text ());
page = header.run ();
Assets_View view;
int myLevel = request->session_logic ()->currentLevel ();
// New user creation.
if (request->query.count ("new")) {
Dialog_Entry dialog_entry = Dialog_Entry ("users", translate("Please enter a name for the new user"), "", "new", "");
page += dialog_entry.run ();
return page;
}
if (request->post.count ("new")) {
string user = request->post["entry"];
if (request->database_users ()->usernameExists (user)) {
page += Assets_Page::error (translate("User already exists"));
} else {
request->database_users ()->addNewUser(user, user, Filter_Roles::member (), "");
user_updated = true;
page += Assets_Page::success (translate("User created"));
}
}
// The user to act on.
string objectUsername = request->query["user"];
int objectUserLevel = request->database_users ()->getUserLevel (objectUsername);
// Delete a user.
if (request->query.count ("delete")) {
string role = Filter_Roles::text (objectUserLevel);
string email = request->database_users ()->getUserToEmail (objectUsername);
string message = "Deleted user " + objectUsername + " with role " + role + " and email " + email;
Database_Logs::log (message, Filter_Roles::admin ());
request->database_users ()->removeUser (objectUsername);
user_updated = true;
database_privileges_client_remove (objectUsername);
page += Assets_Page::success (message);
// Also remove any privileges for this user.
// In particular for the Bible privileges this is necessary,
// beause if old users remain in the privileges storage,
// then a situation where no user has any privileges to any Bible,
// and thus all relevant users have all privileges,
// can never be achieved again.
Database_Privileges::removeUser (objectUsername);
// Remove any login tokens the user might have had: Just to clean things up.
Database_Login::removeTokens (objectUsername);
// Remove any settings for the user.
// The advantage of this is that when a user is removed, all settings are gone,
// so when the same user would be created again, all settings will go back to their defaults.
request->database_config_user ()->remove (objectUsername);
}
// The user's role.
if (request->query.count ("level")) {
string level = request->query ["level"];
if (level == "") {
Dialog_List dialog_list = Dialog_List ("users", translate("Select a role for") + " " + objectUsername, "", "");
dialog_list.add_query ("user", objectUsername);
for (int i = Filter_Roles::lowest (); i <= Filter_Roles::highest (); i++) {
if (i <= myLevel) {
dialog_list.add_row (Filter_Roles::text (i), "level", convert_to_string (i));
}
}
page += dialog_list.run ();
return page;
} else {
request->database_users ()->updateUserLevel (objectUsername, convert_to_int (level));
user_updated = true;
}
}
// User's email address.
if (request->query.count ("email")) {
string email = request->query ["email"];
if (email == "") {
string question = translate("Please enter an email address for") + " " + objectUsername;
string value = request->database_users ()->getUserToEmail (objectUsername);
Dialog_Entry dialog_entry = Dialog_Entry ("users", question, value, "email", "");
dialog_entry.add_query ("user", objectUsername);
page += dialog_entry.run ();
return page;
//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:users.cpp
示例5: sprint_create_burndown_chart
// This function creates a text-based burndown chart for sprint $bible / $year / $month.
string sprint_create_burndown_chart (string bible, int year, int month)
{
// Get the seconds for the first of the month.
int seconds = filter_date_seconds_since_epoch (year, month, 1);
// The business days in the month for on the X-axis.
vector <int> days_in_month;
for (unsigned int day = 1; day <= 31; day++) {
int mymonth = filter_date_numerical_month (seconds);
if (mymonth == month) {
if (filter_date_is_business_day (year, month, day)) {
days_in_month.push_back (day);
}
}
seconds += 86400;
}
// Assemble history of this sprint.
Database_Sprint database_sprint = Database_Sprint ();
vector <Database_Sprint_Item> history = database_sprint.getHistory (bible, year, month);
map <int, int> data;
for (auto day : days_in_month) {
data [day] = 0;
for (auto item : history) {
if (day == item.day) {
int tasks = item.tasks;
int complete = item.complete;
tasks = round (tasks * (100 - complete) / 100);
data [day] = tasks;
}
}
}
vector <string> lines;
lines.push_back ("<table class='burndown'>");
lines.push_back ("<tr>");
for (auto element : data) {
int tasks = element.second;
string text;
for (int i = 0; i < tasks; i++) text.append ("▓<br>");
lines.push_back ("<td style=\"vertical-align: bottom;\" class='day'>" + text + "</td>");
}
lines.push_back ("</tr>");
// Write number of days along the X-axis.
lines.push_back ("<tr>");
for (auto element : data) {
int day = element.first;
lines.push_back ("<td class='day'>" + convert_to_string (day) + "</td>");
}
lines.push_back ("</tr>");
// Write "days" below the X-axis.
lines.push_back ("<tr>");
int columncount = data.size ();
string text = translate("days");
lines.push_back ("<td colspan=\"" + convert_to_string (columncount) + "\">" + text + "</td>");
lines.push_back ("</tr>");
lines.push_back ("</table>");
string chart = filter_string_implode (lines, "\n");
return chart;
}
开发者ID:bibledit,项目名称:bibledit-windows,代码行数:65,代码来源:burndown.cpp
示例6: sendreceive_changes
void sendreceive_changes ()
{
if (sendreceive_changes_watchdog) {
int time = filter_date_seconds_since_epoch ();
if (time < (sendreceive_changes_watchdog + 900)) {
Database_Logs::log (sendreceive_changes_text () + translate("Still busy"), Filter_Roles::translator ());
return;
}
Database_Logs::log (sendreceive_changes_text () + translate("Watchdog timeout"), Filter_Roles::translator ());
}
sendreceive_changes_kick_watchdog ();
config_globals_syncing_changes = true;
Database_Logs::log (sendreceive_changes_sendreceive_text (), Filter_Roles::translator ());
Webserver_Request request;
Sync_Logic sync_logic = Sync_Logic (&request);
Database_Modifications database_modifications;
if (!database_modifications.healthy ()) {
Database_Logs::log (sendreceive_changes_text () + translate("Recreate damaged modifications database"), Filter_Roles::translator ());
database_modifications.erase ();
database_modifications.create ();
}
string response = client_logic_connection_setup ();
int iresponse = convert_to_int (response);
if (iresponse < Filter_Roles::guest () || iresponse > Filter_Roles::admin ()) {
Database_Logs::log (sendreceive_changes_text () + translate("Failure to initiate connection"), Filter_Roles::translator ());
send_receive_changes_done ();
return;
}
// Set the correct user in the session: The sole user on the Client.
vector <string> users = request.database_users ()->getUsers ();
if (users.empty ()) {
Database_Logs::log (translate("No user found"), Filter_Roles::translator ());
send_receive_changes_done ();
return;
}
string user = users [0];
request.session_logic ()->setUsername (user);
string password = request.database_users ()->getmd5 (user);
// The basic request to be POSTed to the server.
// It contains the user's credentials.
map <string, string> post;
post ["u"] = bin2hex (user);
post ["p"] = password;
post ["l"] = convert_to_string (request.database_users ()->getUserLevel (user));
// Error variables.
string error;
bool communication_errors = false;
// Server URL to call.
string address = Database_Config_General::getServerAddress ();
int port = Database_Config_General::getServerPort ();
string url = client_logic_url (address, port, sync_changes_url ());
// Send the removed change notifications to the server.
vector <int> ids = request.database_config_user ()->getRemovedChanges ();
if (!ids.empty ()) Database_Logs::log (sendreceive_changes_text () + "Sending removed notifications: " + convert_to_string (ids.size()), Filter_Roles::translator ());
for (auto & id : ids) {
post ["a"] = convert_to_string (Sync_Logic::changes_delete_modification);
post ["i"] = convert_to_string (id);
response = sync_logic.post (post, url, error);
if (!error.empty ()) {
communication_errors = true;
Database_Logs::log (sendreceive_changes_text () + "Failure sending removed notification: " + error, Filter_Roles::translator ());
}
else {
request.database_config_user ()->removeRemovedChange (id);
}
}
if (communication_errors) {
Database_Logs::log (sendreceive_changes_text () + translate("Not downloading change notifications due to communication error"), Filter_Roles::translator ());
send_receive_changes_done ();
return;
}
// Compare the total checksum for the change notifications for the active user on client and server.
// Checksum is cached for future re-use.
// Take actions based on that.
string client_checksum = request.database_config_user ()->getChangeNotificationsChecksum ();
if (client_checksum.empty ()) {
client_checksum = Sync_Logic::changes_checksum (user);
request.database_config_user ()->setChangeNotificationsChecksum (client_checksum);
//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:changes.cpp
示例7: htmlwriter
void WindowShowRelatedVerses::load_webview (const gchar * url)
{
// New url.
active_url = url;
// Start writing a html page.
HtmlWriter2 htmlwriter ("");
bool display_another_page = true;
if (active_url.find ("keyterm ") == 0) {
item_type = ritKeytermId;
item_id = active_url.substr (8, 100);
gtk_button_clicked (GTK_BUTTON (button_item));
display_another_page = false;
}
else if (active_url.find ("strong ") == 0) {
item_type = ritStrongNumber;
item_id = active_url.substr (7, 100);
gtk_button_clicked (GTK_BUTTON (button_item));
display_another_page = false;
}
else if (active_url.find ("parallels") == 0) {
item_type = ritParallels;
gtk_button_clicked (GTK_BUTTON (button_item));
display_another_page = false;
}
else {
// Display the keyterms in the verse, and their renderings.
htmlwriter.heading_open (3);
htmlwriter.text_add (_("Keyterms in verse ") + myreference.verse);
htmlwriter.heading_close ();
vector <int> keyterms = keyterms_get_terms_in_verse(myreference);
for (unsigned int i = 0; i < keyterms.size(); i++) {
htmlwriter.paragraph_open();
// Display the keyterm.
ustring term;
keyterms_get_term(keyterms[i], term);
htmlwriter.text_add ("* ");
ustring url = "keyterm " + convert_to_string (keyterms[i]);
htmlwriter.hyperlink_add (url, term);
htmlwriter.text_add (": ");
// Display the renderings.
vector <ustring> renderings;
vector <bool> wholewords;
vector <bool> casesensitives;
ustring category;
{
ustring dummy1;
vector < Reference > dummy2;
keyterms_get_data(keyterms[i], category, dummy1, dummy2);
}
keyterms_retrieve_renderings(myproject, term, category, renderings, wholewords, casesensitives);
for (unsigned int i2 = 0; i2 < renderings.size(); i2++) {
if (i2)
htmlwriter.text_add (", ");
htmlwriter.text_add (renderings[i2]);
}
htmlwriter.paragraph_close();
}
// If there are no keyterms, mention this.
if (keyterms.empty()) {
htmlwriter.paragraph_open ();
htmlwriter.text_add ("none");
htmlwriter.paragraph_close ();
}
// Terms derived from the Strong's numbers in this verse.
htmlwriter.heading_open (3);
htmlwriter.text_add (_("Similar words in other verses"));
htmlwriter.heading_close ();
// Get the data.
vector <ustring> strongs;
vector <ustring> words;
kjv_get_strongs_data (myreference, strongs, words);
// Display the data.
for (unsigned int i = 0; i < strongs.size(); i++) {
htmlwriter.paragraph_open ();
Parse parse (strongs[i]);
for (unsigned int i2 = 0; i2 < parse.words.size (); i2++) {
htmlwriter.text_add (words[i]);
htmlwriter.text_add (" ");
ustring url = "strong " + parse.words[i2];
htmlwriter.hyperlink_add (url, parse.words[i2]);
}
htmlwriter.paragraph_close ();
}
// Parallel passages.
vector <Reference> parallel_references;
//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:windowshowrelatedverses.cpp
示例8: zcvrs
/* <num> <radix_int> <string> cvrs <substring> */
static int
zcvrs(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int radix;
check_type(op[-1], t_integer);
if (op[-1].value.intval < 2 || op[-1].value.intval > 36)
return_error(e_rangecheck);
radix = op[-1].value.intval;
check_write_type(*op, t_string);
if (radix == 10) {
switch (r_type(op - 2)) {
case t_integer:
case t_real:
{
int code = convert_to_string(imemory, op - 2, op);
if (code < 0)
return code;
pop(2);
return 0;
}
case t__invalid:
return_error(e_stackunderflow);
default:
return_error(e_rangecheck); /* CET 24-05 wants rangecheck */
}
} else {
uint ival;
byte digits[sizeof(ulong) * 8];
byte *endp = &digits[countof(digits)];
byte *dp = endp;
switch (r_type(op - 2)) {
case t_integer:
ival = (uint) op[-2].value.intval;
break;
case t_real:
{
float fval = op[-2].value.realval;
if (!REAL_CAN_BE_INT(fval))
return_error(e_rangecheck);
ival = (ulong) (long)fval;
} break;
case t__invalid:
return_error(e_stackunderflow);
default:
return_error(e_rangecheck); /* CET 24-05 wants rangecheck */
}
do {
int dit = ival % radix;
*--dp = dit + (dit < 10 ? '0' : ('A' - 10));
ival /= radix;
}
while (ival);
if (endp - dp > r_size(op))
return_error(e_rangecheck);
memcpy(op->value.bytes, dp, (uint) (endp - dp));
r_set_size(op, endp - dp);
}
op[-2] = *op;
pop(2);
return 0;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:68,代码来源:ztype.c
示例9: statistics_statistics
void statistics_statistics ()
{
Webserver_Request request;
Database_Mail database_mail = Database_Mail (&request);
Database_Modifications database_modifications;
Database_Notes database_notes (&request);
Database_Logs::log (translate("Sending statistics"), Filter_Roles::manager ());
string siteUrl = config_logic_site_url ();
vector <string> bibles = request.database_bibles()->getBibles ();
vector <string> users = request.database_users ()->getUsers ();
for (auto & user : users) {
string subject = "Bibledit " + translate("statistics");
vector <string> body;
if (request.database_config_user()->getUserPendingChangesNotification (user)) {
vector <int> ids = database_modifications.getNotificationIdentifiers (user);
body.push_back ("<p><a href=\"" + siteUrl + changes_changes_url () + "\">" + translate("Number of change notifications") + "</a>: " + convert_to_string (ids.size()) + "</p>\n");
}
if (request.database_config_user()->getUserAssignedNotesStatisticsNotification (user)) {
vector <int> ids = database_notes.selectNotes (
bibles, // Bibles.
0, // Book
0, // Chapter
0, // Verse
3, // Passage selector.
0, // Edit selector.
0, // Non-edit selector.
"", // Status selector.
"", // Bible selector.
user, // Assignment selector.
0, // Subscription selector.
-1, // Severity selector.
0, // Text selector.
"", // Search text.
-1); // Limit.
body.push_back ("<p><a href=\"" + siteUrl + notes_index_url () + "?presetselection=assigned\">" + translate("Number of consultation notes assigned to you awaiting your response") + "</a>: " + convert_to_string (ids.size ()) + "</p>\n");
}
if (request.database_config_user()->getUserSubscribedNotesStatisticsNotification (user)) {
body.push_back ("<p>" + translate("Number of consultation notes you are subscribed to") + ":</p>\n");
body.push_back ("<ul>\n");
request.session_logic ()->setUsername (user);
vector <int> ids = database_notes.selectNotes (
bibles, // Bible.
0, // Book
0, // Chapter
0, // Verse
3, // Passage selector.
0, // Edit selector.
0, // Non-edit selector.
"", // Status selector.
"", // Bible selector.
"", // Assignment selector.
1, // Subscription selector.
-1, // Severity selector.
0, // Text selector.
"", // Search text.
-1); // Limit.
body.push_back ("<li><a href=\"" + siteUrl + notes_index_url () + "?presetselection=subscribed\">" + translate("Total") + "</a>: " + convert_to_string (ids.size ()) + "</li>\n");
ids = database_notes.selectNotes (
bibles, // Bible.
0, // Book
0, // Chapter
0, // Verse
3, // Passage selector.
0, // Edit selector.
1, // Non-edit selector.
"", // Status selector.
"", // Bible selector.
"", // Assignment selector.
1, // Subscription selector.
-1, // Severity selector.
0, // Text selector.
"", // Search text.
-1); // Limit.
body.push_back ("<li><a href=\"" + siteUrl + notes_index_url () + "?presetselection=subscribeddayidle\">" + translate("Inactive for a day") + "</a>: " + convert_to_string (ids.size ()) + "</li>\n");
ids = database_notes.selectNotes (
bibles, // Bible.
0, // Book
0, // Chapter
0, // Verse
3, // Passage selector.
0, // Edit selector.
3, // Non-edit selector.
"", // Status selector.
//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:statistics.cpp
示例10: main
int main (int argc, char * argv[])
{
std::streambuf *psbuf = NULL;
std::ofstream log_stream;
std::streambuf *pStreambuf = std::cout.rdbuf();
//--------------RNG INIT STUFF
srand((unsigned)time(0));
long seed;
r = gsl_rng_alloc (gsl_rng_rand48); // pick random number generator
seed = time (NULL) * getpid();
gsl_rng_set (r, seed); // set seed
// TESTING AREA
//---------------
DBN *dbn;
if (command_option_exists(argv, argv+argc, "-n")) {
dbn = return_network();
std::cout << dbn << std::endl;
std::cout << "Ready to learn" << std::endl;
std::cout << "If you are using visualization:" << std::endl;
std::cout << "'V': pauses visualization" << std::endl;
std::cout << "<SPACE>: pauses learning" << std::endl;
std::cout << "'+'/'-' increases/decreases learning rate" << std::endl;
std::cout << "'['/']' increases/decreases output threshold" << std::endl;
std::cout << "'L' stops learning for layer (skips to next if any)" << std::endl;
std::cout << "Current visualization is the features displayed on top with the plot of the reconstruction cost in the box (gl text not supported yet)" << std::endl;
std::cout << "Press <ENTER> to start learning: ";
std::cin.get();
}
else if (command_option_exists(argv, argv+argc, "-l")) {
std::string filename = get_command_line(argv, argv+argc, "-l");
MLP mlp = load_MLP(filename);
dbn = new DBN(mlp);
dbn->data_layers.clear();
dbn->view();
exit(EXIT_SUCCESS);
}
else if (command_option_exists(argv, argv+argc, "-f")) {
if (argc != 3) {
print_usage();
exit(EXIT_FAILURE);
}
//Initialization, time, logfile stuff, etc.
time_t t = time(0); // get time now
struct tm * the_time = localtime( & t );
mkdir(out_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
out_path += convert_to_string(*the_time) + "/";
mkdir((out_path).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::string filename = get_command_line(argv, argv+argc, "-f");
dbn = return_aod_network(filename, log_stream, psbuf);
}
else if (command_option_exists(argv, argv+argc, "-F")) {
std::string filename = get_command_line(argv, argv+argc, "-F");
MLP mlp = load_MLP(filename);
Autoencoder ae(mlp);
ae.name = (mlp).name + "fine_tuning";
Gradient_Descent gd(0);
gd.teachAE(ae);
MLP ae_mlp;
save(ae);
exit(EXIT_SUCCESS);
}
else if (command_option_exists(argv, argv+argc, "-stack")) {
std::string filename = get_command_line(argv, argv+argc, "-stack");
dbn = load_and_stack(filename, log_stream, psbuf);
}
else {
print_usage();
exit(EXIT_SUCCESS);
}
ContrastiveDivergence cd(1000);
dbn->learn(cd);
std::cout.rdbuf(pStreambuf);
log_stream.close();
exit(1);
return 0;
}
开发者ID:rdevon,项目名称:DBN,代码行数:83,代码来源:main.cpp
示例11: search_strong
string search_strong (void * webserver_request)
{
Webserver_Request * request = (Webserver_Request *) webserver_request;
Database_Kjv database_kjv = Database_Kjv ();
string bible = request->database_config_user()->getBible ();
if (request->query.count ("b")) {
bible = request->query ["b"];
}
if (request->query.count ("load")) {
int book = Ipc_Focus::getBook (request);
int chapter = Ipc_Focus::getChapter (request);
int verse = Ipc_Focus::getVerse (request);
// Get Strong's numbers, plus English snippets.
string html = "<table>\n";
vector <Database_Kjv_Item> details = database_kjv.getVerse (book, chapter, verse);
for (auto & detail : details) {
string strong = detail.strong;
string english = detail.english;
html += "<tr><td><a href=\"" + strong + "\">" + strong + "</a></td><td>" + english + "</td></tr>\n";
}
html += "</table>\n";
return html;
}
if (request->query.count ("strong")) {
string strong = request->query ["strong"];
strong = filter_string_trim (strong);
vector <int> passages;
vector <Passage> details = database_kjv.searchStrong (strong);
for (auto & passage : details) {
int i_passage = filter_passage_to_integer (passage);
passages.push_back (i_passage);
}
passages = array_unique (passages);
sort (passages.begin(), passages.end());
string output;
for (auto & passage : passages) {
if (!output.empty()) output.append ("\n");
output.append (convert_to_string (passage));
}
return output;
}
if (request->query.count ("id")) {
int id = convert_to_int (request->query ["id"]);
// Get the and passage for this identifier.
Passage passage = filter_integer_to_passage (id);
int book = passage.book;
int chapter = passage.chapter;
string verse = passage.verse;
// Get the plain text.
string text = search_logic_get_bible_verse_text (bible, book, chapter, convert_to_int (verse));
// Format it.
string link = filter_passage_link_for_opening_editor_at (book, chapter, verse);
string output = "<div>" + link + " " + text + "</div>";
// Output to browser.
return output;
}
string page;
Assets_Header header = Assets_Header (translate("Search"), request);
header.setNavigator ();
header.addBreadCrumb (menu_logic_search_menu (), menu_logic_search_text ());
page = header.run ();
Assets_View view;
view.set_variable ("bible", bible);
string script = "var searchBible = \"" + bible + "\";";
view.set_variable ("script", script);
page += view.render ("search", "strong");
page += Assets_Page::footer ();
return page;
//.........这里部分代码省略.........
开发者ID:alerque,项目名称:bibledit,代码行数:101,代码来源:strong.cpp
示例12: PHP_METHOD
/**
* Decrypts an encrypted text
*
*<code>
* echo $crypt->decrypt($encrypted, "decrypt password");
*</code>
*
* @param string $text
* @param string $key
* @return string
*/
PHP_METHOD(Phalcon_Crypt, decrypt){
zval *text, *key = NULL, *decrypt_key = NULL, *cipher, *mode, *iv_size = NULL;
zval *key_size, *text_size, *iv, *text_to_decipher, *decrypted = NULL;
zval *padding_type, *block_size = NULL;
zval *handler, *arguments = NULL, *value = NULL;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &text, &key);
if (phalcon_function_exists_ex(SS("mcrypt_get_iv_size") TSRMLS_CC) == FAILURE) {
PHALCON_THROW_EXCEPTION_STR(phalcon_crypt_exception_ce, "mcrypt extension is required");
return;
}
PHALCON_OBS_VAR(handler);
phalcon_read_property_this(&handler, this_ptr, SL("_beforeDecrypt"), PH_NOISY TSRMLS_CC);
if (phalcon_is_callable(handler TSRMLS_CC)) {
PHALCON_SEPARATE_PARAM(text);
PHALCON_INIT_NVAR(arguments);
array_init_size(arguments, 1);
phalcon_array_append(&arguments, text, 0);
PHALCON_INIT_NVAR(value);
PHALCON_CALL_USER_FUNC_ARRAY(value, handler, arguments);
PHALCON_CPY_WRT(text, value);
}
if (!key || Z_TYPE_P(key) == IS_NULL) {
decrypt_key = phalcon_fetch_nproperty_this(this_ptr, SL("_key"), PH_NOISY TSRMLS_CC);
} else {
decrypt_key = key;
}
if (PHALCON_IS_EMPTY(decrypt_key)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_crypt_exception_ce, "Decryption key cannot be empty");
return;
}
cipher = phalcon_fetch_nproperty_this(this_ptr, SL("_cipher"), PH_NOISY TSRMLS_CC);
mode = phalcon_fetch_nproperty_this(this_ptr, SL("_mode"), PH_NOISY TSRMLS_CC);
PHALCON_CALL_FUNCTION(&iv_size, "mcrypt_get_iv_size", cipher, mode);
if (unlikely(Z_TYPE_P(iv_size) != IS_LONG)) {
convert_to_long(iv_size);
}
PHALCON_INIT_VAR(key_size);
phalcon_fast_strlen(key_size, decrypt_key);
if (PHALCON_GT(key_size, iv_size)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_crypt_exception_ce, "Size of key is too large for this algorithm");
return;
}
PHALCON_INIT_VAR(text_size);
phalcon_fast_strlen(text_size, text);
if (PHALCON_GT(key_size, text_size)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_crypt_exception_ce, "Size of IV is larger than text to decrypt");
return;
}
PHALCON_INIT_VAR(iv);
phalcon_substr(iv, text, 0, Z_LVAL_P(iv_size));
PHALCON_INIT_VAR(text_to_decipher);
phalcon_substr(text_to_decipher, text, Z_LVAL_P(iv_size), 0);
PHALCON_CALL_FUNCTION(&decrypted, "mcrypt_decrypt", cipher, decrypt_key, text_to_decipher, mode, iv);
if (unlikely(Z_TYPE_P(decrypted) != IS_STRING)) {
convert_to_string(decrypted);
}
PHALCON_CALL_FUNCTION(&block_size, "mcrypt_get_block_size", cipher, mode);
if (unlikely(Z_TYPE_P(block_size) != IS_LONG)) {
convert_to_long(block_size);
}
padding_type = phalcon_fetch_nproperty_this(this_ptr, SL("_padding"), PH_NOISY TSRMLS_CC);
assert(Z_TYPE_P(padding_type) == IS_LONG);
assert(Z_TYPE_P(block_size) == IS_LONG);
assert(Z_TYPE_P(mode) == IS_STRING);
assert(Z_TYPE_P(decrypted) == IS_STRING);
phalcon_crypt_unpad_text(return_value, decrypted, mode, Z_LVAL_P(block_size), Z_LVAL_P(padding_type) TSRMLS_CC);
//.........这里部分代码省略.........
开发者ID:tianhendi,项目名称:cphalcon,代码行数:101,代码来源:crypt.c
示例13: call_php
//.........这里部分代码省略.........
l = *(ISC_INT64*)argv[i]->dsc_address;
if (argv[i]->dsc_scale == 0 && l <= LONG_MAX && l >= LONG_MIN) {
ZVAL_LONG(&args[i], (long)l);
} else {
ZVAL_DOUBLE(&args[i], ((double)l)/scales[-argv[i]->dsc_scale]);
}
break;
case dtype_real:
ZVAL_DOUBLE(&args[i], *(float*)argv[i]->dsc_address);
break;
case dtype_double:
ZVAL_DOUBLE(&args[i], *(double*)argv[i]->dsc_address);
break;
case dtype_sql_date:
isc_decode_sql_date((ISC_DATE*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.dateformat"), &t),1);
break;
case dtype_sql_time:
isc_decode_sql_time((ISC_TIME*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.timeformat"), &t),1);
break;
case dtype_timestamp:
isc_decode_timestamp((ISC_TIMESTAMP*)argv[i]->dsc_address, &t);
ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.timestampformat"), &t));
break;
}
}
LOCK();
/* now call the function */
if (FAILURE == call_user_function(EG(function_table), NULL,
&callback, &return_value, argc, args)) {
UNLOCK();
break;
}
UNLOCK();
for (i = 0; i < argc; ++i) {
switch (argv[i]->dsc_dtype) {
case dtype_sql_date:
case dtype_sql_time:
case dtype_timestamp:
zval_dtor(&args[i]);
}
}
zval_dtor(&callback);
/* return whatever type we got back from the callback: let DB handle conversion */
switch (Z_TYPE(return_value)) {
case IS_LONG:
r->dsc_dtype = dtype_long;
*(long*)r->dsc_address = Z_LVAL(return_value);
r->dsc_length = sizeof(long);
break;
case IS_DOUBLE:
r->dsc_dtype = dtype_double;
*(double*)r->dsc_address = Z_DVAL(return_value);
r->dsc_length = sizeof(double);
break;
case IS_NULL:
r->dsc_flags |= DSC_null;
break;
default:
convert_to_string(&return_value);
case IS_STRING:
r->dsc_dtype = dtype_varying;
memcpy(res->vary_string, Z_STRVAL(return_value),
(res->vary_length = min(r->dsc_length-2,Z_STRLEN(return_value))));
r->dsc_length = res->vary_length+2;
break;
}
zval_dtor(&return_value);
return;
} while (0);
/**
* If we end up here, we should report an er
|
请发表评论