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


C++ DataSourceRef类代码示例

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


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

示例1: loadUrl

		// Load JSON from URL
		Value loadUrl(const string & url, bool isEscaped)
		{

			// Load URL
			DataSourceRef dataSource = ci::loadUrl(Url(url, isEscaped));

			// Read buffer
			Buffer buffer;
			try
			{
				buffer = dataSource->getBuffer();
			}
			catch (...)
			{
				Value value;
				return value;
			}
			size_t dataSize = buffer.getDataSize();
			shared_ptr<int_fast8_t> bufferStr(new int_fast8_t[dataSize + 1], checked_array_deleter<int_fast8_t>());
			memcpy(bufferStr.get(), buffer.getData(), buffer.getDataSize());
			bufferStr.get()[dataSize] = 0;

			// Convert buffer to string, deserialize and return
			return deserialize(string(reinterpret_cast<char *>(bufferStr.get())));

		}
开发者ID:afrancois,项目名称:BanTheRewind,代码行数:27,代码来源:ciJson.cpp

示例2: setFile

// TODO: non-local file support?
bool FilePlayer::setFile(const DataSourceRef fileSource)
{
	if(fileSource->isFilePath()) {
		return setFile(fileSource->getFilePath());
	} else {
		return false;
	}
}
开发者ID:Contexter,项目名称:AUSpeechSynth,代码行数:9,代码来源:FilePlayer.cpp

示例3: setup

HRESULT Shader::setup(DataSourceRef dataSrc, const std::string& entryName)
{
    if (dataSrc && dataSrc->getBuffer().getDataSize() > 0)
    {
        CComPtr<ID3DBlob> shaderBytecode;
        HR( dx11::compileShader(dataSrc->getBuffer(), entryName, getProfileName(), &shaderBytecode) );
        HR( doCreateShader(shaderBytecode, &mHandle) );
    }
    return hr;
}
开发者ID:halogenica,项目名称:Cinder-DirectX,代码行数:10,代码来源:Shader.cpp

示例4: loadAsset

void AssetReloader::load( const fs::path assetPath, string key )
{
//    console() << "AssetReloader :: loading asset :: " << assetPath << " with key :: " << key << endl;
    
    DataSourceRef asset = loadAsset( assetPath );
    
    //    console() << asset->getFilePath() << endl;
    
    gl::Texture tmp = gl::Texture( loadImage( asset ) );
    mLoadedImages[key] = tmp;
    mKeyList[ asset->getFilePath().c_str() ] = key;
}
开发者ID:cwhitney,项目名称:AssetReloader,代码行数:12,代码来源:AssetReloader.cpp

示例5: mObj

//////////////////////////////////////////////////////////////////////////
// GlslProg
GlslProg::GlslProg( DataSourceRef vertexShader, DataSourceRef fragmentShader, DataSourceRef geometryShader )
    : mObj( shared_ptr<Obj>( new Obj ) )
{
    mObj->mHandle = glCreateProgram();

    loadShader( vertexShader->getBuffer(), GL_VERTEX_SHADER_ARB );
    if( fragmentShader )
        loadShader( fragmentShader->getBuffer(), GL_FRAGMENT_SHADER_ARB );
    if( geometryShader )
        loadShader( geometryShader->getBuffer(), GL_GEOMETRY_SHADER_EXT );

    link();
}
开发者ID:alexbw,项目名称:Cinder,代码行数:15,代码来源:GlslProg.cpp

示例6: createFileQuartzRef

///////////////////////////////////////////////////////////////////////////////
// ImageSourceFileQuartz
ImageSourceFileQuartzRef ImageSourceFileQuartz::createFileQuartzRef( DataSourceRef dataSourceRef, ImageSource::Options options )
{
	std::shared_ptr<CGImageSource> sourceRef;
	std::shared_ptr<CGImage> imageRef;
	
	::CFStringRef keys[1] = { kCGImageSourceShouldAllowFloat };
	::CFBooleanRef values[1] = { kCFBooleanTrue };
	const std::shared_ptr<__CFDictionary> optionsDict( (__CFDictionary*)CFDictionaryCreate( kCFAllocatorDefault, (const void **)&keys, (const void **)&values, 1, NULL, NULL ), cocoa::safeCfRelease );

	if( dataSourceRef->isFilePath() ) {
		::CFStringRef pathString = cocoa::createCfString( dataSourceRef->getFilePath().string() );
		::CFURLRef urlRef = ::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString, kCFURLPOSIXPathStyle, false );
		sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithURL( urlRef, optionsDict.get() ), cocoa::safeCfRelease );
		::CFRelease( pathString );
		::CFRelease( urlRef );
	}
	else if( dataSourceRef->isUrl() ) {
		::CFURLRef urlRef = cocoa::createCfUrl( dataSourceRef->getUrl() );
		if( ! urlRef )
			throw ImageIoExceptionFailedLoad();
		sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithURL( urlRef, optionsDict.get() ), cocoa::safeCfRelease );
		::CFRelease( urlRef );		
	}
	else { // last ditch, we'll use a dataref from the buffer
		::CFDataRef dataRef = cocoa::createCfDataRef( dataSourceRef->getBuffer() );
		if( ! dataRef )
			throw ImageIoExceptionFailedLoad();
		
		sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithData( dataRef, optionsDict.get() ), cocoa::safeCfRelease );
		::CFRelease( dataRef );
	}
	
	if( sourceRef ) {
		imageRef = std::shared_ptr<CGImage>( ::CGImageSourceCreateImageAtIndex( sourceRef.get(), options.getIndex(), optionsDict.get() ), CGImageRelease );
		if( ! imageRef )
			throw ImageIoExceptionFailedLoad();
	}
	else
		throw ImageIoExceptionFailedLoad();

	const std::shared_ptr<__CFDictionary> imageProperties( (__CFDictionary*)::CGImageSourceCopyProperties( sourceRef.get(), NULL ), ::CFRelease );
	const std::shared_ptr<__CFDictionary> imageIndexProperties( (__CFDictionary*)::CGImageSourceCopyPropertiesAtIndex( sourceRef.get(), options.getIndex(), NULL ), ::CFRelease );

	return ImageSourceFileQuartzRef( new ImageSourceFileQuartz( imageRef.get(), options, imageProperties, imageIndexProperties ) );
}
开发者ID:AKS2346,项目名称:Cinder,代码行数:47,代码来源:ImageSourceFileQuartz.cpp

示例7: in

void XFont::read(InputSourceRef inputSource)
{
    if (inputSource->isFile())
    {
        ifstream in(inputSource->getFilePath().c_str(), ifstream::binary);
        readFromStream(in);
        in.close();
    }
    else
    {
        DataSourceRef resource = inputSource->loadDataSource();
        Buffer &buffer = resource->getBuffer();

        ReadStreamBuffer tmp(buffer);
        istream in(&tmp);
        readFromStream(in);
    }
}
开发者ID:MoonActive,项目名称:chronotext-toolkit,代码行数:18,代码来源:XFont.cpp

示例8: createFileQuartzRef

///////////////////////////////////////////////////////////////////////////////
// ImageSourceFileQuartz
ImageSourceFileQuartzRef ImageSourceFileQuartz::createFileQuartzRef( DataSourceRef dataSourceRef )
{
	::CGImageSourceRef sourceRef = NULL;
	::CGImageRef imageRef = NULL;
	
	::CFStringRef keys[1] = { kCGImageSourceShouldAllowFloat };
	::CFBooleanRef values[1] = { kCFBooleanTrue };
	::CFDictionaryRef optionsDict = ::CFDictionaryCreate( kCFAllocatorDefault, (const void **)&keys, (const void **)&values, 1, NULL, NULL );

	if( dataSourceRef->isFilePath() ) {
		::CFStringRef pathString = cocoa::createCfString( dataSourceRef->getFilePath() );
		::CFURLRef urlRef = ::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString, kCFURLPOSIXPathStyle, false );
		sourceRef = ::CGImageSourceCreateWithURL( urlRef, optionsDict );
		::CFRelease( pathString );
		::CFRelease( urlRef );
	}
	else if( dataSourceRef->isUrl() ) {
		::CFURLRef urlRef = cocoa::createCfUrl( dataSourceRef->getUrl() );
		if( ! urlRef )
			throw ImageIoExceptionFailedLoad();
		sourceRef = ::CGImageSourceCreateWithURL( urlRef, optionsDict );
		::CFRelease( urlRef );		
	}
	else { // last ditch, we'll use a dataref from the buffer
		::CFDataRef dataRef = cocoa::createCfDataRef( dataSourceRef->getBuffer() );
		if( ! dataRef )
			throw ImageIoExceptionFailedLoad();
		
		sourceRef = ::CGImageSourceCreateWithData( dataRef, optionsDict );
		::CFRelease( dataRef );
	}
	
	if( sourceRef ) {
		imageRef = ::CGImageSourceCreateImageAtIndex( sourceRef, 0, optionsDict );
		::CFRelease( sourceRef );
		if( ! imageRef )
			throw ImageIoExceptionFailedLoad();
	}
	else
		throw ImageIoExceptionFailedLoad();

	return ImageSourceFileQuartzRef( new ImageSourceFileQuartz( imageRef ) );
}
开发者ID:cthompso,项目名称:Cinder,代码行数:45,代码来源:ImageSourceFileQuartz.cpp

示例9: loadAsset

void DartTestApp::loadScript()
{
	DataSourceRef script = loadAsset( "main.dart" );
	const char *scriptPath = script->getFilePath().c_str();
	char *error = NULL;
	mIsolate = createIsolateAndSetup( scriptPath, "main", this, &error );
	if( ! mIsolate ) {
		LOG_E << "could not create isolate: " << error << endl;
		assert( 0 );
	}
	assert( mIsolate == Dart_CurrentIsolate() );

	Dart_EnterScope();

	Dart_Handle url = checkError( Dart_NewStringFromCString( scriptPath ) );
	string scriptContents = loadString( script );

	Dart_Handle source = checkError( Dart_NewStringFromCString( scriptContents.c_str() ) );
	checkError( Dart_LoadScript( url, source, 0, 0 ) );

	// apparently 'something' must be called before swapping in print,
	// else she blows up with: parser.cc:4996: error: expected: current_class().is_finalized()
	invoke( "setup" );

	Dart_Handle library = Dart_RootLibrary();
	if ( Dart_IsNull( library ) ) {
		LOG_E << "Unable to find root library" << endl;
		return;
	}

	// load in our custom _printCloser, which maps back to Log
	Dart_Handle corelib = checkError( Dart_LookupLibrary( Dart_NewStringFromCString( "dart:core" ) ) );
	Dart_Handle print = checkError( Dart_GetField( library, Dart_NewStringFromCString( "_printClosure" ) ) );
	checkError( Dart_SetField( corelib, Dart_NewStringFromCString( "_printClosure" ), print ) );

	checkError( Dart_SetNativeResolver( library, ResolveName ) );

	invoke( "main" );

	Dart_ExitScope();
    Dart_ExitIsolate();
}
开发者ID:financeCoding,项目名称:Cinder-Dart-Test,代码行数:42,代码来源:DartTestApp.cpp

示例10: mode

FollowablePath::FollowablePath(InputSourceRef inputSource, int mode)
:
mode(mode)
{
    if (inputSource->isFile())
    {
        ifstream in(inputSource->getFilePath().c_str(), ifstream::binary);
        readFromStream(in);
        in.close();
    }
    else
    {
        DataSourceRef resource = inputSource->loadDataSource();
        Buffer &buffer = resource->getBuffer();
        
        ReadStreamBuffer tmp(buffer);
        istream in(&tmp);
        readFromStream(in);
    }
}
开发者ID:MoonActive,项目名称:chronotext-toolkit,代码行数:20,代码来源:FollowablePath.cpp

示例11: loadImage

ImageSourceRef loadImage( DataSourceRef dataSource, ImageSource::Options options, string extension )
{
#if defined( CINDER_COCOA )
	cocoa::SafeNsAutoreleasePool autorelease;
#endif

	if( extension.empty() )
		extension = getPathExtension( dataSource->getFilePathHint() );
	
	return ImageIoRegistrar::createSource( dataSource, options, extension );
}
开发者ID:todayman,项目名称:Cinder,代码行数:11,代码来源:ImageIo.cpp

示例12: setSourceFile

void SamplePlayerNodeTestApp::setSourceFile( const DataSourceRef &dataSource )
{
	mSourceFile = audio::load( dataSource, audio::master()->getSampleRate() );

	getWindow()->setTitle( dataSource->getFilePath().filename().string() );

	CI_LOG_V( "SourceFile info: " );
	console() << "samplerate: " << mSourceFile->getSampleRate() << endl;
	console() << "native samplerate: " << mSourceFile->getSampleRateNative() << endl;
	console() << "channels: " << mSourceFile->getNumChannels() << endl;
	console() << "frames: " << mSourceFile->getNumFrames() << endl;
	console() << "metadata:\n" << mSourceFile->getMetaData() << endl;
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:13,代码来源:SampleTestApp.cpp

示例13: loadResource

Dart_Isolate DartTestApp::createIsolateAndSetup( const char* script_uri, const char* main, void* data, char** error )
{
	DataSourceRef snapshot = loadResource( "snapshot_gen.bin" );
	const uint8_t *snapshotData = (const uint8_t *)snapshot->getBuffer().getData();

	LOG_V << "Creating isolate " << script_uri << ", " << main << endl;
	Dart_Isolate isolate = Dart_CreateIsolate( script_uri, main, snapshotData, data, error );
	if ( isolate == NULL ) {
		LOG_E << "Couldn't create isolate: " << *error << endl;
		return NULL;
	}

	LOG_V << "Entering scope" << endl;
	Dart_EnterScope();

	// Set up the library tag handler for this isolate.
	LOG_V << "Setting up library tag handler" << endl;
	Dart_Handle result = Dart_SetLibraryTagHandler( libraryTagHandler );
	CHECK_RESULT( result );

	Dart_ExitScope();
	return isolate;
}
开发者ID:financeCoding,项目名称:Cinder-Dart-Test,代码行数:23,代码来源:DartTestApp.cpp

示例14: defined

// static
unique_ptr<SourceFile> SourceFile::create( const DataSourceRef &dataSource, size_t sampleRate )
{
	unique_ptr<SourceFile> result;

#if ! defined( CINDER_WINRT ) || ( _MSC_VER > 1800 )
	if( dataSource->getFilePathHint().extension().string() == ".ogg" )
#else
	if( dataSource->getFilePathHint().extension() == ".ogg" )
#endif
		result.reset( new SourceFileOggVorbis( dataSource, sampleRate ) );
	else {
#if defined( CINDER_COCOA )
		result.reset( new cocoa::SourceFileCoreAudio( dataSource, sampleRate ) );
#elif defined( CINDER_MSW )
		result.reset( new msw::SourceFileMediaFoundation( dataSource, sampleRate ) );
#endif
	}

	if( result )
		result->setupSampleRateConversion();

	return result;
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:24,代码来源:Source.cpp

示例15: loadFromDataSource

void XmlTree::loadFromDataSource( DataSourceRef dataSource, XmlTree *result, const XmlTree::ParseOptions &parseOptions )
{
	auto buf = dataSource->getBuffer();
	size_t dataSize = buf->getSize();
	unique_ptr<char[]> bufString( new char[dataSize+1] );
	memcpy( bufString.get(), buf->getData(), buf->getSize() );
	bufString.get()[dataSize] = 0;
	rapidxml::xml_document<> doc;    // character type defaults to char
	if( parseOptions.getParseComments() )
		doc.parse<rapidxml::parse_comment_nodes | rapidxml::parse_doctype_node>( bufString.get() );
	else
		doc.parse<rapidxml::parse_doctype_node>( bufString.get() );
	parseItem( doc, NULL, result, parseOptions );
	result->setNodeType( NODE_DOCUMENT ); // call this after parse - constructor replaces it
}
开发者ID:Ahbee,项目名称:Cinder,代码行数:15,代码来源:Xml.cpp


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