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


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

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


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

示例1: parse

void DataValue::parse(const ustring &text, DataType type, void *value) {
	switch(type) {
		case data_int:
		case data_combo:
		case data_flags:
		case data_comboEx:
			*(int *)value = atoi(text.c_str());
			break;
		case data_str:
			if(text[0] == '"')
				((ustring*)value)->assign(text, 1, text.length() - 2);
			else if(text[0] == '#')
				parseStrList(text, value);
			else
				*(ustring*)value = text;
			break;
		case data_stock:
		case data_element:
			if(text[0] == '"')
				((ustring*)value)->assign(text, 1, text.length() - 2);
			else
				*(ustring*)value = text;
			break;
		case data_real:
			*(double *)value = atof(text.c_str());
			break;
		case data_data: {
			int i;
			static const int dtypes[] = { data_int, data_str, data_real };

			for(int t = 0; t < 3; t++)
				if(strncmp(text.c_str(), dataNames[dtypes[t]], i = strlen(dataNames[dtypes[t]])) == 0) {
					ustring s = ustring(text, i+1, text.length() - i - 2);
					switch(t) {
						case 0: *(TData*)value = atoi(s.c_str()); break;
						case 1: *(TData*)value = s; break;
						case 2: *(TData*)value = atof(s.c_str()); break;
					}
				}
			break;
		}
		case data_list:
			parseStrList(text, value);
			break;
		case data_pixbuf:
			parsePixbuf(text, value);
			break;
		case data_array:
			parseArray(text, value);
			break;
		case data_color:
			((TypeColor*)value)->set(text);
			break;
		case data_font:
			parseFont(text, value);
			break;
		default:
			;
	}
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:60,代码来源:ElementProperty.cpp

示例2: Import

void CDate::Import(ustring a)
{
	do
	{
		int dem = 0;
		int dk = 0;
		int j = 0;
		char** temp = new char*[3]; //Tạo con trỏ hai chiều kiểu char
		for(int i = 0; i < 3; i++) //Vòng lặp khởi tạo vùng nhớ cho biến
			temp[i] = new char[a.length()];

		for(int i = 0; i < a.length(); i++) //Vòng lặp chạy từ cuối chuỗi
		{
			if(a[i] >= '0' && a[i] <= '9') //Nếu gặp phần tử là số thì thêm vào biến tạm thứ dem.
			{
				temp[dem][j] = a[i];
				j++;
			}
			else //Nếu gặp thì tăng dem lên 1 để chuyển biến tạm và j = 0 để trở về vị trí ban đầu của biến tạm mới
			{
				dem++;
				j = 0;
			}
		}

		this->m_day = atoi(temp[0]); //Chuyển giá trị trong chuỗi thành kiểu nguyên và gán cho thuộc tính của con trỏ this
		this->m_month = atoi(temp[1]); //Tương tự
		this->m_year = atoi(temp[2]); //Tương tự

	} while(this->m_year < 0 || this->m_month < 0 || this->m_month > 12 || (CheckYear(this->m_year) == 0 && this->m_day > SizeMonth[this->m_month - 1] || this->m_day < 0) || (CheckYear(this->m_year) == 1 && this->m_day > _SizeMonth[this->m_month - 1] || this->m_day < 0)); //Điều kiện dùng của vòng lặp nhập thời gian
}
开发者ID:panoti,项目名称:DACK_CTDL_G1,代码行数:31,代码来源:Date.cpp

示例3: send_line

void WindowsOutpost::send_line(const ustring & command)
// Sends "command" to the windows outpost.
{
  int result = 0;
  if (connected) {
    // Discard any previous reply.
    char buf[1024];
#ifdef WIN32
    if (recv(sock, buf, sizeof(buf), 0)) ;
    if (send(sock, command.c_str(), command.length(), 0)) ;
    result = send(sock, "\n", 1, 0);
#else
    if (read(sock, buf, sizeof(buf))) ;
    if (write(sock, command.c_str(), command.length())) ;
    result = write(sock, "\n", 1);
#endif
    // Give some time to allow the reply to come back.
    g_usleep(1000000);
  }
  if (result < 0) {
    connected = false;
#ifndef WIN32
    perror(NULL);
#endif
    log(_("Error sending data"));
    clear();
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:28,代码来源:windowsoutpost.cpp

示例4: searchwords_find_fast

void Highlight::searchwords_find_fast(GtkTextBuffer * textbuffer, GtkTextIter * beginbound, GtkTextIter * endbound, const ustring & searchword, bool casesensitive, vector < GtkTextIter > &wordstart, vector < GtkTextIter > &wordend)
// Searches for words to highlight. For simple highligthing. 
// Is much faster than the slow routine, see there fore more information.
{
  // Variable.
  GtkTextIter begin;
  GtkTextIter end;
  // Extract the line.
  ustring line = gtk_text_buffer_get_slice(textbuffer, beginbound, endbound, false);
  // Deal with case sensitivity.
  ustring case_considerate_search_word(searchword);
  if (!casesensitive)
    case_considerate_search_word = case_considerate_search_word.casefold();
  // Go through the line looking for matches.
  for (unsigned int i = 0; i < line.length(); i++) {
    if (interrupt_thread)
      continue;
    ustring compareline(line.substr(i, searchword.length()));
    // Deal with case sensitivity.
    if (!casesensitive)
      compareline = compareline.casefold();
    // Now compare.
    if (case_considerate_search_word == compareline) {
      // Get the iterators in the textbuffer that belong to this possible match.
      begin = *beginbound;
      gtk_text_iter_forward_chars(&begin, i);
      end = begin;
      gtk_text_iter_forward_chars(&end, searchword.length());
      // Add the boundaries of the word to highlight.
      wordstart.push_back(begin);
      wordend.push_back(end);
    }
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:34,代码来源:highlight.cpp

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

示例6: replace_text

bool replace_text(ustring & line, const ustring & look_for, const ustring & replace_with)
// Replaces some text. Returns true if any replacement was done.
{
  bool replacements_done = false;
  size_t offposition = line.find (look_for);
  while (offposition != string::npos) {
    line.replace (offposition, look_for.length (), replace_with);
    offposition = line.find (look_for, offposition + replace_with.length ());
    replacements_done = true;
  }
  return replacements_done;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:12,代码来源:utilities.cpp

示例7: loadKeys

bool PubAddr::loadKeys(ustring Skey, ustring Ekey, int nonce, int extra)
{
	std::unique_lock<std::shared_timed_mutex> mlock(this->mutex_);
	this->extra_bytes = extra;
	this->nonce_trials = nonce;

	this->pubEncryptionKey.clear();
	this->pubSigningKey.clear();

	int length = Ekey.length();
	if (length == 64)
	{

		this->pubEncryptionKey += 0x04;
		this->pubEncryptionKey += Ekey;
	}
	else if (length == 65)
	{
		if (Ekey.c_str()[0] != 0x04)
		{
			mlock.unlock();
			return false;
		}
		this->pubEncryptionKey += Ekey;
	}

	length = Skey.length();
	if (length == 64)
	{


		this->pubSigningKey += 0x04;
		this->pubSigningKey += Skey;


	}
	else if (length == 65)
	{
		if (Skey.c_str()[0] != 0x04)
		{
			mlock.unlock();
			return false;
		}
		this->pubSigningKey += Skey;
	}

	this->empty = false;
	mlock.unlock();
	return true;
}
开发者ID:steady286,项目名称:BitMRC,代码行数:50,代码来源:Addr.cpp

示例8: replace_text_between

bool replace_text_between(ustring & line, const ustring & start, const ustring & end, const ustring & replacement)
// Replaces text that starts with "start" and ends with "end" with "replacement".
// Returns true if replacement was done.
{
  bool replacements_done = false;
  size_t beginpos = line.find(start);
  size_t endpos = line.find(end);
  while ((beginpos != string::npos) && (endpos != string::npos) && (endpos > beginpos)) {
    line.replace(beginpos, endpos - beginpos + end.length(), replacement);
    beginpos = line.find(start, beginpos + replacement.length());
    endpos = line.find(end, beginpos + replacement.length());
    replacements_done = true;
  }
  return replacements_done;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:15,代码来源:utilities.cpp

示例9: strtol

  int strtol(long &value, ustring str, long &value2, ustring str2, int base)
  {
    const char *nptr = str.c_str();
    const char *nptr2 = str.c_str();
    char *eptr, *eptr2;
    value = ::strtol(nptr, &eptr, base);
    value2 = ::strtol(nptr2, &eptr2, base);

    if ( (nptr==eptr) || (nptr2==eptr2) )
      return -1;
    else if ( (eptr<(char*)nptr+str.length()) && (eptr2<(char*)nptr2+str2.length()) )
      return 0;
    else
      return 1;
  }
开发者ID:gasparfm,项目名称:glibutils,代码行数:15,代码来源:gutils_string.cpp

示例10: analyseWord

    ustringArrayT analyseWord (ustring str) {
        typedef bool (*_TrivialPointerToFunctions_) (ustring);

        ustringArrayT res(3);
        _TrivialPointerToFunctions_ testFuncs[3] =
            { isConsonant, isVowel, isConsonant };

        // First part: Consonant 1
        // Second part: Vowel
        // Third part: Consonant 2

        for (int part = 0; part < 3; part++) {
            res[part] = "";
            // This is safe due to short-circuit logic
            while (str.length () > 0 && testFuncs[part] (_(str[0]))) {
                res[part] += _(str[0]);
                str.replace (0, 1, "");
            }
        }

        // Special case: "qu" and "gi" are considered consonants
        if (analyseWordCheckSpecialConsonants (res, "qu") ||
            analyseWordCheckSpecialConsonants (res, "gi")) {
            res[0] += _(res[1][0]);
            res[1] = res[1].replace (0, 1, "");
        }

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

示例11: GetStringWidth

float CFont::GetStringWidth( const ustring& text, bool offsetFirstCharacter /*= false*/ )
{
    float totalW = 0;

    uchar lastChar = 0;
    for ( int i = 0; i < text.length(); ++i )
    {
        uchar c = text[i];
        auto descIt = m_chars.find(c);

        if ( descIt == m_chars.end() )
        {
            descIt = m_chars.find( -1 );
        }
        auto & desc = descIt->second;

        if (i != 0 || offsetFirstCharacter)
        {
            totalW += desc.offset.x;
        }
        totalW += desc.xAdvance;

        auto kernIt = m_kernings.find( std::make_pair( lastChar, c ) );
        if ( kernIt != m_kernings.end() )
        {
            totalW += kernIt->second;
        }

        lastChar = c;
    }


    return totalW;
}
开发者ID:rcrmn,项目名称:mastervj-basic-engine,代码行数:34,代码来源:Font.cpp

示例12: string_reverse

ustring string_reverse(const ustring & s)
{
  ustring returnvalue;
  for (int i = s.length() - 1; i >= 0; i--)
    returnvalue.append(s.substr(i, 1));
  return returnvalue;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:7,代码来源:utilities.cpp

示例13:

// Heavy lifting of OSL regex operations.
OSL_SHADEOP int
osl_regex_impl2 (OSL::ShadingContext *ctx, ustring subject_,
                 int *results, int nresults, ustring pattern,
                 int fullmatch)
{
    const std::string &subject (subject_.string());
    boost::match_results<std::string::const_iterator> mresults;
    const boost::regex &regex (ctx->find_regex (pattern));
    if (nresults > 0) {
        std::string::const_iterator start = subject.begin();
        int res = fullmatch ? boost::regex_match (subject, mresults, regex)
                            : boost::regex_search (subject, mresults, regex);
        int *m = (int *)results;
        for (int r = 0;  r < nresults;  ++r) {
            if (r/2 < (int)mresults.size()) {
                if ((r & 1) == 0)
                    m[r] = mresults[r/2].first - start;
                else
                    m[r] = mresults[r/2].second - start;
            } else {
                m[r] = pattern.length();
            }
        }
        return res;
    } else {
        return fullmatch ? boost::regex_match (subject, regex)
                         : boost::regex_search (subject, regex);
    }
}
开发者ID:DingTo,项目名称:OpenShadingLanguage,代码行数:30,代码来源:opstring.cpp

示例14: DASSERT

int
Dictionary::get_document_index (ustring dictionaryname)
{
    DocMap::iterator dm = m_document_map.find(dictionaryname);
    int dindex;
    if (dm == m_document_map.end()) {
        dindex = m_documents.size();
        m_document_map[dictionaryname] = dindex;
        pugi::xml_document *doc = new pugi::xml_document;
        m_documents.push_back (doc);
        pugi::xml_parse_result parse_result;
        if (boost::ends_with (dictionaryname.string(), ".xml")) {
            // xml file -- read it
            parse_result = doc->load_file (dictionaryname.c_str());
        } else {
            // load xml directly from the string
            parse_result = doc->load_buffer (dictionaryname.c_str(),
                                             dictionaryname.length());
        }
        if (! parse_result) {
            m_context->error ("XML parsed with errors: %s, at offset %d",
                              parse_result.description(),
                              parse_result.offset);
            m_document_map[dictionaryname] = -1;
            return -1;
        }
    } else {
        dindex = dm->second;
    }

    DASSERT (dindex < (int)m_documents.size());
    return dindex;
}
开发者ID:jamesvecore,项目名称:OpenShadingLanguage,代码行数:33,代码来源:dictionary.cpp

示例15: lowerCase

ustring lowerCase(const ustring & s)
{
// Make a lowercase copy of s
  string lower(s);
  for (size_t i = 0; i < s.length(); ++i)
    lower[i] = tolower(lower[i]);
  return lower;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:8,代码来源:utilities.cpp


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