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


C++ CharArray类代码示例

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


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

示例1: shaderSource

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
String ShaderSourceRepository::shaderSource(ShaderIdent shaderIdent)
{
    String shaderProg;

    CharArray rawSource;
    if (rawShaderSource(shaderIdent, &rawSource))
    {
        if (rawSource.size() > 0)
        {
#ifdef CVF_OPENGL_ES
            // Always version 100 on OpenGL ES
            shaderProg = "#version 100\nprecision highp float;\n";
#else
            // Default on desktop is GLSL 1.2 (OpenGL 2.1) unless the shader explicitly specifies a version
            if (rawSource[0] != '#')
            {
                shaderProg = "#version 120\n";
            }
#endif
    
            shaderProg += rawSource.ptr();
        }
    }

    return shaderProg;
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:29,代码来源:cvfShaderSourceRepository.cpp

示例2: test_set_byte

 void test_set_byte() {
   CharArray* c = String::create(state, "xyz")->data();
   c->set_byte(state, Fixnum::from(0), Fixnum::from('1'));
   TS_ASSERT_EQUALS(c->get_byte(state, Fixnum::from(0)), Fixnum::from('1'));
   c->set_byte(state, Fixnum::from(2), Fixnum::from('2'));
   TS_ASSERT_EQUALS(c->get_byte(state, Fixnum::from(2)), Fixnum::from('2'));
 }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:7,代码来源:test_chararray.hpp

示例3: rd

	value_t Hash::to_s(Hash *self)
	{
		RecursionDetector<RecursionType::Hash_to_s, false> rd(self);

		if(rd.recursion())
			return String::get("{...}");

		CharArray result = "{";

		OnStack<1> os1(self);
		OnStackString<1> os2(result);

		HashAccess::each_pair(self, [&](value_t key, value_t value) -> bool {

			OnStack<1> os(value);
			
			result += inspect(key);
			result += "=>";
			result += inspect(value);
			result += ", ";

			return true;
		});

		if(result.size() > 1)
			result.shrink(result.size() - 2);

		result += "}";

		return result.to_string();
	}
开发者ID:Zoxc,项目名称:mirb,代码行数:31,代码来源:hash.cpp

示例4: finally

value_t IO::rb_readlines(String *path)
{
    Stream *file;

    Platform::wrap([&] {
        file = Platform::open(path->string, Platform::Read, Platform::Open);
    });

    Finally finally([&] {
        delete file;
    });

    auto result = Array::allocate();

    while(true)
    {
        CharArray line = file->gets();

        if(line.size())
            result->vector.push(line.to_string());
        else
            break;
    }

    return result;
}
开发者ID:Zoxc,项目名称:mirb,代码行数:26,代码来源:io.cpp

示例5: if

String* String::resize_capacity(STATE, Fixnum* count) {
    native_int sz = count->to_native();

    if(sz < 0) {
        Exception::argument_error(state, "negative byte array size");
    } else if(sz >= INT32_MAX) {
        // >= is used deliberately because we use a size of + 1
        // for the byte array
        Exception::argument_error(state, "too large byte array size");
    }

    CharArray* ba = CharArray::create(state, sz + 1);
    native_int copy_size = sz;
    native_int data_size = as<CharArray>(data_)->size();

    // Check that we don't copy any data outside the existing byte array
    if(unlikely(copy_size > data_size)) {
        copy_size = data_size;
    }
    memcpy(ba->raw_bytes(), byte_address(), copy_size);

    // We've unshared
    shared(state, Qfalse);
    data(state, ba);
    hash_value(state, nil<Fixnum>());

    // If we shrunk it and num_bytes said there was more than there
    // is, clamp it.
    if(num_bytes()->to_native() > sz) {
        num_bytes(state, count);
    }

    return this;
}
开发者ID:rougecardinal,项目名称:rubinius,代码行数:34,代码来源:string.cpp

示例6: test_to_chars

  void test_to_chars() {
    String* s = String::create(state, "xy");
    CharArray* c = s->data();
    char* chars = c->to_chars(state, Fixnum::from(2));

    TS_ASSERT_SAME_DATA("xy", chars, 2);
  }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:7,代码来源:test_chararray.hpp

示例7: get_UserInfo

void IL2Client::game_TargetByName( const wchar_t *name )
{
	//L2Client *cl = (L2Client *)m_pcl;
	UserInfo *usr = get_UserInfo();
	CharArray *ca = get_WorldChars();
	NpcArray *na = get_WorldNpcs();
	unsigned int nPassed = 0, i = 0, count = ca->GetCount();
	unsigned int objectID = 0;
	if( _wcsicmp( name, usr->charName ) == 0 )
	{
		objectID = usr->objectID;
	}
	if( objectID == 0 )
	{
		// try chars
		count = ca->GetCount();
		nPassed = 0;
		if( count > 0 )
		{
			ca->Lock();
			for( i=0; i<CharArray::CHARARRAY_MAX_CHARS; i++ )
			{
				if( ca->chars_array[i]->isUnused() ) continue;
				nPassed++;
				if( _wcsicmp( name, ca->chars_array[i]->charName ) == 0 )
				{
					objectID = ca->chars_array[i]->objectID;
					break;
				}
				if( nPassed >= count ) break;
			}
			ca->Unlock();
		}
	}
	if( objectID == 0 )
	{
		// try NPCs
		count = na->getCount();
		nPassed = 0;
		if( count > 0 )
		{
			na->Lock();
			for( i=0; i<NpcArray::NPCA_MAX_NPCS; i++ )
			{
				if( na->npcs_array[i]->isUnused() ) continue;
				nPassed++;
				if( _wcsicmp( name, na->npcs_array[i]->charName ) == 0 )
				{
					objectID = na->npcs_array[i]->objectID;
					break;
				}
				if( nPassed >= count ) break;
			}
			na->Unlock();
		}
	}
	if( objectID == 0 ) return;
	game_Action( objectID );
}
开发者ID:minlexx,项目名称:l2-unlegits,代码行数:59,代码来源:IL2Client.cpp

示例8: toUnicode

 int32_t StringUtils::toUnicode(const uint8_t* utf8, int32_t length, CharArray unicode)
 {
     if (length == 0)
         return 0;
     UTF8Decoder utf8Decoder(utf8, utf8 + length);
     int32_t decodeLength = utf8Decoder.decode(unicode.get(), unicode.size());
     return decodeLength == Reader::READER_EOF ? 0 : decodeLength;
 }
开发者ID:alesha1488,项目名称:LucenePlusPlus,代码行数:8,代码来源:StringUtils.cpp

示例9: test_get_byte_index_out_of_bounds

 void test_get_byte_index_out_of_bounds() {
   CharArray* c = String::create(state, "xyz")->data();
   native_int sz = c->size(state)->to_native();
   TS_ASSERT_THROWS_ASSERT(c->get_byte(state, Fixnum::from(sz)), const RubyException &e,
       TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
   TS_ASSERT_THROWS_ASSERT(c->get_byte(state, Fixnum::from(sz+1)), const RubyException &e,
       TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
   TS_ASSERT_THROWS_ASSERT(c->get_byte(state, Fixnum::from(-1)), const RubyException &e,
       TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
 }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:10,代码来源:test_chararray.hpp

示例10: test_compare_bytes_out_of_bounds

  void test_compare_bytes_out_of_bounds() {
    CharArray* a = String::create(state, "xyZzy")->data();
    CharArray* b = String::create(state, "xyzzy")->data();

    Fixnum* zero = Fixnum::from(0);
    Fixnum* neg = Fixnum::from(-1);

    TS_ASSERT_THROWS_ASSERT(a->compare_bytes(state, b, neg, zero), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(a->compare_bytes(state, b, zero, neg), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
  }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:12,代码来源:test_chararray.hpp

示例11: while

	CharArray Stream::gets()
	{
		static const size_t buffer_size = 0x200;

		CharArray result, buffer;

		while(true)
		{
			pos_t p = pos();
			buffer = read(buffer_size);

			for(size_t i = 0; i < buffer.size(); ++i)
			{
				if(buffer[i] == '\r')
				{
					++i;

					if(i < buffer.size())
					{
						if(buffer[i] == '\n')
							++i;

						seek(p + i, FromStart);
						return result + buffer.copy(0, i);
					}
					else
					{
						CharArray c = read(1);

						if(c == "\n")
							buffer += c;
						else
							seek(-(pos_t)c.size());

						return result + buffer;
					}
				}
				else if(buffer[i] == '\n')
				{
					++i;

					seek(p + i, FromStart);
					return result + buffer.copy(0, i);
				}
			}

			if(buffer.size() < buffer_size)
				return result + buffer;

			result += buffer;
		}
	}
开发者ID:Zoxc,项目名称:mirb,代码行数:52,代码来源:stream.cpp

示例12: read

		CharArray NativeStream::read(size_t length)
		{
			CharArray buf;
			buf.buffer(length);

			ssize_t result = ::read(fd, buf.str_ref(), buf.size());

			if(result < 0)
				raise("Unable to read from file descriptor");

			buf.shrink((size_t)result);
			return buf;
		}
开发者ID:Zoxc,项目名称:mirb,代码行数:13,代码来源:posix.cpp

示例13: ArgumentNullException

  ByteArray Convert::FromBase64CharArray(CharArray& inArray, int offset, int length)
    {
    if(inArray.IsNull())
      throw ArgumentNullException(L"inArray");
    if(offset < 0)
      throw ArgumentOutOfRangeException(L"offset < 0");
    if(length < 0)
      throw ArgumentOutOfRangeException(L"length < 0");
    // avoid integer overflow
    if(offset > (int)inArray.Length() - length)
      throw ArgumentOutOfRangeException(L"offset + length > array.Length");

    return InternalFromBase64CharArray(inArray, offset, length);
    }
开发者ID:ctguxp,项目名称:CrapoLibrary,代码行数:14,代码来源:System.Convert.cpp

示例14: TEST_F

TEST_F(MappingCharFilterTest, testReaderReset) {
    CharStreamPtr cs = newLucene<MappingCharFilter>(normMap, newLucene<StringReader>(L"x"));
    CharArray buf = CharArray::newInstance(10);
    int32_t len = cs->read(buf.get(), 0, 10);
    EXPECT_EQ(1, len);
    EXPECT_EQ(L'x', buf[0]) ;
    len = cs->read(buf.get(), 0, 10);
    EXPECT_EQ(-1, len);

    // rewind
    cs->reset();
    len = cs->read(buf.get(), 0, 10);
    EXPECT_EQ(1, len);
    EXPECT_EQ(L'x', buf[0]) ;
}
开发者ID:304471720,项目名称:LucenePlusPlus,代码行数:15,代码来源:MappingCharFilterTest.cpp

示例15: split

			template<typename F1, typename F2> void split(const CharArray &input, F1 data, F2 split)
			{
				compile_pattern();
		
				int ovector[vector_size];

				size_t prev = 0;
		
				while(true)
				{
					int groups = match(input, ovector, prev);

					if(groups <= 0)
					{
						if(prev < input.size())
							data(input.copy(prev, input.size() - prev));

						return;
					}
					else
					{
						int start = ovector[0];
						int stop = ovector[1];

						for (int i = 0; i < groups; i++) {
							start = std::min(start, ovector[2 * i]);
							stop = std::max(stop, ovector[2 * i + 1]);
						}

						if((size_t)stop == prev)
						{
							split(start, stop);

							data(input.copy(prev, 1));

							prev += 1;
						}
						else
						{
							data(input.copy(prev, (size_t)start - prev));

							split(start, stop);

							prev = stop;
						}
					}
				}
			}
开发者ID:Zoxc,项目名称:mirb,代码行数:48,代码来源:regexp.hpp


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