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


C++ CharSet类代码示例

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


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

示例1: LoadCharSet

int LoadCharSet(const char* fontFileName,const char* charArray,CharSet& charSet)
{
	if (!fontFileName || !charArray)
	{
		return 0;
	}

	IplImage* largeImage = cvLoadImage(fontFileName,CV_LOAD_IMAGE_GRAYSCALE);
	if (!largeImage)
	{
		return 0;
	}

	int charNum = strlen(charArray);
	int width = largeImage->width/charNum;
	int height = largeImage->height;

	charSet.clear();
	charSet.resize(charNum);

	for (int i = 0;i < charNum;i++)
	{
		IplImage* image = cvCreateImage(cvSize(width,height),8,1);
		cvSetImageROI(largeImage,cvRect(i*width,0,width,height));
		cvCopy(largeImage,image);
		CharFont font;
		font.code = charArray[i];
		font.image = image;
		charSet[i] = font;
	}

	cvReleaseImage(&largeImage);
	return charSet.size();
}
开发者ID:lghknight,项目名称:hack-12306,代码行数:34,代码来源:CharFont.cpp

示例2: FreeCharSet

int FreeCharSet(CharSet& charSet)
{
	for (int i = 0;i < charSet.size();i++)
	{
		cvReleaseImage(&charSet[i].image);
	}

	return charSet.size();
}
开发者ID:lghknight,项目名称:hack-12306,代码行数:9,代码来源:CharFont.cpp

示例3: CharSet

CharSet* Action::Symbols(Tab *tab) {
	CharSet *s;
	if (typ == Node::clas)
		s = tab->CharClassSet(sym)->Clone();
	else {
		s = new CharSet(); s->Set(sym);
	}
	return s;
}
开发者ID:pauloscustodio,项目名称:coco-r-cpp,代码行数:9,代码来源:Action.cpp

示例4: INTL_adjust_text_descriptor

void INTL_adjust_text_descriptor(thread_db* tdbb, dsc* desc)
{
/**************************************
 *
 *      I N T L _ a d j u s t _ t e x t _ d e s c r i p t o r
 *
 **************************************
 *
 * Functional description
 *      This function receives a text descriptor with
 *      dsc_length = numberOfCharacters * maxBytesPerChar
 *      and change dsc_length to number of bytes used by the string.
 *
 **************************************/
	if (desc->dsc_dtype == dtype_text)
	{
		SET_TDBB(tdbb);

		USHORT ttype = INTL_TTYPE(desc);

		CharSet* charSet = INTL_charset_lookup(tdbb, ttype);

		if (charSet->isMultiByte())
		{
			Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> buffer;

			if (charSet->getFlags() & CHARSET_LEGACY_SEMANTICS)
			{
				desc->dsc_length = charSet->substring(TEXT_LEN(desc), desc->dsc_address, TEXT_LEN(desc),
										buffer.getBuffer(TEXT_LEN(desc) * charSet->maxBytesPerChar()), 0,
										TEXT_LEN(desc));

				const ULONG maxLength = TEXT_LEN(desc) / charSet->maxBytesPerChar();
				ULONG charLength = charSet->length(desc->dsc_length, desc->dsc_address, true);

				while (charLength > maxLength)
				{
					if (desc->dsc_address[desc->dsc_length - 1] == *charSet->getSpace())
					{
						--desc->dsc_length;
						--charLength;
					}
					else
						break;
				}
			}
			else
			{
				desc->dsc_length = charSet->substring(TEXT_LEN(desc), desc->dsc_address,
										TEXT_LEN(desc), buffer.getBuffer(TEXT_LEN(desc)), 0,
										TEXT_LEN(desc) / charSet->maxBytesPerChar());
			}
		}
	}
}
开发者ID:Alexpux,项目名称:firebird-git-svn,代码行数:55,代码来源:intl.cpp

示例5: CharSet

void CharSet::Subtract(CharSet *s) {
	CharSet *x = new CharSet();
	Range *p = head;
	while (p != NULL) {
		for (int i = p->from; i <= p->to; i++)
			if (!s->Get(i)) x->Set(i);
		Range *del = p;
		p = p->next;
		delete del;
	}
	head = x->head;
	x->head = NULL;
	delete x;
}
开发者ID:pauloscustodio,项目名称:coco-r-cpp,代码行数:14,代码来源:CharSet.cpp

示例6: WordVariants

// Recursive helper function for WordVariants().
void WordListLangModel::WordVariants(const CharSet &char_set,
                                     string_32 prefix_str32,
                                     WERD_CHOICE *word_so_far,
                                     string_32 str32,
                                     vector<WERD_CHOICE *> *word_variants) {
  int str_len = str32.length();
  if (str_len == 0) {
    if (word_so_far->length() > 0) {
      word_variants->push_back(new WERD_CHOICE(*word_so_far));
    }
  } else {
    // Try out all the possible prefixes of the str32.
    for (int len = 1; len <= str_len; len++) {
      // Check if prefix is supported in character set.
      string_32 str_pref32 = str32.substr(0, len);
      int class_id = char_set.ClassID(reinterpret_cast<const char_32 *>(
          str_pref32.c_str()));
      if (class_id <= 0) {
        continue;
      } else {
        string_32 new_prefix_str32 = prefix_str32 + str_pref32;
        string_32 new_str32 = str32.substr(len);
        word_so_far->append_unichar_id(class_id, 1, 0.0, 0.0);
        WordVariants(char_set, new_prefix_str32, word_so_far, new_str32,
                     word_variants);
        word_so_far->remove_last_unichar_id();
      }
    }
  }
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:31,代码来源:word_list_lang_model.cpp

示例7: Subtract

void CharSet::Subtract(const CharSet& b)
{
	CharSet tmp;
	Range *p = head;
	while (p != NULL)
	{
		for (int i = p->from; i <= p->to; i++)
		{
			if (!b.Get(i))
			{
				tmp.Set(i);
			}
		}

		// cleanup old storage - as per Clear
		Range *del = p;
		p = p->next;
		delete del;
	}
	head = tmp.head;
	tmp.head = NULL;       // avoid double deletion
}
开发者ID:olesenm,项目名称:coco-cpp,代码行数:22,代码来源:CharSet.cpp

示例8: strlen

static
char *unique( char *str )
{
	typedef std::set<char> CharSet;
	typedef std::pair<CharSet::iterator, bool> InsertRetType;

	if( !str || !(*str) )
		return str;

	CharSet charset;
	char *end = str + strlen(str);

	for( char *p = end - 1; p >= str; --p ) {
		InsertRetType ret = charset.insert( *p );
		if( !ret.second ) {
			memmove( p, p+1, end - p );
			--end;
		} // if
	} // for

	return str;
}
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:22,代码来源:unique_str.cpp

示例9: copychar

	inline void copychar( CharSet& output_, Buffer& buf_)
	{
		/// \remark a check if the character sets fulfill is_equal(..) (IsoLatin code page !)
		if (CharSet::is_equal( charset, output_))
		{
			// ... if the character sets are equal and of the same subclass (code pages)
			//	then we do not decode/encode the character but copy it directly to the output
			charset.fetchbytes( buf, state, input);
#ifdef __GNUC__
#if (__GNUC__ >= 5 && __GNUC_MINOR__ >= 0)
			for (unsigned int ii=0; ii<8 && ii<state; ++ii) buf_.push_back(buf[ii]);
#else
			for (unsigned int ii=0; ii<state; ++ii) buf_.push_back(buf[ii]);
#endif
#else
			for (unsigned int ii=0; ii<state; ++ii) buf_.push_back(buf[ii]);
#endif
		}
		else
		{
			output_.print( chr(), buf_);
		}
	}
开发者ID:andreasbaumann,项目名称:textwolf,代码行数:23,代码来源:textscanner.hpp

示例10: CsConvert

CsConvert CharSetContainer::lookupConverter(thread_db* tdbb, CHARSET_ID toCsId)
{
	if (toCsId == CS_UTF16)
		return CsConvert(cs->getStruct(), NULL);

	CharSet* toCs = INTL_charset_lookup(tdbb, toCsId);
	if (cs->getId() == CS_UTF16)
		return CsConvert(NULL, toCs->getStruct());

	return CsConvert(cs->getStruct(), toCs->getStruct());
}
开发者ID:Alexpux,项目名称:firebird-git-svn,代码行数:11,代码来源:intl.cpp

示例11: part

string part(const string &str, int &pos, const CharSet &d, bool empty)
{
    string p;
    for (; pos < str.length(); ++pos)
        if (d.exists(str[pos]))
        {
            if (!p.empty() || empty)
            {
                ++pos;
                break;
            }
            p.clear();
        }
        else
        {
            p += str[pos];
        }
    return p;
}
开发者ID:5nw,项目名称:httpserver,代码行数:19,代码来源:strings.cpp

示例12: skip

	bool skip()
	{
		pos++;
		if (pos >= buf.size())
		{
			if (ii >= NOF_TESTS)
			{
				pos = buf.size();
				return false;
			}
			else
			{
				buf.clear();
				unsigned int tt = character( ++ii, (unsigned int)CharSet::MaxChar);
				encoding.print( tt, buf);
				pos = 0;
			}
		}
		return true;
	}
开发者ID:andreasbaumann,项目名称:textwolf,代码行数:20,代码来源:test_TextReader.cpp

示例13: pad_spaces

static void pad_spaces(thread_db* tdbb, CHARSET_ID charset, BYTE* ptr, ULONG len)
{								/* byte count */
/**************************************
 *
 *      p a d  _ s p a c e s
 *
 **************************************
 *
 * Functional description
 *      Pad a buffer with the character set defined space character.
 *
 **************************************/
	SET_TDBB(tdbb);

	fb_assert(ptr != NULL);

	CharSet* obj = INTL_charset_lookup(tdbb, charset);

	// Single-octet character sets are optimized here
	if (obj->getSpaceLength() == 1)
	{
		const BYTE* const end = &ptr[len];
		while (ptr < end)
			*ptr++ = *obj->getSpace();
	}
	else
	{
		const BYTE* const end = &ptr[len];
		const UCHAR* space = obj->getSpace();
		const UCHAR* const end_space = &space[obj->getSpaceLength()];
		while (ptr < end)
		{
			space = obj->getSpace();
			while (ptr < end && space < end_space) {
				*ptr++ = *space++;
			}
			// This fb_assert is checking that we didn't have a buffer-end
			// in the middle of a space character
			fb_assert(!(ptr == end) || (space == end_space));
		}
	}
}
开发者ID:Alexpux,项目名称:firebird-git-svn,代码行数:42,代码来源:intl.cpp

示例14: INTL_convert_bytes

ULONG INTL_convert_bytes(thread_db* tdbb,
						 CHARSET_ID dest_type,
						 BYTE* dest_ptr,
						 const ULONG dest_len,
						 CHARSET_ID src_type,
						 const BYTE* src_ptr,
						 const ULONG src_len,
						 ErrorFunction err)
{
/**************************************
 *
 *      I N T L _ c o n v e r t _ b y t e s
 *
 **************************************
 *
 * Functional description
 *      Given a string of bytes in one character set, convert it to another
 *      character set.
 *
 *      If (dest_ptr) is NULL, return the count of bytes needed to convert
 *      the string.  This does not guarantee the string can be converted,
 *      the purpose of this is to allocate a large enough buffer.
 *
 * RETURNS:
 *      Length of resulting string, in bytes.
 *      calls (err) if conversion error occurs.
 *
 **************************************/
	SET_TDBB(tdbb);

	fb_assert(src_ptr != NULL);
	fb_assert(src_type != dest_type);
	fb_assert(err != NULL);

	dest_type = INTL_charset(tdbb, dest_type);
	src_type = INTL_charset(tdbb, src_type);

	const UCHAR* const start_dest_ptr = dest_ptr;

	if (dest_type == CS_BINARY || dest_type == CS_NONE ||
		src_type == CS_BINARY || src_type == CS_NONE)
	{
		// See if we just need a length estimate
		if (dest_ptr == NULL)
			return (src_len);

		if (dest_type != CS_BINARY && dest_type != CS_NONE)
		{
			CharSet* toCharSet = INTL_charset_lookup(tdbb, dest_type);

			if (!toCharSet->wellFormed(src_len, src_ptr))
				err(Arg::Gds(isc_malformed_string));
		}

		ULONG len = MIN(dest_len, src_len);
		if (len)
		{
			do {
				*dest_ptr++ = *src_ptr++;
			} while (--len);
		}

		// See if only space characters are remaining
		len = src_len - MIN(dest_len, src_len);
		if (len == 0 || allSpaces(INTL_charset_lookup(tdbb, src_type), src_ptr, len, 0))
			return dest_ptr - start_dest_ptr;

		err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
			Arg::Gds(isc_trunc_limits) << Arg::Num(dest_len) << Arg::Num(src_len));
	}
	else if (src_len)
	{
		// character sets are known to be different
		// Do we know an object from cs1 to cs2?

		CsConvert cs_obj = INTL_convert_lookup(tdbb, dest_type, src_type);
		return cs_obj.convert(src_len, src_ptr, dest_len, dest_ptr, NULL, true);
	}

	return 0;
}
开发者ID:Alexpux,项目名称:firebird-git-svn,代码行数:81,代码来源:intl.cpp

示例15:

 void StandardChars<char16>::SetNonWordChars(ArenaAllocator* setAllocator, CharSet<Char> &set)
 {
     set.SetNotRanges(setAllocator, numWordPairs, wordStr);
 }
开发者ID:280185386,项目名称:ChakraCore,代码行数:4,代码来源:StandardChars.cpp


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