示例#1
0
/*
 * Extracts and processes all messages inside the specified buffer.
 * @throw CDCReading Exception
 */
void CDCImplPrivate::processAllMessages(ustring& msgBuffer) {
	if (msgBuffer.empty()) {
		return;
	}

	ParsedMessage parsedMessage = parseNextMessage(msgBuffer);
	while ( parsedMessage.parseResult.resultType != PARSE_NOT_COMPLETE ) {
		if ( parsedMessage.parseResult.resultType == PARSE_BAD_FORMAT ) {
			// throw all bytes from the buffer up to next 0x0D
			size_t endMsgPos = msgBuffer.find(0x0D, parsedMessage.parseResult.lastPosition);
			if (endMsgPos == string::npos) {
				msgBuffer.clear();
			}  else {
				msgBuffer.erase(0, endMsgPos+1);
			}

			setLastReceptionError("Bad message format");
		} else {
			msgBuffer.erase(0, parsedMessage.parseResult.lastPosition+1);
			processMessage(parsedMessage);
		}

		if (msgBuffer.empty()) {
			return;
		}

		parsedMessage = parseNextMessage(msgBuffer);
	}
}
示例#2
0
bool uncompress(const ustring & archive, const ustring & directory)
// Uncompresses "archive" into "directory".
// Returns whether this was successful.
{
  // Bail out if the archive was not recognized.
  if (!compressed_archive_recognized(archive)) {
    gw_critical(_("cannot uncompress unrecognized archive"));
    return false;
  }
  // Ensure that the output directory is there.
  gw_mkdir_with_parents (directory);

  // Get the uncompression identifier.
  int uncompression_identifier = uncompression_identifier_get (archive);

  // Do the uncompression.
  int result = -1;
  switch (uncompression_identifier) {
  case 0:
    {
		gw_message("I'm not yet smart enough to handle the " + archive + " file type");
		break;
    }
  case 1:
    { // If you have a zip utility installed in Windows, etc.
      GwSpawn spawn (Directories->get_unzip());
      spawn.arg ("-o"); // overwrite without prompting
      if (!directory.empty ()) {
        spawn.arg ("-d"); // extract files into exdir
        spawn.arg (directory);
      }
      spawn.arg (archive);
      spawn.progress (_("Unpacking"), false);
      spawn.run ();
      result = 0;
      break;
    }
  case 2:
    {
      GwSpawn spawn(Directories->get_tar());
	  spawn.arg ("--force-local"); // to permit : in filename (like C:\Users\...)
      spawn.arg("-xvzf"); // x=eXtract, z=gunZip, f=Filename to extract
      if (!directory.empty()) {
        spawn.workingdirectory(directory);
      }
      spawn.arg(archive);
      spawn.progress(_("Unpacking"), false);
      spawn.run();
      result = spawn.exitstatus;
	  DEBUG("tar return code="+std::to_string(result));
      break;
    }
  }

  // Return whether things were ok.  
  return (result == 0);
}
示例#3
0
	ustring MakeSDDL(const ustring &name, const ustring &group, mode_t mode, bool protect) {
		ustring Result;
		if (!name.empty())
			Result = Result + L"O:" + Sid(name.c_str()).as_str();
		if (!group.empty())
			Result = Result + L"G:" + Sid(group.c_str()).as_str();
		Result += L"D:";
		if (protect)
			Result += L"P";
		Result += Mode2Sddl(name, group, mode);
		return Result;
	}
示例#4
0
void notes_read_one_from_file (int id, ustring& note, ustring& project, ustring& references, ustring& category, int& date_created, ustring& user_created, int& date_modified, ustring& logbook)
{
    note.clear();
    logbook.clear();
    ustring filename = notes_file_name (id);
    ReadText rt (filename, true, false);
    bool logbook_indicator_encountered = false;
    for (unsigned int i = 0; i < rt.lines.size(); i++) {
        ustring line = rt.lines[i];
        if (i == 0) {
            // Retrieve date created.
            date_created = convert_to_int (line);
        }
        else if (i == 1) {
            // Retrieve user who created it.
            user_created = line;
        }
        else if (i == 2) {
            // Retrieve references.
            references = line;
        }
        else if (i == 3) {
            // Retrieve category.
            category = line;
        }
        else if (i == 4) {
            // Retrieve project.
            project = line;
        }
        else if (i == 5) {
            // Retrieve date modified.
            date_modified = convert_to_int (line);
        }
        else if (line == notes_logbook_line ()) {
            logbook_indicator_encountered = true;
        }
        else {
            if (logbook_indicator_encountered) {
                if (!logbook.empty()) logbook.append ("\n");
                logbook.append (line);
            } else {
                if (!note.empty()) note.append ("\n");
                note.append (line);
            }
        }
    }
    note = trim (note);
    logbook = trim (logbook);
}
示例#5
0
/// Open a FileChooserDialog.
bool select_file_name(const ustring &title, ustring &location,
	bool openOrCreate, bool directoriesOnly)
{
	FileChooserDialog fileChooser(title);

	if (title.empty() == true)
	{
		return false;
	}

	prepare_file_chooser(fileChooser, location, openOrCreate, directoriesOnly);
	fileChooser.show();

	int result = fileChooser.run();
	if (result == RESPONSE_OK)
	{
		// Retrieve the chosen location
		if (directoriesOnly == false)
		{
			location = filename_to_utf8(fileChooser.get_filename());
		}
		else
		{
			location = filename_to_utf8(fileChooser.get_current_folder());
		}

		return true;
	}

	return false;
}
示例#6
0
void string_append_line(ustring & container, const ustring & line)
{
  if (!container.empty()) {
    container.append("\n");
  }
  container.append(line);
}
示例#7
0
vector < ustring > gtkw_file_chooser_open_multiple(GtkWidget * parent, const ustring & title, ustring directory)
// Allows the user to select multiple files.
// parent: window will be centered on parent, or NULL.
// title: If given, will be title for the dialog.
// directory: If given, will be the directory to look in.
// Returns the files that were selected, or is empty if no selection was made.
{
  // Initialize variables.
  vector < ustring > selection;
  ustring mytitle(title);
  if (mytitle.empty())
    mytitle = _("Select a file");
  // Create dialog.
  GtkWidget *dialog;
  dialog = gtk_file_chooser_dialog_new(mytitle.c_str(), GTK_WINDOW(parent), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
  if (directory.empty())
    directory = g_get_home_dir();
  gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), directory.c_str());
  gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), true);
  // Run dialog.
  if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
    GSList *filenames1 = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
    GSList *filenames2 = filenames1;
    while (filenames1) {
      selection.push_back((gchar *) filenames1->data);
      g_free(filenames1->data);
      filenames1 = filenames1->next;
    }
    g_slist_free(filenames2);
  }
  // Destroy dialog
  gtk_widget_destroy(dialog);
  // Return selection.
  return selection;
}
示例#8
0
ustring gtkw_file_chooser_select_folder(GtkWidget * parent, const ustring & title, const ustring & directory)
// Allows user to select a folder.
// parent: window will be centered on parent, or NULL.
// title: If given, will be title for the dialog.
// directory: If given, will be directory selected by default.
// Returns the folder selected, or is empty if no selection was made.
{
  // Initialize variables.
  ustring selection;
  ustring mytitle(title);
  if (mytitle.empty())
    mytitle = _("Select a folder");
  ustring mydirectory(directory);
  if (mydirectory.empty())
    mydirectory = g_get_home_dir();
  mydirectory.append(G_DIR_SEPARATOR_S);
  // Create dialog.
  GtkWidget *dialog;
  dialog = gtk_file_chooser_dialog_new(mytitle.c_str(), GTK_WINDOW(parent), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
  gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), mydirectory.c_str());
  if (directory.empty()) {
    gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir());
  }
  // Run dialog.
  if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
    selection = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
  }
  // Destroy dialog
  gtk_widget_destroy(dialog);
  // Return selection.
  return selection;
}
示例#9
0
void TextSupervisor::Draw(const ustring &text, const TextStyle &style)
{
    if(text.empty()) {
        IF_PRINT_WARNING(VIDEO_DEBUG) << "empty string was passed to function" << std::endl;
        return;
    }

    if(IsFontValid(style.font) == false) {
        IF_PRINT_WARNING(VIDEO_DEBUG) << "failed because font was invalid: " << style.font << std::endl;
        return;
    }

    FontProperties *fp = _font_map[style.font];
    VideoManager->PushState();

    // Break the string into lines and render the shadow and text for each line
    uint16 buffer[2048];
    const uint16 NEWLINE = '\n';
    size_t last_line = 0;
    do {
        // Find the next new line character in the string and save the line
        size_t next_line;
        for(next_line = last_line; next_line < text.length(); next_line++) {
            if(text[next_line] == NEWLINE)
                break;

            buffer[next_line - last_line] = text[next_line];
        }
        buffer[next_line - last_line] = 0;
        last_line = next_line + 1;

        // If this line is empty, skip on to the next one
        if(buffer[0] == 0) {
            VideoManager->MoveRelative(0, -fp->line_skip * VideoManager->_current_context.coordinate_system.GetVerticalDirection());
            continue;
        }

        // Save the draw cursor position before drawing this text
        VideoManager->PushMatrix();

        // If text shadows are enabled, draw the shadow first
        if(style.shadow_style != VIDEO_TEXT_SHADOW_NONE) {
            VideoManager->PushMatrix();
            const float dx = VideoManager->_current_context.coordinate_system.GetHorizontalDirection() * style.shadow_offset_x;
            const float dy = VideoManager->_current_context.coordinate_system.GetVerticalDirection() * style.shadow_offset_y;
            VideoManager->MoveRelative(dx, dy);
            _DrawTextHelper(buffer, fp, _GetTextShadowColor(style));
            VideoManager->PopMatrix();
        }

        // Now draw the text itself, restore the position of the draw cursor, and move the draw cursor one line down
        _DrawTextHelper(buffer, fp, style.color);
        VideoManager->PopMatrix();
        VideoManager->MoveRelative(0, -fp->line_skip * VideoManager->_current_context.coordinate_system.GetVerticalDirection());

    } while(last_line < text.length());

    VideoManager->PopState();
} // void TextSupervisor::Draw(const ustring& text)
示例#10
0
uint64_t StringTable::addString (ustring str, ustring var_name)
{
    ASSERT (m_ptr && "StringTable has not been initialized");

    // The strings are laid out in the table as a struct:
    //
    //   struct TableRep {
    //       size_t len;
    //       size_t hash;
    //       char   str[len+1];
    //   };

    // Compute the size of the entry before adding it to the table 
    size_t size = sizeof(size_t) + sizeof(size_t) + str.size() + 1;
    if (((m_offset + size) >= m_size)) {
        reallocTable();
    }

    // It should be hard to trigger this assert, unless the table size is
    // very small and the string is very large.
    ASSERT (m_offset + size <= m_size && "String table allocation error");

    int offset = getOffset(str.string());
    if (offset < 0) {
        // Place the hash and length of the string before the characters
        size_t hash = str.hash();
        cudaMemcpy (m_ptr + m_offset, (void*)&hash, sizeof(size_t), cudaMemcpyHostToDevice);
        m_offset += sizeof(size_t);

        size_t len = str.length();
        cudaMemcpy (m_ptr + m_offset, (void*)&len, sizeof(size_t), cudaMemcpyHostToDevice);
        m_offset += sizeof(size_t);

        offset = m_offset;
        m_offset_map [str] = offset;
        m_name_map   [str] = var_name;

        // Copy the raw characters to the table
        cudaMemcpy (m_ptr + m_offset, str.c_str(), str.size() + 1, cudaMemcpyHostToDevice);
        m_offset += str.size() + 1;

        // Align the offset for the next entry to 8-byte boundaries
        m_offset = (m_offset + 0x7u) & ~0x7u;
    }

    uint64_t addr = reinterpret_cast<uint64_t>(m_ptr + offset);

    // Optionally create an OptiX variable for the string. It's not necessary to
    // create a variable for strings that do not appear by name in compiled code
    // (in either the OSL library functions or in the renderer).
    if (! var_name.empty()) {
        m_optix_ctx [var_name.string()]->setUserData (8, &addr);
    }

    return addr;
}
示例#11
0
void Devoice(ServerConnection *conn, const ustring& params)
{
    if (params.empty()) {
        throw CommandException(_("/DEVOICE <nicks>, devoices one or more users in the current channel."));

    } else {
        ustring channel = AppWin->getNotebook().getCurrent()->getName();
        ustring param = channel + " " + params;
        Commands::Devoice(conn, param);
    }
}
示例#12
0
	void User::add(const ustring & name, const ustring & pass, const ustring & dom) {
		DWORD dwLevel = 1;
		USER_INFO_1 info = {0};
		info.usri1_name = const_cast<wchar_t*>(name.c_str());
		info.usri1_password = const_cast<wchar_t*>(pass.c_str());
		info.usri1_priv = USER_PRIV_USER;
		info.usri1_flags = UF_SCRIPT | UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD;
		if (pass.empty())
			info.usri1_flags |= UF_PASSWD_NOTREQD;
		CheckApiError(::NetUserAdd(dom.c_str(), dwLevel, (PBYTE)&info, nullptr));
	}
示例#13
0
void Kick(ServerConnection *conn, const ustring& params)
{
    if (params.empty()) {
        throw CommandException(_("/KICK <nick>, kick a user from a channel."));

    } else {
        ustring channel = AppWin->getNotebook().getCurrent()->getName();
        ustring param = channel + " " + params;
        Commands::Kick(conn, param);
    }
}
示例#14
0
bool bitpattern_take(ustring & pattern)
// Return the next bit from "pattern" and removes it from that string.
// This implies that settngs from the pattern must be taken in the same order
// that they were added.
{
  bool setting = false;
  if (!pattern.empty()) {
    setting = convert_to_bool(pattern.substr(0, 1));
    pattern.erase(0, 1);
  }
  return setting;
}
示例#15
0
void FiltersDialog::load_filters(const ustring & selection)
{
  vector < ustring > filters = scripts_get_all();
  combobox_set_strings(combobox_filters, filters);
  if (!selection.empty())
    combobox_set_string(combobox_filters, selection);
  else if (filters.size() > 1)
    combobox_set_index(combobox_filters, 1);
  else
    combobox_set_index(combobox_filters, 0);
  on_combobox_filters();
}
示例#16
0
ustring Reference::human_readable(const ustring & language)
// Gives a reference in a human readable format. If no language is given,
// it takes the English names of the books.
{
  ustring s;
  if (language.empty())
    s.append(books_id_to_english(book));
  else
    s.append(books_id_to_name(language, book));
  s.append(" ");
  s.append(convert_to_string(chapter));
  s.append(":");
  s.append(verse);
  return s;
}
示例#17
0
	WinAbsSD::WinAbsSD(const ustring& name, const ustring& group, bool prot):
		m_owner(nullptr),
		m_group(nullptr),
		m_dacl(nullptr),
		m_sacl(nullptr)
	{
		m_sd = alloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
		CheckApi(::InitializeSecurityDescriptor(m_sd, SECURITY_DESCRIPTOR_REVISION));
		m_dacl = WinDacl::create(64);

		if (!name.empty()) {
			try {
				Sid usr(name.c_str());
				DWORD ownerSize = SECURITY_MAX_SID_SIZE;
				m_owner = (PSID)::LocalAlloc(LPTR, ownerSize);
				usr.copy_to(m_owner, ownerSize);
			} catch (...) {
			}
		}

		if (!group.empty()) {
			try {
				DWORD groupSize = SECURITY_MAX_SID_SIZE;
				m_group = (PSID)::LocalAlloc(LPTR, groupSize);
				Sid grp(group.c_str());
				grp.copy_to(m_group, groupSize);
			} catch (...) {
			}
		}

		set_owner(m_sd, m_owner);
		set_group(m_sd, m_group);
		set_dacl(m_sd, m_dacl);
		CheckApi(::IsValidSecurityDescriptor(m_sd));
		set_protect(prot);
	}
示例#18
0
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.book = books_bibleworks_to_id (parse.words[1]);
  reference.chapter = convert_to_int (parse.words[2]);
  reference.verse = parse.words[3];  
  return true;
}
示例#19
0
/// Prepare a FileChooser.
bool prepare_chooser(FileChooser *pChooser, ustring &location,
	bool openOrCreate, bool directoriesOnly)
{
	FileChooserAction chooserAction = FILE_CHOOSER_ACTION_OPEN;

	// Have we been provided with an initial location ?
	if (location.empty() == true)
	{
		// No, get the location of the home directory then
		char *homeDir = getenv("HOME");
		if (homeDir != NULL)
		{
			location = homeDir;
			location += "/";
		}
	}

	if (directoriesOnly == false)
	{
		if (openOrCreate == true)
		{
			chooserAction = FILE_CHOOSER_ACTION_OPEN;
		}
		else
		{
			chooserAction = FILE_CHOOSER_ACTION_SAVE;
		}
	}
	else
	{
		if (openOrCreate == true)
		{
			chooserAction = FILE_CHOOSER_ACTION_SELECT_FOLDER;
		}
		else
		{
			chooserAction = FILE_CHOOSER_ACTION_CREATE_FOLDER;
		}
	}

	pChooser->set_action(chooserAction);
	pChooser->set_filename(filename_from_utf8(location));
	pChooser->set_local_only();
	pChooser->set_select_multiple(false);
	// FIXME: add FileFilter's

	return false;
}
示例#20
0
/**
 Sets the %document's subject to \p subject.
 If \p subject is empty, the %document's subject is removed.

 \returns true on success, false on failure
 */
bool document::set_subject(const ustring &subject)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_subject;

    if (subject.empty()) {
        goo_subject = NULL;
    } else {
        goo_subject = detail::ustring_to_unicode_GooString(subject);
    }

    d->doc->setDocInfoSubject(goo_subject);
    return true;
}
示例#21
0
/**
 Sets the value of the specified \p key of the %document information to \p val.
 If \p val is empty, the entry specified by \p key is removed.

 \returns true on success, false on failure
 */
bool document::set_info_key(const std::string &key, const ustring &val)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_val;

    if (val.empty()) {
        goo_val = NULL;
    } else {
        goo_val = detail::ustring_to_unicode_GooString(val);
    }

    d->doc->setDocInfoStringEntry(key.c_str(), goo_val);
    return true;
}
示例#22
0
/**
 Sets the %document's producer to \p producer.
 If \p producer is empty, the %document's producer is removed.

 \returns true on success, false on failure
 */
bool document::set_producer(const ustring &producer)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_producer;

    if (producer.empty()) {
        goo_producer = NULL;
    } else {
        goo_producer = detail::ustring_to_unicode_GooString(producer);
    }

    d->doc->setDocInfoProducer(goo_producer);
    return true;
}
示例#23
0
/**
 Sets the %document's keywords to \p keywords.
 If \p keywords is empty, the %document's keywords are removed.

 \returns true on success, false on failure
 */
bool document::set_keywords(const ustring &keywords)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_keywords;

    if (keywords.empty()) {
        goo_keywords = NULL;
    } else {
        goo_keywords = detail::ustring_to_unicode_GooString(keywords);
    }

    d->doc->setDocInfoKeywords(goo_keywords);
    return true;
}
示例#24
0
/**
 Sets the %document's creator to \p creator.
 If \p creator is empty, the %document's creator is removed.

 \returns true on success, false on failure
 */
bool document::set_creator(const ustring &creator)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_creator;

    if (creator.empty()) {
        goo_creator = NULL;
    } else {
        goo_creator = detail::ustring_to_unicode_GooString(creator);
    }

    d->doc->setDocInfoCreator(goo_creator);
    return true;
}
示例#25
0
/**
 Sets the %document's title to \p title.
 If \p title is empty, the %document's title is removed.

 \returns true on success, false on failure
 */
bool document::set_title(const ustring &title)
{
    if (d->is_locked) {
        return false;
    }

    GooString *goo_title;

    if (title.empty()) {
        goo_title = NULL;
    } else {
        goo_title = detail::ustring_to_unicode_GooString(title);
    }

    d->doc->setDocInfoTitle(goo_title);
    return true;
}
bool
SimpleRenderer::get_array_attribute (ShaderGlobals *sg, bool derivatives, ustring object,
                                     TypeDesc type, ustring name,
                                     int index, void *val)
{
    AttrGetterMap::const_iterator g = m_attr_getters.find (name);
    if (g != m_attr_getters.end()) {
        AttrGetter getter = g->second;
        return (this->*(getter)) (sg, derivatives, object, type, name, val);
    }

    // If no named attribute was found, allow userdata to bind to the
    // attribute request.
    if (object.empty() && index == -1)
        return get_userdata (derivatives, name, type, sg, val);

    return false;
}
示例#27
0
OdtTextParagraph::OdtTextParagraph(vector < ustring > *lines, const ustring & stylename)
// OpenDocument Text Text Paragraph.
// If no stylename is given, it takes the "Standard" style.
{
  // Save pointer, init variables.
  mylines = lines;
  mynewline = false;

  // Build the line.
  myline = "<text:p text:style-name=\"";
  if (stylename.empty())
    myline.append("Standard");
  else
    myline.append(stylename);
  myline.append("\">");

  // Line length.
  linelength = myline.length();
}
示例#28
0
/// Open a FileChooserDialog.
bool select_file_name(Window &parentWindow, const ustring &title,
	ustring &location, bool openOrCreate, bool directoriesOnly)
{
	FileChooserDialog fileChooser(title);
	StockID okButtonStockId = Stock::OPEN;

	if (title.empty() == true)
	{
		return false;
	}

	if (openOrCreate == false)
	{
		okButtonStockId = Stock::SAVE;
	}

	prepare_chooser(&fileChooser, location, openOrCreate, directoriesOnly);
	fileChooser.add_button(Stock::CANCEL, RESPONSE_CANCEL);
	fileChooser.add_button(okButtonStockId, RESPONSE_OK);
	// FIXME: add FileFilter's
	fileChooser.set_title(title);
	fileChooser.set_show_hidden(true);
	fileChooser.show();

	int result = fileChooser.run();
	if (result == RESPONSE_OK)
	{
		// Retrieve the chosen location
		if (directoriesOnly == false)
		{
			location = filename_to_utf8(fileChooser.get_filename());
		}
		else
		{
			location = filename_to_utf8(fileChooser.get_current_folder());
		}

		return true;
	}

	return false;
}
示例#29
0
ustring convert_bibleworks_greek (ustring line)
{
  ustring outputline;
  while (!line.empty()) {
    ustring character;
    bool converted = false;
    // Convert the combined characters.
    character = line.substr (0, 2);
    for (unsigned int i = 0; i < sizeof(bibleworks_greek_table_2) / sizeof(*bibleworks_greek_table_2); i++) {
      if (!converted) {
        if (character == bibleworks_greek_table_2[i].input) {
          outputline.append (bibleworks_greek_table_2[i].output);
          line.erase (0, 2);
          converted = true;
        }
      }
    }
    // Convert the single character.
    if (!converted) {
      character = line.substr (0, 1);
      for (unsigned int i = 0; i < sizeof(bibleworks_greek_table_1) / sizeof(*bibleworks_greek_table_1); i++) {
        if (!converted) {
          if (character == bibleworks_greek_table_1[i].input) {
            outputline.append (bibleworks_greek_table_1[i].output);
            line.erase (0, 1);
            converted = true;
          }
        }
      }
    }
    // Message if the conversion didn't work out.
    if (!converted) {
      gw_critical ("Output so far: " + outputline + " - unhandled character: " + character + " - input stream: " + line);
      outputline.append (character);
      line.erase (0, 1);
    }
  }
  return outputline;  
}
示例#30
0
int
main (int argc, char **argv)
{
    getargs (argc, argv);

    if (input_filename.empty()) {
        std::cout << "Error: Must supply a filename.\n";
        return -1;
    }

    imagecache = ImageCache::create ();
    imagecache->attribute ("forcefloat", 1);

    // Allocate a buffer big enough (for floats)
    bool ok = imagecache->get_imagespec (input_filename, spec);
    ASSERT (ok);
    imagecache->invalidate_all (true);  // Don't hold anything
    buffer.resize (spec.image_pixels()*spec.nchannels*sizeof(float), 0);

    {
        double t = time_trial (time_read_image, ntrials);
        std::cout << "image_read speed: " << Strutil::timeintervalformat(t,2) << "\n";
    }

    {
        double t = time_trial (time_read_imagebuf, ntrials);
        std::cout << "ImageBuf read speed: " << Strutil::timeintervalformat(t,2) << "\n";
    }

    {
        double t = time_trial (time_ic_get_pixels, ntrials);
        std::cout << "ImageCache get_pixels speed: " << Strutil::timeintervalformat(t,2) << "\n";
    }

    imagecache->invalidate_all (true);  // Don't hold anything

    ImageCache::destroy (imagecache);
    return unit_test_failures;
}