当前位置: 首页>>代码示例>>C++>>正文


C++ ustring::empty方法代码示例

本文整理汇总了C++中ustring::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::empty方法的具体用法?C++ ustring::empty怎么用?C++ ustring::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ustring的用法示例。


在下文中一共展示了ustring::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processAllMessages

/*
 * 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);
	}
}
开发者ID:iqrfsdk,项目名称:clibcdc-windows,代码行数:33,代码来源:CDCImpl.cpp

示例2: uncompress

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);
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:57,代码来源:compress.cpp

示例3: MakeSDDL

	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;
	}
开发者ID:pombreda,项目名称:main,代码行数:12,代码来源:sd_makesddl.cpp

示例4: notes_read_one_from_file

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);
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:49,代码来源:notes_utils.cpp

示例5: select_file_name

/// 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;
}
开发者ID:BackupTheBerlios,项目名称:pinot-svn,代码行数:32,代码来源:PinotUtils.cpp

示例6: string_append_line

void string_append_line(ustring & container, const ustring & line)
{
  if (!container.empty()) {
    container.append("\n");
  }
  container.append(line);
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:7,代码来源:utilities.cpp

示例7: mytitle

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;
}
开发者ID:alerque,项目名称:bibledit,代码行数:35,代码来源:gtkwrappers.cpp

示例8: gtkw_file_chooser_select_folder

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;
}
开发者ID:alerque,项目名称:bibledit,代码行数:32,代码来源:gtkwrappers.cpp

示例9: Draw

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)
开发者ID:AMDmi3,项目名称:ValyriaTear,代码行数:59,代码来源:text.cpp

示例10: addString

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;
}
开发者ID:aconty,项目名称:OpenShadingLanguage,代码行数:56,代码来源:stringtable.cpp

示例11: Devoice

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);
    }
}
开发者ID:WizardGed,项目名称:lostirc,代码行数:11,代码来源:GuiCommands.cpp

示例12: add

	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));
	}
开发者ID:IDA-RE-things,项目名称:andrew-grechkin,代码行数:11,代码来源:user.cpp

示例13: Kick

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);
    }
}
开发者ID:WizardGed,项目名称:lostirc,代码行数:11,代码来源:GuiCommands.cpp

示例14: bitpattern_take

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;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:12,代码来源:utilities.cpp

示例15: load_filters

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();
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:12,代码来源:dialogfilters.cpp


注:本文中的ustring::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。