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


C++ os函数代码示例

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


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

示例1: qc

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
std::string CVProjectUtil::WriteQc(
	const std::string &file,
	unsigned int qcFlags,
	const std::list< std::string > &qcStuff )
{
	// Get the pathname for the Qc file
	const std::string qc( Qc( file ) );
	const std::string dir( DirName( qc ) );

	if ( _access( qc.c_str(), 00 ) == 0 )
	{
		merr << "Cannot overwrite destination qc: " << qc << std::endl;
		return "";
	}

	CreateDirectoryEx( Prefix().c_str(), dir.c_str(), NULL );

	std::ofstream os( qc.c_str() );
	if ( !os )
	{
		merr << "Couldn't write to qc: " << qc << std::endl;
		return "";
	}

	if ( qcFlags & kQcYUp )
	{
		os << "$upaxis Y\n\n";
	}
	else if ( qcFlags & kQcZUp )
	{
		os << "$upaxis Z\n\n";
	}
	else if ( qcFlags & kQcXUp )
	{
		os << "$upaxis X\n\n";
	}

	if ( m_path.length() )
	{
		os << "$cdmaterials " << Path() << "\n\n";
	}

	if ( qcFlags & kQcCollapseBones )
	{
		os << "$collapsebones\n\n";
	}

	if ( qcFlags & kQcCenterBonesOnVerts )
	{
		os << "$centerbonesonverts\n\n";
	}

	if ( qcFlags & kQcSkipBoneInBBox )
	{
		os << "$skipboneinbbox\n\n";
	}

	std::copy( qcStuff.begin(), qcStuff.end(), std::ostream_iterator< std::string >( os, "\n" ) );

	// TODO: Ask for relative names...
	os << "\n";
	os << "$modelname " << ( m_path.empty() ? "" : m_path + "/" ) << File( file ) << ".mdl\n";
	os << "\n";
	os << "$model " << File( file ) << " \"" << File( file ) << ".smd\" {\n";
	os << "}\n";
	os << "\n";
	os << "$sequence idle \"" << File( file ) << ".smd\"" << std::endl;
	os << "\n";

	os.close();

	return qc;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:76,代码来源:VProjectUtil.cpp

示例2: os

std::string CraftOutput::dump() const
{
	std::ostringstream os(std::ios::binary);
	os << "(item=\"" << item << "\", time=" << time << ")";
	return os.str();
}
开发者ID:Ekdohibs,项目名称:minetest,代码行数:6,代码来源:craftdef.cpp

示例3: os

  void LLVMState::run(STATE) {
    state_ = state;

    GCTokenImpl gct;
    JITCompileRequest* compile_request = nil<JITCompileRequest>();
    OnStack<1> os(state, compile_request);

    state->gc_dependent(gct, 0);

    bool show_machine_code_ = jit_dump_code() & cMachineCode;

    while(!thread_exit_) {

      current_compiler_ = 0;

      {
        GCIndependent guard(state, 0);

        {
          utilities::thread::Mutex::LockGuard lg(compile_lock_);

          while(compile_list_.get()->empty_p()) {
            compile_cond_.wait(compile_lock_);

            if(thread_exit_) break;
          }
        }
      }

      if(thread_exit_) break;

      {
        utilities::thread::Mutex::LockGuard guard(request_lock_);

        compile_request = try_as<JITCompileRequest>(compile_list_.get()->shift(state));
        if(!compile_request || compile_request->nil_p()) continue;
      }

      utilities::thread::Condition* cond = compile_request->waiter();

      // Don't proceed until requester has reached the wait_cond
      if(cond) wait_mutex.lock();

      Context ctx(this);
      jit::Compiler jit(&ctx);

      current_compiler_ = &jit;

      uint32_t class_id = 0;
      uint32_t serial_id = 0;
      void* func = 0;

      try {
        if(compile_request->receiver_class() &&
            !compile_request->receiver_class()->nil_p()) {
          // Apparently already compiled, probably some race
          if(compile_request->method()->find_specialized(
                compile_request->receiver_class())) {
            if(config().jit_show_compiling) {
              CompiledCode* code = compile_request->method();
              llvm::outs() << "[[[ JIT already compiled "
                        << enclosure_name(code) << "#" << symbol_debug_str(code->name())
                        << (compile_request->is_block() ? " (block)" : " (method)")
                        << " ]]]\n";
            }

            // If someone was waiting on this, wake them up.
            if(cond) {
              wait_mutex.unlock();
              cond->signal();
            }

            current_compiler_ = 0;

            continue;
          }

          class_id = compile_request->receiver_class()->class_id();
          serial_id = compile_request->receiver_class()->serial_id();
        }

        {
          timer::StopWatch<timer::microseconds> timer(
              vm()->metrics().jit.compile_time_us);

          jit.compile(compile_request);

          bool indy = !config().jit_sync;
          func = jit.generate_function(indy);
        }

        // We were unable to compile this function, likely
        // because it's got something we don't support.
        if(!func) {
          if(config().jit_show_compiling) {
            CompiledCode* code = compile_request->method();
            llvm::outs() << "[[[ JIT error background compiling "
                      << enclosure_name(code) << "#" << symbol_debug_str(code->name())
                      << (compile_request->is_block() ? " (block)" : " (method)")
                      << " ]]]\n";
//.........这里部分代码省略.........
开发者ID:Red54,项目名称:rubinius,代码行数:101,代码来源:state.cpp

示例4: test_main

int test_main(int, char*[])
{
#if !defined __BORLANDC__
    fs::path const tmpdir(fs::complete("/tmp"));
    fs::create_directory(tmpdir);
#endif // !defined __BORLANDC__

    std::string filename0("/tmp/eraseme");

    {
    std::ofstream os(filename0.c_str(), ios_out_trunc_binary());
    BOOST_TEST(os.good());

    os
        << "a=a\n"
        << "No equal sign--line should be ignored.\n"
        << "\n"
        << "b=b\n"
        << "c=\n"
        << "d==\n"
        << "e=1=.\n"
        << "f= f \r\n"
        << "this=a test\n"
        << "z=2\n"
        << "y=-3.142\n"
        << "x=2.718 \n"
        << "w= 2.718\n"
        << "v= 2.718 \n"
        << "u=\n"
        << "t= \n"
        << "s=       \n"
        ;
    }

    name_value_pairs n_v_pairs_0(filename0);
    std::map<std::string, std::string> m0 = n_v_pairs_0.map();
    BOOST_TEST(0 == std::remove(filename0.c_str()));

    BOOST_TEST_EQUAL(15, m0.size());

    // Test string_value().

    BOOST_TEST_EQUAL("a"     , n_v_pairs_0.string_value("a"));
    BOOST_TEST_EQUAL("b"     , n_v_pairs_0.string_value("b"));
    BOOST_TEST_EQUAL(""      , n_v_pairs_0.string_value("c"));
    BOOST_TEST_EQUAL("="     , n_v_pairs_0.string_value("d"));
    BOOST_TEST_EQUAL("1=."   , n_v_pairs_0.string_value("e"));
#ifndef LMI_MSW
    BOOST_TEST_EQUAL(" f \r" , n_v_pairs_0.string_value("f"));
#else  // LMI_MSW
    BOOST_TEST_EQUAL(" f "   , n_v_pairs_0.string_value("f"));
#endif // LMI_MSW
    BOOST_TEST_EQUAL("a test", n_v_pairs_0.string_value("this"));

    // Test numeric_value().

    BOOST_TEST_EQUAL( 2.0    , n_v_pairs_0.numeric_value("z"));
    BOOST_TEST_EQUAL(-3.142  , n_v_pairs_0.numeric_value("y"));
    BOOST_TEST_EQUAL( 2.718  , n_v_pairs_0.numeric_value("x"));
    BOOST_TEST_EQUAL( 2.718  , n_v_pairs_0.numeric_value("w"));
    BOOST_TEST_EQUAL( 2.718  , n_v_pairs_0.numeric_value("v"));
    BOOST_TEST_EQUAL( 0.0    , n_v_pairs_0.numeric_value("u"));
    BOOST_TEST_EQUAL( 0.0    , n_v_pairs_0.numeric_value("t"));
    BOOST_TEST_EQUAL( 0.0    , n_v_pairs_0.numeric_value("s"));

    BOOST_TEST_EQUAL("2.718" , n_v_pairs_0.string_numeric_value("v"));
    BOOST_TEST_EQUAL("0"     , n_v_pairs_0.string_numeric_value("s"));

    std::string filename1("/tmp/nonexistent_name_value_pairs_test_file");
    name_value_pairs n_v_pairs_1(filename1);
    std::map<std::string, std::string> m1 = n_v_pairs_1.map();
    BOOST_TEST_EQUAL(0, m1.size());

    return EXIT_SUCCESS;
}
开发者ID:vadz,项目名称:lmi.new,代码行数:75,代码来源:name_value_pairs_test.cpp

示例5: os

  Object* Channel::receive_timeout(STATE, GCToken gct, Object* duration, CallFrame* call_frame) {
    // Passing control away means that the GC might run. So we need
    // to stash this into a root, and read it back out again after
    // control is returned.
    //
    // DO NOT USE this AFTER wait().

    // We have to do this because we can't pass this to OnStack, since C++
    // won't let us reassign it.

    Channel* self = this;
    OnStack<2> os(state, self, duration);

    GCLockGuard lg(state, gct, call_frame, mutex_);

    if(self->semaphore_count_ > 0) {
      self->semaphore_count_--;
      return cNil;
    }

    if(!self->value_->empty_p()) return self->value_->shift(state);

    // Otherwise, we need to wait for a value.
    struct timespec ts = {0,0};
    bool use_timed_wait = true;

    if(Fixnum* fix = try_as<Fixnum>(duration)) {
      ts.tv_sec = fix->to_native();
    } else if(Float* flt = try_as<Float>(duration)) {
      uint64_t nano = (uint64_t)(flt->val * NANOSECONDS);
      ts.tv_sec  =  (time_t)(nano / NANOSECONDS);
      ts.tv_nsec =    (long)(nano % NANOSECONDS);
    } else if(duration->nil_p()) {
      use_timed_wait = false;
    } else {
      return Primitives::failure();
    }

    // We pin this so we can pass condition_ out without worrying about
    // us moving it.
    if(!self->pin()) {
      rubinius::bug("unable to pin Channel");
    }

    struct timeval tv = {0,0};
    if(use_timed_wait) {
      gettimeofday(&tv, 0);
      uint64_t nano = ts.tv_nsec + tv.tv_usec * 1000;
      ts.tv_sec  += tv.tv_sec + nano / NANOSECONDS;
      ts.tv_nsec  = nano % NANOSECONDS;
    }

    // We lock to manipulate the wait condition on the VM* so that
    // we can sync up properly with another thread trying to wake us
    // up right as we're trying to go to sleep.
    state->lock(gct, call_frame);

    if(!state->check_async(call_frame)) {
      state->unlock();
      return NULL;
    }

    state->vm()->wait_on_channel(self);

    state->unlock();

    self->waiters_++;

    bool exception = false;

    for(;;) {
      {
        GCIndependent gc_guard(state, call_frame);

        if(use_timed_wait) {
          if(self->condition_.wait_until(self->mutex_, &ts) == utilities::thread::cTimedOut) break;
        } else {
          self->condition_.wait(self->mutex_);
        }
      }

      // or there are values available.
      if(self->semaphore_count_ > 0 || !self->value()->empty_p()) break;
      if(!state->check_async(call_frame)) {
        exception = true;
        break;
      }
    }

    state->vm()->clear_waiter();
    state->vm()->thread->sleep(state, cFalse);

    self->unpin();
    self->waiters_--;

    if(exception || !state->check_async(call_frame)) return NULL;

    if(self->semaphore_count_ > 0) {
      self->semaphore_count_--;
      return cNil;
//.........这里部分代码省略.........
开发者ID:Energy0124,项目名称:rubinius,代码行数:101,代码来源:channel.cpp

示例6: main

int main( int argc, char * * argv )
{
	// initialize memory managers
	MemoryManager::init();
	NotePlayHandleManager::init();

	// intialize RNG
	srand( getpid() + time( 0 ) );

	disable_denormals();

	bool coreOnly = false;
	bool fullscreen = true;
	bool exitAfterImport = false;
	bool allowRoot = false;
	bool renderLoop = false;
	bool renderTracks = false;
	QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

	// first of two command-line parsing stages
	for( int i = 1; i < argc; ++i )
	{
		QString arg = argv[i];

		if( arg == "--help"    || arg == "-h" ||
		    arg == "--version" || arg == "-v" ||
		    arg == "--render"  || arg == "-r" )
		{
			coreOnly = true;
		}
		else if( arg == "--rendertracks" )
		{
			coreOnly = true;
			renderTracks = true;
		}
		else if( arg == "--allowroot" )
		{
			allowRoot = true;
		}
		else if( arg == "--geometry" || arg == "-geometry")
		{
			if( arg == "--geometry" )
			{
				// Delete the first "-" so Qt recognize the option
				strcpy(argv[i], "-geometry");
			}
			// option -geometry is filtered by Qt later,
			// so we need to check its presence now to
			// determine, if the application should run in
			// fullscreen mode (default, no -geometry given).
			fullscreen = false;
		}
	}

#ifndef LMMS_BUILD_WIN32
	if ( ( getuid() == 0 || geteuid() == 0 ) && !allowRoot )
	{
		printf( "LMMS cannot be run as root.\nUse \"--allowroot\" to override.\n\n" );
		return EXIT_FAILURE;
	}	
#endif

	QCoreApplication * app = coreOnly ?
			new QCoreApplication( argc, argv ) :
					new QApplication( argc, argv ) ;

	Mixer::qualitySettings qs( Mixer::qualitySettings::Mode_HighQuality );
	ProjectRenderer::OutputSettings os( 44100, false, 160,
						ProjectRenderer::Depth_16Bit );
	ProjectRenderer::ExportFileFormats eff = ProjectRenderer::WaveFile;

	// second of two command-line parsing stages
	for( int i = 1; i < argc; ++i )
	{
		QString arg = argv[i];

		if( arg == "--version" || arg == "-v" )
		{
			printVersion( argv[0] );
			return EXIT_SUCCESS;
		}
		else if( arg == "--help" || arg  == "-h" )
		{
			printHelp();
			return EXIT_SUCCESS;
		}
		else if( arg == "--upgrade" || arg == "-u" )
		{
			++i;

			if( i == argc )
			{
				printf( "\nNo input file specified.\n\n"
	"Try \"%s --help\" for more information.\n\n", argv[0] );
				return EXIT_FAILURE;
			}


			DataFile dataFile( QString::fromLocal8Bit( argv[i] ) );

//.........这里部分代码省略.........
开发者ID:ThomasJClark,项目名称:lmms,代码行数:101,代码来源:main.cpp

示例7: test_main

int test_main( int /* argc */, char* /* argv */[] )
{
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    std::list<A *> alist;
    {   
        test_ostream os(testfile, TEST_STREAM_FLAGS);
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
        A * free_a_ptr = new A;
        alist.push_back(free_a_ptr);
        alist.push_back(new A);
        // verify that first element is the same as the free pointer
        BOOST_CHECK((*alist.begin()) == free_a_ptr);
        oa << boost::serialization::make_nvp("alist", alist);
        oa << boost::serialization::make_nvp("free_a_ptr", free_a_ptr);
    }
    std::list<A *> alist1;
    {
        test_istream is(testfile, TEST_STREAM_FLAGS);
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
        A * free_a_ptr1;
        ia >> boost::serialization::make_nvp("alist", alist1);
        ia >> boost::serialization::make_nvp("free_a_ptr", free_a_ptr1);
        BOOST_CHECK(
            alist.size() == alist1.size() 
            && std::equal(alist.begin(),alist.end(),alist1.begin(),ptr_equal_to<A *>())
        );
        // verify that first element is the same as the free pointer
        BOOST_CHECK((*alist1.begin()) == free_a_ptr1);
    }

    std::for_each(
        alist.begin(), 
        alist.end(), 
        boost::checked_deleter<A>()
    );
    std::for_each(
        alist1.begin(), 
        alist1.end(), 
        boost::checked_deleter<A>()
    );
    
    #ifdef BOOST_HAS_SLIST
    std::list<A *> aslist;
    {   
        aslist.push_back(new A);
        aslist.push_back(new A);
        test_ostream os(testfile, TEST_STREAM_FLAGS);
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
        aslist.push_back(new A);
        aslist.push_back(new A);
        oa << boost::serialization::make_nvp("aslist", aslist);
    }
    std::list<A *> aslist1;
    {
        test_istream is(testfile, TEST_STREAM_FLAGS);
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
        ia >> boost::serialization::make_nvp("aslist", aslist1);
        BOOST_CHECK(aslist.size() == aslist1.size() &&
            std::equal(aslist.begin(),aslist.end(),aslist1.begin(),ptr_equal_to<A *>())
        );
    }
    std::for_each(
        aslist.begin(), 
        aslist.end(), 
        boost::checked_deleter<A>()
    );
    std::for_each(
        aslist1.begin(), 
        aslist1.end(), 
        boost::checked_deleter<A>()
    );  
    #endif
    std::remove(testfile);
    return EXIT_SUCCESS;
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:77,代码来源:test_list_ptrs.cpp

示例8: os

void IOList::writeIOList(string filename)
{
   ofstream os(filename.c_str(), ios::out);
   writeIOList(os);
   os.close();
}
开发者ID:etotheipi,项目名称:Cpp_IOList_Container_Class,代码行数:6,代码来源:IOList.cpp

示例9: os

void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
(
    const fileName& filename,
    const MeshedSurfaceProxy<Face>& surf
)
{
    const pointField& pointLst = surf.points();
    const List<Face>&  faceLst = surf.faces();
    const List<label>& faceMap = surf.faceMap();

    const List<surfZone>& zones =
    (
        surf.surfZones().empty()
      ? surfaceFormatsCore::oneZone(faceLst)
      : surf.surfZones()
    );

    const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);


    OFstream os(filename);
    if (!os.good())
    {
        FatalErrorInFunction
            << "Cannot open file for writing " << filename
            << exit(FatalError);
    }


    // Write header
    os  << "# tetgen .smesh file written " << clock::dateTime().c_str() << nl
        << "# <points count=\"" << pointLst.size() << "\">" << nl
        << pointLst.size() << " 3" << nl;    // 3: dimensions

    // Write vertex coords
    forAll(pointLst, ptI)
    {
        const point& pt = pointLst[ptI];

        os  << ptI << ' ' << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
    }
    os  << "# </points>" << nl
        << nl
        << "# <faces count=\"" << faceLst.size() << "\">" << endl;

    os  << faceLst.size() << " 1" << endl;   // one attribute: zone number


    label faceIndex = 0;
    forAll(zones, zoneI)
    {
        const surfZone& zone = zones[zoneI];

        if (useFaceMap)
        {
            forAll(zone, localFaceI)
            {
                const Face& f = faceLst[faceMap[faceIndex++]];

                os << f.size();
                forAll(f, fp)
                {
                    os << ' ' << f[fp];
                }
                os << ' ' << zoneI << endl;
            }
        }
        else
        {
            forAll(zones[zoneI], localFaceI)
            {
                const Face& f = faceLst[faceIndex++];

                os << f.size();
                forAll(f, fp)
                {
                    os << ' ' << f[fp];
                }
                os << ' ' << zoneI << endl;
            }
        }
    }
开发者ID:BarisCumhur,项目名称:OpenFOAM-dev,代码行数:82,代码来源:SMESHsurfaceFormat.C

示例10: strcpy

 bool Index::init(std::istream &is, const char *path, int open_flag)
 {
     name_[0]=0;
     if (path && path[0]) {
         strcpy(name_, path);
     }
     if (name_[0]) {
         // Prepare directory
         switch (open_flag) {
             case INDEX_CREATE_OR_OPEN:
             {
                 DIR *dir=opendir(name_);
                 if (!dir) {
                     // Create dir
                     if(mkdir(name_, 0755)!=0) {
                         return false;
                     }
                 } else {
                     closedir(dir);
                 }
             }
                 break;
             case INDEX_CREATE:
             {
                 DIR *dir=opendir(name_);
                 if (dir) {
                     // Directory exists, failed
                     closedir(dir);
                     return false;
                 }
                 // Create dir
                 if(mkdir(name_, 0755)!=0) {
                     return false;
                 }
             }
                 break;
             case INDEX_OPEN:
             {
                 DIR *dir=opendir(name_);
                 if (!dir) {
                     return false;
                 }
                 closedir(dir);
             }
                 break;
             default:
                 break;
         }
     }
     
     fc_=common::FieldConfig::load(is);
     if (!fc_) {
         return false;
     }
     
     char buf[PATH_MAX];
     ri_=create_reverse_index(common::add_suffix(buf, name_, "/rindex"));
     if (!ri_) {
         delete fc_;
         return false;
     }
     
     fi_=new index::ForwardIndex(common::add_suffix(buf, name_, "/findex"), fc_);
     if (!fi_) {
         delete ri_;
         delete fc_;
         return false;
     }
     
     if (open_flag==INDEX_CREATE || open_flag==INDEX_CREATE_OR_OPEN) {
         if (path && path[0]) {
             // Save config.xml file under the index directory if this index has a name
             char buf[PATH_MAX];
             memset(buf, 0, PATH_MAX);
             strcpy(buf, path);
             strcat(buf, "/config.xml");
             std::ofstream os(buf);
             os << fc_->serialize();
         }
     }
     return true;
 }
开发者ID:ahegongzhu,项目名称:Argos,代码行数:82,代码来源:full_index.cpp

示例11: main

int main (int argc, char** argv) {

    // Creates runtime and base app
	pI::Application app;
	pI::Runtime runtime(app.GetRuntime());

    std::cerr << "Plugin dir: " << app.FindPIPluginDir() << std::endl;
	app.LoadPluginLibraries (app.FindPIPluginDir().c_str());

	std::vector<std::string> names(GetPluginNames (runtime));
	const pI_int count(names.size());

	std::cout << "{" << std::endl;

	appendValue(std::cout, API_VERSION, runtime.GetRuntimeVersion());
	appendValue(std::cout, PLUGIN_COUNT, count);

	std::cout << "\"" << PLUGINS << "\":" << std::endl << "[" << std::endl;
	for (pI_int lv = 0; lv < count; ++lv) {
		std::cout << "{" << std::endl;
		appendValue(std::cout, NAME, names[lv]);

		if (names[lv] == "CImg/Functions") {
			// special treatment for CImg META plugin
			try {
				pI::pInPtr p(runtime.SpawnPlugin ((const pI_str) names[lv].c_str()));
				pI::Arguments params(p->GetParameterSignature());
				appendValue(std::cout, DESCRIPTION, p->GetDescription());
				appendValue(std::cout, PLUGIN_VERSION, p->GetpInVersion());
				appendValue(std::cout, API_VERSION, p->GetAPIVersion());
				appendValue(std::cout, AUTHOR, p->GetAuthor());
				appendValue(std::cout, COPYRIGHT, p->GetCopyright());
				appendValue(std::cout, OPTIONAL_INIT, "false");
				appendValue(std::cout, DEFAULT_INIT, "true");

				std::cout << "\"parameters\":" << std::endl << "[" << std::endl;
				for (pI_size lv2 = 0; lv2 < params.size(); ++lv2) {
					std::cout << runtime.SerializeArgument (params[lv2]);
					if (lv2 < params.size() - 1) {
						std::cout << ",";
					}
					std::cout << std::endl;
				}
				std::cout << "]," << std::endl;

				pI::StringSelection sts(params[0]);
				std::cout << "\"CImg functions\":" << std::endl << "[" << std::endl;
				for (pI_size lv2 = 0; lv2 < sts.GetCount(); ++lv2) {
					sts.SetIndex (lv2);
					p->Initialize (params);
					std::cout << "{" << std::endl;
					appendValue(std::cout, NAME, sts.GetSymbols (lv2));
					std::cout << "\"inputSignature\":" << std::endl << "[" << std::endl;
					pI::Arguments is(p->GetInputSignature());
					for (pI_size lv3 = 0; lv3 < is.size(); ++lv3) {
						std::cout << runtime.SerializeArgument (is[lv3]);
						if (lv3 < is.size() - 1)
							std::cout << ",";
					}
					std::cout << std::endl << "]," << std::endl;
					std::cout << "\"outputSignature\":" << std::endl << "[" << std::endl;
					pI::Arguments os(p->GetOutputSignature());
					for (pI_size lv3 = 0; lv3 < os.size(); ++lv3) {
						std::cout << runtime.SerializeArgument (os[lv3]);
						if (lv3 < os.size() - 1)
							std::cout << ",";
					}
					std::cout << std::endl << "]" << std::endl;
					std::cout << "}";
					if (lv2 < sts.GetCount() - 1)
						std::cout << ",";
					std::cout << std::endl;
				}
				std::cout << "]" << std::endl;
			} catch (...) {}
		} else {
			try {
				pI::pInPtr p(runtime.SpawnPlugin ((const pI_str) names[lv].c_str()));
				appendValue(std::cout, DESCRIPTION, p->GetDescription());
				appendValue(std::cout, PLUGIN_VERSION, p->GetpInVersion());
				appendValue(std::cout, API_VERSION, p->GetAPIVersion());
				appendValue(std::cout, AUTHOR, p->GetAuthor());
				appendValue(std::cout, COPYRIGHT, p->GetCopyright());
				bool optional_init((p->GetInputSignature().size() > 0) ||
								   (p->GetOutputSignature().size() > 0));
				appendValue(std::cout, OPTIONAL_INIT, (optional_init ? "true" : "false"));

				std::cout << "\"" << PARAMETERS << "\":" << std::endl << "[" << std::endl;
				pI::Arguments params(p->GetParameterSignature());
				for (pI_size lv2 = 0; lv2 < params.size(); ++lv2) {
					std::cout << runtime.SerializeArgument (params[lv2]);
					if (lv2 < params.size() - 1) {
						std::cout << ",";
					}
					std::cout << std::endl;
				}
				std::cout << "]," << std::endl;
				bool default_init;
				try {
					p->Initialize (params);
//.........这里部分代码省略.........
开发者ID:jondo,项目名称:pureImage,代码行数:101,代码来源:PluginLister.cpp

示例12: GetArgs

int CLocalFinderApp::Run(void)
{
    CArgs myargs = GetArgs();

    int left            = myargs["from"].AsInteger();
    int right           = myargs["to"].AsInteger();
    bool repeats        = myargs["rep"];


    //
    // read our sequence data
    //
    CFastaReader fastareader(myargs["input"].AsString());
    CRef<CSeq_loc> masked_regions;
    masked_regions = fastareader.SaveMask();
    CRef<CSeq_entry> se = fastareader.ReadOneSeq();
    
    if(masked_regions) {
        CBioseq& bioseq = se->SetSeq();     // assumes that reader gets only one sequence per fasta id (no [] in file)
        CRef<CSeq_annot> seq_annot(new CSeq_annot);
        seq_annot->SetNameDesc("NCBI-FASTA-Lowercase");
        bioseq.SetAnnot().push_back(seq_annot);
        CSeq_annot::C_Data::TFtable* feature_table = &seq_annot->SetData().SetFtable();
        for(CSeq_loc_CI i(*masked_regions); i; ++i) {
            CRef<CSeq_feat> repeat(new CSeq_feat);
            CRef<CSeq_id> id(new CSeq_id);
            id->Assign(i.GetSeq_id());
            CRef<CSeq_loc> loc(new CSeq_loc(*id, i.GetRange().GetFrom(), i.GetRange().GetTo()));
            repeat->SetLocation(*loc);
            repeat->SetData().SetImp().SetKey("repeat_region");
            feature_table->push_back(repeat);
        }
    }

    CRef<CObjectManager> objmgr = CObjectManager::GetInstance();
    CScope scope(*objmgr);
    scope.AddTopLevelSeqEntry(*se);       

    CRef<CSeq_id> cntg(new CSeq_id);
    cntg->Assign(*se->GetSeq().GetFirstId());
    CSeq_loc loc;
    loc.SetWhole(*cntg);
    CSeqVector vec(loc, scope);
    vec.SetIupacCoding();

    CResidueVec seq;
    ITERATE(CSeqVector,i,vec)
        seq.push_back(*i);

    // read the alignment information
    TGeneModelList alignments;
    if(myargs["align"]) {
        CNcbiIstream& alignmentfile = myargs["align"].AsInputFile();
        string our_contig = cntg->GetSeqIdString(true);
        string cur_contig; 
        CAlignModel algn;
        
        while(alignmentfile >> algn >> getcontig(cur_contig)) {
            if (cur_contig==our_contig)
                alignments.push_back(algn);
        }
    }

    // create engine
    CRef<CHMMParameters> hmm_params(new CHMMParameters(myargs["model"].AsInputFile()));
    CGnomonEngine gnomon(hmm_params, seq, TSignedSeqRange(left, right));

    // run!
    gnomon.Run(alignments, repeats, true, true, false, false, 10.0);

    // dump the annotation
    CRef<CSeq_annot> annot = gnomon.GetAnnot(*cntg);
    auto_ptr<CObjectOStream> os(CObjectOStream::Open(eSerial_AsnText, cout));
    *os << *annot;

    return 0;

}
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:78,代码来源:local_finder.cpp

示例13: writeVTKFile

static void writeVTKFile(CDataArray2D<float, 9> visData, int timestep)
{
	char numstr[21];
	sprintf(numstr, "%d", timestep);

	int width = visData.width;
	int height = visData.height;

	printf("%i, %i", width, height);

	std::string filename;
	filename.append("./");
	filename.append("output");
	filename.append("/");
	filename.append("LBMGrid_");
	filename.append(numstr);
	filename.append(".vtr");
		// genearte filebuf to write to file
	std::filebuf fb;
	fb.open(const_cast<char *>(filename.c_str()), std::ios::out);
	std::ostream os(&fb);

	if(!fb.is_open()){
		printf("error");
	}else{
		//printf("%s geöffnet", const_cast<char *>(filename.c_str()));
	}

	// vtk Header
	os << "<?xml version=\"1.0\"?>" << std::endl;
	os << "<VTKFile type=\"RectilinearGrid\">" << std::endl;

	// domain size
	os << "<RectilinearGrid WholeExtent=\"0 " << width << " 0 " << height
	   << " 0 0\">" << std::endl;
	os << "<Piece Extent=\"" << 0 << " " << width << " " << 0 << " " << height << " 0 0\">" << std::endl;

	// specify coordinates
	os << "<Coordinates>" << std::endl;
	os << "<DataArray type=\"Float64\" format=\"ascii\">" << std::endl;

	for(int i = 0; i <= width; ++i){
		os << (float)i << " ";
	}
	os << std::endl;

	os << "</DataArray>" << std::endl;

	// along y-Axis
	os << "<DataArray type=\"Float64\" format=\"ascii\">" << std::endl;
	for(int i = 0; i <= height; ++i){
		os << (float)i << " ";
	}
	os << std::endl;
	os << "</DataArray>" << std::endl;

	// along z-Axis (nothing to do => 2D)
	os << "<DataArray type=\"Float64\" format=\"ascii\">0 0</DataArray>"
	   << std::endl;

	os << "</Coordinates>" << std::endl;

	// add payload
	os << "<CellData Vectors=\"velocity\" Scalars=\"rho, p_force\">"
	   << std::endl;

	// 1 velocity field
	os << "<DataArray Name=\"velocity\" NumberOfComponents=\"3\" type=\"Float64\" format=\"ascii\">"
	  << std::endl;

	for(int j = height-1; j >=0; --j){
	    for(int i = 0; i < width; ++i){
	    	//printf("tut was bei %i, %i", i, j);
			os << std::scientific << visData.getRef(i, j, 0) << " " << visData.getRef(i, j, 1) << " " << 0.  // war mal u[i][j] v[i][j]
			   << std::endl;
		}
	}

	os << "</DataArray>" << std::endl;

	// 2 pressure
	os << "<DataArray type=\"Float64\" Name=\"rho\" format=\"ascii\">"
	   << std::endl;

	for(int j = height-1; j >=0; --j){
		for(int i = 0; i < width; ++i){
			os << std::scientific << visData.getRef(i, j, 2) << std::endl;
		}
	}

	os << "</DataArray>" << std::endl;

	// 3 vorticity
	os << "<DataArray type=\"Float64\" Name=\"p_force\" format=\"ascii\">"
	   << std::endl;

	for(int j = height-1; j >=0; --j){
		for(int i = 0; i < width; ++i){
			os << std::scientific << visData.getRef(i, j, 3) << std::endl;
		}
//.........这里部分代码省略.........
开发者ID:sgs-us,项目名称:talfer,代码行数:101,代码来源:CVTKTools.hpp

示例14: main

int main(int argc, char** argv)
{
    try {
        options(argc, argv);

        utils::compress_istream is(input_file, 1024 * 1024);
        utils::compress_ostream os(output_file);

        if (map_file != "-" && ! boost::filesystem::exists(map_file))
            throw std::runtime_error("no map file: " + map_file.string());

        utils::compress_istream ms(map_file);

        hypergraph_type hypergraph;
        sentence_type   sentence;
        span_set_type   spans;
        phrase_type     rhs;

        while (1) {
            is >> hypergraph;
            ms >> sentence;

            if (! is || ! ms) break;

            if (! hypergraph.is_valid()) {
                os << hypergraph << '\n';
                continue;
            }

            // map terminals...
            // we will first compute spans, then, perform terminal mapping..

            spans.clear();
            spans.resize(hypergraph.edges.size());

            cicada::span_edge(hypergraph, spans);

            for (size_t edge_id = 0; edge_id != hypergraph.edges.size(); ++ edge_id) {
                hypergraph_type::edge_type& edge = hypergraph.edges[edge_id];
                const span_type& span = spans[edge_id];
                const hypergraph_type::symbol_type lhs = edge.rule->lhs;

                rhs.clear();

                int pos = 0;
                int span_pos = span.first;
                hypergraph_type::rule_type::symbol_set_type::const_iterator riter_end = edge.rule->rhs.end();
                for (hypergraph_type::rule_type::symbol_set_type::const_iterator riter = edge.rule->rhs.begin(); riter != riter_end; ++ riter) {
                    if (riter->is_non_terminal()) {
                        const int __non_terminal_index = riter->non_terminal_index();
                        const int non_terminal_pos = utils::bithack::branch(__non_terminal_index <= 0, pos, __non_terminal_index - 1);
                        ++ pos;

                        // compute span_pos from antecedent node...

                        rhs.push_back(*riter);
                        span_pos = spans[hypergraph.nodes[edge.tails[non_terminal_pos]].edges.front()].second;
                    } else if (*riter != vocab_type::EPSILON) {
                        rhs.push_back(sentence[span_pos]);
                        ++ span_pos;
                    }
                }

                edge.rule = hypergraph_type::rule_type::create(hypergraph_type::rule_type(lhs, rhs.begin(), rhs.end()));
            }

            os << hypergraph << '\n';
        }

        if (is || ms)
            throw std::runtime_error("# of hypergraphs and # of sentences do not match");
    }
    catch (std::exception& err) {
        std::cerr << "error: " << err.what() << std::endl;
        return 1;
    }
    return 0;
}
开发者ID:hitochan777,项目名称:cicada,代码行数:78,代码来源:cicada_filter_terminal.cpp

示例15: ConvertTypeToXSD


//.........这里部分代码省略.........
                                                         sPropName, 
                                                         "name" );

                    if (sContentName.isEmpty())
                        sContentName = sContentType;

                    sType = "MapOfString" + sContentName;
                }
                else
                    sType = "ArrayOf" + sContentType;

                bCustomType = true;

            }
            else if (sType == "QStringList") 
            { 
                sType = "ArrayOfString"; 
                bCustomType = true; 
            }

            QString sNewPropName( metaProperty.name() );

            if (IsNillable( sType ))
                oNode.setAttribute( "nillable" , true );   

            if (bCustomType)
                typesToInclude.insert( sType, sContentType );
    
            oNode.setAttribute( "type"     , ((bCustomType) ? "tns:" : "xs:") +
                                       ConvertTypeToXSD( sType, bCustomType ));

            oNode.setAttribute( "name"     , sNewPropName );
            oNode.setAttribute( "minOccurs", 0            );

            oSeqNode.appendChild( oNode );
        }
    }

    // ------------------------------------------------------------------
    // Create element for class
    //
    //	   <xs:element name="<className>" nillable="true" type="tns:<className>"/>
    // ------------------------------------------------------------------

    QDomElement oElementNode = createElement( "xs:element" );

    oElementNode.setAttribute( "type"    , "tns:" + sClassName );
    oElementNode.setAttribute( "nillable", "true" );
    oElementNode.setAttribute( "name"    , sClassName );

    // ----------------------------------------------------------------------
    // Build xml tree...
    // ----------------------------------------------------------------------

    appendChild( oRoot );

    if (typesToInclude.count() > 0)
    {
        // ------------------------------------------------------------------
        // Create all needed includes
        //
        //	<xs:include schemaLocation="<path to dependant schema"/>
        // ------------------------------------------------------------------

        QString sBaseUri = "http://" + pRequest->m_mapHeaders[ "host" ] + 
                                       pRequest->m_sResourceUrl + "?type=";

        QMap<QString, QString>::const_iterator it = typesToInclude.constBegin();
        while( it != typesToInclude.constEnd())
        {
            QDomElement oIncNode = createElement( "xs:include" );
            QString     sType    = it.key();

            sType.remove( "DTC::" );

            if (it.value().isEmpty())
                oIncNode.setAttribute( "schemaLocation", sBaseUri + sType );
            else
                oIncNode.setAttribute( "schemaLocation", sBaseUri + sType + "&name=" + it.value() );
    
            oRoot.appendChild( oIncNode );
            ++it;
        }
    }

    oRoot.appendChild( oTypeNode    );
    oRoot.appendChild( oElementNode );

    // ----------------------------------------------------------------------
    // Return xsd doc to caller
    // ----------------------------------------------------------------------

    QTextStream os( &(pRequest->m_response) );

    pRequest->m_eResponseType   = ResponseTypeXML;

    save( os, 0 );

    return true;
}
开发者ID:JGunning,项目名称:OpenAOL-TV,代码行数:101,代码来源:xsd.cpp


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