• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ustring类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ASTNode

ASTfunction_declaration::ASTfunction_declaration (OSLCompilerImpl *comp,
                             TypeSpec type, ustring name,
                             ASTNode *form, ASTNode *stmts, ASTNode *meta)
    : ASTNode (function_declaration_node, comp, 0, meta, form, stmts),
      m_name(name), m_sym(NULL), m_is_builtin(false)
{
    m_typespec = type;
    Symbol *f = comp->symtab().clash (name);
    if (f && f->symtype() != SymTypeFunction) {
        error ("\"%s\" already declared in this scope as a ", name.c_str(),
               f->typespec().string().c_str());
        // FIXME -- print the file and line of the other definition
        f = NULL;
    }

    // FIXME -- allow multiple function declarations, but only if they
    // aren't the same polymorphic type.

    if (name[0] == '_' && name[1] == '_' && name[2] == '_') {
        error ("\"%s\" : sorry, can't start with three underscores",
               name.c_str());
    }

    m_sym = new FunctionSymbol (name, type, this);
    func()->nextpoly ((FunctionSymbol *)f);
    std::string argcodes = oslcompiler->code_from_type (m_typespec);
    for (ASTNode *arg = form;  arg;  arg = arg->nextptr()) {
        const TypeSpec &t (arg->typespec());
        if (t == TypeSpec() /* UNKNOWN */) {
            m_typespec = TypeDesc::UNKNOWN;
            return;
        }
        argcodes += oslcompiler->code_from_type (t);
        ASSERT (arg->nodetype() == variable_declaration_node);
        ASTvariable_declaration *v = (ASTvariable_declaration *)arg;
        if (v->init())
            v->error ("function parameter '%s' may not have a default initializer.",
                      v->name().c_str());
    }
    func()->argcodes (ustring (argcodes));
    oslcompiler->symtab().insert (m_sym);

    // Typecheck it right now, upon declaration
    typecheck (typespec ());
}
开发者ID:boberfly,项目名称:gafferDependencies,代码行数:45,代码来源:ast.cpp


示例2: gw_path_get_dirname

ustring gw_path_get_dirname(const ustring & filename)
{
  ustring returnvalue;
  gchar *dirname;
  dirname = g_path_get_dirname(filename.c_str());
  returnvalue = dirname;
  g_free(dirname);
  return returnvalue;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:9,代码来源:gwrappers.cpp


示例3: gw_path_get_basename

ustring gw_path_get_basename(const ustring & filename)
{
  ustring returnvalue;
  gchar *basename;
  basename = g_path_get_basename(filename.c_str());
  returnvalue = basename;
  g_free(basename);
  return returnvalue;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:9,代码来源:gwrappers.cpp


示例4: getMarkedCharPos

    _size_t_ getMarkedCharPos (ustring ch) {
        _size_t_ mark =
            LettersWithMarks.find (removeAccentFromChar (ch.lowercase ()));

        if (mark != ustring::npos)
            mark %= LettersWithoutMarks.length ();

        return mark;
    }
开发者ID:ano-qml,项目名称:BoGoEngine,代码行数:9,代码来源:utils.cpp


示例5:

void CGlobalRecords::wide2str16(const ustring& str1, u16string& str2)
{
	ustring::const_iterator	cBegin, cEnd;
	size_t len;

	str2.clear();

	len = str1.length();
	str2.reserve(len);

	cBegin	= str1.begin();
	cEnd	= str1.end();

	while(cBegin != cEnd) {
		str2.push_back((unsigned16_t)*cBegin++);
	}
	XL_ASSERT(str2.length() == str1.length());
}
开发者ID:liudongbao,项目名称:xlslib-1,代码行数:18,代码来源:globalrec.cpp


示例6: parsePixbuf

void DataValue::parsePixbuf(const ustring &text, void *value) {
	gsize size;
	guchar *buf = g_base64_decode(text.c_str(), &size);
	Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
	loader->write(buf, size);
	loader->close();
	(*(TypePixbuf*)value) = loader->get_pixbuf();
	g_free(buf);
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:9,代码来源:ElementProperty.cpp


示例7: ascii_toupper

  inline ustring ascii_toupper(ustring str)
  {
    ustring ret;
    
    for (ustring::const_iterator it = str.begin();
	 it != str.end();
	 ++it)
    {
      uchar x = *it;
      
      if (x >= 0x61 && x <= 0x7A)
	x -= 0x20;
      
      ret.append(x);
    }
    
    return ret;
  }
开发者ID:nomovok-opensource,项目名称:frenzy,代码行数:18,代码来源:unicode.hpp


示例8: script_decode_usfm_file

void script_decode_usfm_file(const ustring & filename)
// Decodes a USFM file, that means, puts the original USFM code back.
{
  // Read the file. Bail out if there's no text.
  ustring input;
  {
    gchar *contents;
    g_file_get_contents(filename.c_str(), &contents, NULL, NULL);
    if (!contents)
      return;
    input = contents;
    g_free(contents);
  }
  if (input.empty())
    return;

  // Go through the input, changing usfm codes to their numerical equivalent,
  // and copying data to the output.
  // E.g. "\_105_100" would become "\id".
  ustring output;
  while (!input.empty()) {
    ustring character = input.substr(0, 1);
    input.erase(0, 1);
    output.append(character);
    if (character == "\\") {
      size_t pos = input.find(" ");
      if (pos == string::npos)
        pos = input.length();
      ustring encoded_text = input.substr(0, pos);
      input.erase(0, pos);
      Parse parse(encoded_text, false, "_");
      for (unsigned int i = 0; i < parse.words.size(); i++) {
        gunichar unichar = convert_to_int(parse.words[i]);
        gchar buf[7];
        gint length = g_unichar_to_utf8(unichar, (gchar *) & buf);
        buf[length] = '\0';
        character = buf;
        output.append(character);
      }
    }
  }
  // Write the data back to the file.
  g_file_set_contents(filename.c_str(), output.c_str(), -1, NULL);
}
开发者ID:githubber,项目名称:bibledit,代码行数:44,代码来源:scripts.cpp


示例9: ASTNode

ASTvariable_declaration::ASTvariable_declaration (OSLCompilerImpl *comp,
                                                  const TypeSpec &type,
                                                  ustring name, ASTNode *init,
                                                  bool isparam, bool ismeta,
                                                  bool isoutput, bool initlist)
    : ASTNode (variable_declaration_node, comp, 0, init, NULL /* meta */),
      m_name(name), m_sym(NULL), 
      m_isparam(isparam), m_isoutput(isoutput), m_ismetadata(ismeta),
      m_initlist(initlist)
{
    m_typespec = type;
    Symbol *f = comp->symtab().clash (name);
    if (f) {
        std::string e = Strutil::format ("\"%s\" already declared in this scope", name.c_str());
        if (f->node()) {
            boost::filesystem::path p(f->node()->sourcefile().string());
            e += Strutil::format ("\n\t\tprevious declaration was at %s:%d",
                                  p.filename().c_str(), f->node()->sourceline());
        }
        if (f->scope() == 0 && f->symtype() == SymTypeFunction && isparam) {
            // special case: only a warning for param to mask global function
            warning ("%s", e.c_str());
        } else {
            error ("%s", e.c_str());
        }
    }
    if (name[0] == '_' && name[1] == '_' && name[2] == '_') {
        error ("\"%s\" : sorry, can't start with three underscores",
               name.c_str());
    }
    SymType symtype = isparam ? (isoutput ? SymTypeOutputParam : SymTypeParam)
                              : SymTypeLocal;
    m_sym = new Symbol (name, type, symtype, this);
    if (! m_ismetadata)
        oslcompiler->symtab().insert (m_sym);

    // A struct really makes several subvariables
    if (type.is_structure() || type.is_structure_array()) {
        ASSERT (! m_ismetadata);
        // Add the fields as individual declarations
        m_compiler->add_struct_fields (type.structspec(), m_sym->name(),
                                       symtype, type.arraylength(), this);
    }
}
开发者ID:WooFL,项目名称:OpenShadingLanguage,代码行数:44,代码来源:ast.cpp


示例10: q

int
Dictionary::dict_find (int nodeID, ustring query)
{
    if (nodeID <= 0 || nodeID >= (int)m_nodes.size())
        return 0;     // invalid node ID

    const Dictionary::Node &node (m_nodes[nodeID]);
    Query q (node.document, nodeID, query);
    QueryMap::iterator qfound = m_cache.find (q);
    if (qfound != m_cache.end()) {
        return qfound->second.valueoffset;
    }

    // Query was not found.  Do the expensive lookup and cache it
    pugi::xpath_node_set matches;
    try {
        matches = node.node.select_nodes (query.c_str());
    }
    catch (const pugi::xpath_exception& e) {
        m_context->error ("Invalid dict_find query '%s': %s",
                          query.c_str(), e.what());
        return 0;
    }

    if (matches.empty()) {
        m_cache[q] = QueryResult (false);  // mark invalid
        return 0;   // Not found
    }
    int firstmatch = (int) m_nodes.size();
    int last = -1;
    for (int i = 0, e = (int)matches.size(); i < e;  ++i) {
        m_nodes.push_back (Node (node.document, matches[i].node()));
        int nodeid = (int) m_nodes.size()-1;
        if (last < 0) {
            // If this is the first match, add a cache entry for it
            m_cache[q] = QueryResult (true /* it's a node */, nodeid);
        } else {
            // If this is a subsequent match, set the last match's 'next'
            m_nodes[last].next = nodeid;
        }
        last = nodeid;
    }
    return firstmatch;
}
开发者ID:jamesvecore,项目名称:OpenShadingLanguage,代码行数:44,代码来源:dictionary.cpp


示例11: script_encode_usfm_file

void script_encode_usfm_file(const ustring & filename)
// Encodes a USFM file. The purpose is that the USFM marked are not changed by the script.
// The assumption is that numbers are not affected.
{
  // Read the file. Bail out if there's no text.
  ustring input;
  {
    gchar *contents;
    g_file_get_contents(filename.c_str(), &contents, NULL, NULL);
    if (!contents)
      return;
    input = contents;
    g_free(contents);
  }
  if (input.empty())
    return;

  // Go through the input, changing usfm codes to their numerical equivalent,
  // and copying data to the output.
  // E.g. "\id" would become "\_105_100".
  ustring output;
  bool within_usfm = false;
  for (unsigned int i = 0; i < input.length(); i++) {
    ustring character = input.substr(i, 1);
    if (within_usfm)
      if (character == " ")
        within_usfm = false;
    if (within_usfm) {
      gunichar unichar;
      gunichar *uc;
      uc = g_utf8_to_ucs4_fast(character.c_str(), -1, NULL);
      unichar = *uc;
      g_free(uc);
      character = "_" + convert_to_string(unichar);
    }
    output.append(character);
    if (character == "\\")
      within_usfm = true;
  }

  // Write the data back to the file.
  g_file_set_contents(filename.c_str(), output.c_str(), -1, NULL);
}
开发者ID:githubber,项目名称:bibledit,代码行数:43,代码来源:scripts.cpp


示例12: getAccentFromChar

    Accents getAccentFromChar (ustring ch) {
        _size_t_ accent = VowelsWithAccents.find (ch.lowercase ());

        if (accent != ustring::npos)
            accent %= NUMBER_OF_ACCENTS;
        else
            accent = NO_ACCENT;

        return accent;
    }
开发者ID:ano-qml,项目名称:BoGoEngine,代码行数:10,代码来源:utils.cpp


示例13: bibleworks_define_parsing_person

void bibleworks_define_parsing_person (ustring& parsing, ustring& definition)
// This looks in the "parsing" whether the person is given. 
// If so, it adds the description to the "definition" and removes the relevant code from the "parsing".
{
  ustring person = parsing.substr (0, 1);
  bool person_found = true;
  if (person == "1") {
    definition.append (" first person");
  } else if (person == "2") {
    definition.append (" second person");
  } else if (person == "3") {
    definition.append (" third person");
  } else {
    person_found = false;
  }
  if (person_found) {
    parsing.erase (0, 1);
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:19,代码来源:bibleworks.cpp


示例14: fprintf

void
OSLCompilerImpl::warning (ustring filename, int line, const char *format, ...)
{
    va_list ap;
    va_start (ap, format);
    std::string errmsg = format ? OIIO::Strutil::vformat (format, ap) : "";
    fprintf (stderr, "%s:%d: warning: %s\n", 
             filename.c_str(), line, errmsg.c_str());
    va_end (ap);
}
开发者ID:danieldresser,项目名称:OpenShadingLanguage,代码行数:10,代码来源:oslcomp.cpp


示例15: check_matched_pairs

void CheckMatchingPairs::check_matched_pairs(ustring & text)
// Checks on matched pairs. Output any problems found.
{
  for (unsigned int i = 0; i < text.length(); i++) {
    // Get the unicode character;
    gunichar unichar;
    unichar = g_utf8_get_char(text.substr(i, 1).c_str());
    // If we found a mirror character, investigate further.
    gunichar mirror;
    if (g_unichar_get_mirror_char(unichar, &mirror)) {
      // Do we ignore this one?
      if (ignores.find(unichar) != ignores.end())
        continue;
      // See whether this one opens or closes a pair.
      if (gopeners.find(unichar) != gopeners.end()) {
        // It opens: Add data.
        MatchingPairOpener opener(text.substr(i, 1), unichar, book, chapter, verse, get_context(text, i));
        openers.push_back(opener);
        continue;
      } else {
        // It closes: check for previously seen opener.
        bool give_message = false;
        if (openers.empty()) {
          give_message = true;
        }
        if (!give_message) {
          if (openers[openers.size() - 1].unichar == mirror) {
            // Remove last one.
            openers.pop_back();
          } else {
            // Flag message.
            give_message = true;
          }
        }
        if (give_message) {
          // Give message;
          message(book, chapter, verse, _("Pair not opened: ") + get_context(text, i));
        }
      }
    }
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:42,代码来源:check_matching_pairs.cpp


示例16: 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


示例17:

	void Services::Filter::set_host(const ustring & host, PCWSTR user, PCWSTR pass)
	{
		LogNoise(L"host: '%s', user: '%s'\n", host.c_str(), user);
		Base::shared_ptr<Ext::RemoteConnection> tmp_conn(new Ext::RemoteConnection(host, user, pass));
		Base::shared_ptr<Ext::Service::Manager> tmp_scm(new Ext::Service::Manager(tmp_conn.get(), SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
		m_writable = false;

		using std::swap;
		swap(m_scm, tmp_scm);
		swap(m_conn, tmp_conn);
	}
开发者ID:IDA-RE-things,项目名称:andrew-grechkin,代码行数:11,代码来源:services.cpp


示例18: loadFromFile

void StringList::loadFromFile(const ustring &fileName)
{
    clear();
    if(file_test(fileName, FILE_TEST_EXISTS)) {
        gchar *cont;
        gsize len;
        g_file_get_contents(fileName.c_str(), &cont, &len, NULL);
        loadFromChar(cont);
        g_free(cont);
    }
}
开发者ID:CriDos,项目名称:HiAsm5_console,代码行数:11,代码来源:StringList.cpp


示例19: Assign

	bool HttpBindIP::Assign(const ustring & ip, const ustring & port) {
		u_short	prt = htons(Str::as_uint32(port.c_str()));
		if (is_valid(ip) && prt) {
			sockaddr_in *tmp = (sockaddr_in*)pIpPort;
			tmp->sin_port		= prt;
			tmp->sin_addr.s_addr = inet_addr(utf8(ip).c_str());
			tmp->sin_family		= AF_INET;
			return true;
		}
		return false;
	}
开发者ID:IDA-RE-things,项目名称:andrew-grechkin,代码行数:11,代码来源:httpmgr.cpp


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ utArray类代码示例发布时间:2022-05-31
下一篇:
C++ usrloc_api_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap