Пример #1
0
void c_hoice(){

	str_in1 = strlen(in1);
	str_in2 = strlen(in2);
	str_in3 = strlen(in3);

	var_in(); if (chosen == 1) return ;

	else
	{
		if (str_in1 == 1)
		{	if (str_in2 == 0)
			{
				if (in1[0] >= 'A' && in1[0] <= 'Z')
				{
					for (int i = 0; i <= 9; i ++)
					{
						if (in1[0] == var[i])
						{
							begin_chosen = i;
							printf("        = "); comma(var_var[begin_chosen]); chosen = 1; return;

						}
						else
							begin_chosen = 100;
					}
				}

				else if (in1[0] >= 'a' && in1[0] <= 'z')
				{
					in1[0] -= 32;
					for (int i = 0; i <= 9; i ++)
					{
						if (in1[0] == var[i])
						{
							begin_chosen = i;
							printf("        = "); comma(var_var[begin_chosen]); chosen = 1; return;

						}
						else
							begin_chosen = 100;
					}
				}
			}}

		else 
		{
			choice = strcmp (in1, c_lear);
			if (choice == 0) {system("clear"); chosen = 1; return ;}
			else { choice = strcmp (in1, e_nd); 
				if (choice == 0) exit(1);
				else { choice = strcmp (in1, V_AR);
					if (choice == 0) {VAR(); chosen = 1; return ;}
					else { choice = strcmp (in1, s_ave);
						if (choice == 0) {save(); chosen = 1; return;}
						else { choice = strcmp (in1, l_oad);
							if (choice == 0) {load(); chosen = 1; return;}
						}}}}
		}
		if (begin_chosen == 100)
		{printf("        = undefined."); chosen = 1; return;}
	}

} // choice 함수
Пример #2
0
int
crackmacho(int fd, Fhdr *fp)
{
	int i;
	Macho *m;

	if((m = machoinit(fd)) == nil)
		return -1;

	fp->fd = fd;
	fp->macho = m;

	for(i=0; i<nelem(mtab); i++){
		if(m->cputype != mtab[i].etype)
			continue;
		fp->mach = mtab[i].mach;
		fp->mtype = mtab[i].mtype;
		fp->mname = mtab[i].name;
		m->coreregs = mtab[i].coreregs;
		break;
	}
	if(i == nelem(mtab)){
		werrstr("unsupported cpu type %ud", m->cputype);
		goto err;
	}

	fp->atype = AMACH;
	fp->aname = "mach";

	if(mach == nil)
		mach = fp->mach;

	switch(m->filetype){
	default:
		werrstr("unsupported macho file type %lud", m->filetype);
		goto err;
	case MachoFileObject:
		fp->ftype = FOBJ;
		fp->fname = "object";
		break;
	case MachoFileExecutable:
		fp->ftype = FEXEC;
		fp->fname = "executable";
		break;
	case MachoFileFvmlib:
		fp->ftype = FSHLIB;
		fp->fname = "shared library";
		break;
	case MachoFileCore:
		fp->ftype = FCORE;
		fp->fname = "core";
		break;
	case MachoFilePreload:
		fp->ftype = FBOOT;
		fp->fname = "preloaded executable";
		break;
	}

	fp->txtaddr = fp->dataddr = 0;
	fp->txtsz = fp->datsz = 0;
	for(i=0; i<m->ncmd; i++){
		if(m->cmd[i].type != MachoCmdSegment)
			continue;
		if(strcmp(m->cmd[i].seg.name, "__TEXT") == 0){
			fp->txtaddr = m->cmd[i].seg.vmaddr;
			fp->txtsz = m->cmd[i].seg.vmsize;
			fp->txtoff = m->cmd[i].seg.fileoff;
		}
		if(strcmp(m->cmd[i].seg.name, "__DATA") == 0){
			fp->dataddr = m->cmd[i].seg.vmaddr;
			fp->datsz = m->cmd[i].seg.filesz;
			fp->datoff = m->cmd[i].seg.fileoff;
			fp->bsssz = m->cmd[i].seg.vmsize - fp->datsz;
		}
	}

	fp->map = mapmacho;
	fp->syminit = symmacho;

	for(i=0; i<m->ncmd; i++)
		if(m->cmd[i].type == MachoCmdSymtab)
			break;
	if(i < m->ncmd){
		fp->stabs.stabbase = load(fp->fd, m->cmd[i].sym.symoff, m->cmd[i].sym.nsym*16);
		fp->stabs.stabsize = m->cmd[i].sym.nsym*16;
		fp->stabs.strbase = (char*)load(fp->fd, m->cmd[i].sym.stroff, m->cmd[i].sym.strsize);
		if(fp->stabs.stabbase == nil || fp->stabs.strbase == nil){
			fp->stabs.stabbase = nil;
			fp->stabs.strbase = nil;
		}else{
			fp->stabs.strsize = m->cmd[i].sym.strsize;
			fp->stabs.e2 = (m->e4==beload4 ? beload2 : leload2);
			fp->stabs.e4 = m->e4;
		}
	}

	return 0;

err:
	machoclose(m);
	return -1;
}
Пример #3
0
/*
 * main bzl class
 */
Sheet::Sheet(const SheetData& data, ICellObserver* obs /*= NULL*/)
  : m_mode(editMode)
  , m_pObserver(obs)
{
  load(data);
}
Пример #4
0
int GGLAssembler::scanline_core(const needs_t& needs, context_t const* c)
{
    int64_t duration = ggl_system_time();

    mBlendFactorCached = 0;
    mBlending = 0;
    mMasking = 0;
    mAA        = GGL_READ_NEEDS(P_AA, needs.p);
    mDithering = GGL_READ_NEEDS(P_DITHER, needs.p);
    mAlphaTest = GGL_READ_NEEDS(P_ALPHA_TEST, needs.p) + GGL_NEVER;
    mDepthTest = GGL_READ_NEEDS(P_DEPTH_TEST, needs.p) + GGL_NEVER;
    mFog       = GGL_READ_NEEDS(P_FOG, needs.p) != 0;
    mSmooth    = GGL_READ_NEEDS(SHADE, needs.n) != 0;
    mBuilderContext.needs = needs;
    mBuilderContext.c = c;
    mBuilderContext.Rctx = reserveReg(R0); // context always in R0
    mCbFormat = c->formats[ GGL_READ_NEEDS(CB_FORMAT, needs.n) ];

    // ------------------------------------------------------------------------

    decodeLogicOpNeeds(needs);

    decodeTMUNeeds(needs, c);

    mBlendSrc  = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_SRC, needs.n));
    mBlendDst  = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_DST, needs.n));
    mBlendSrcA = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_SRCA, needs.n));
    mBlendDstA = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_DSTA, needs.n));

    if (!mCbFormat.c[GGLFormat::ALPHA].h) {
        if ((mBlendSrc == GGL_ONE_MINUS_DST_ALPHA) ||
            (mBlendSrc == GGL_DST_ALPHA)) {
            mBlendSrc = GGL_ONE;
        }
        if ((mBlendSrcA == GGL_ONE_MINUS_DST_ALPHA) ||
            (mBlendSrcA == GGL_DST_ALPHA)) {
            mBlendSrcA = GGL_ONE;
        }
        if ((mBlendDst == GGL_ONE_MINUS_DST_ALPHA) ||
            (mBlendDst == GGL_DST_ALPHA)) {
            mBlendDst = GGL_ONE;
        }
        if ((mBlendDstA == GGL_ONE_MINUS_DST_ALPHA) ||
            (mBlendDstA == GGL_DST_ALPHA)) {
            mBlendDstA = GGL_ONE;
        }
    }

    // if we need the framebuffer, read it now
    const int blending =    blending_codes(mBlendSrc, mBlendDst) |
                            blending_codes(mBlendSrcA, mBlendDstA);

    // XXX: handle special cases, destination not modified...
    if ((mBlendSrc==GGL_ZERO) && (mBlendSrcA==GGL_ZERO) &&
        (mBlendDst==GGL_ONE) && (mBlendDstA==GGL_ONE)) {
        // Destination unmodified (beware of logic ops)
    } else if ((mBlendSrc==GGL_ZERO) && (mBlendSrcA==GGL_ZERO) &&
        (mBlendDst==GGL_ZERO) && (mBlendDstA==GGL_ZERO)) {
        // Destination is zero (beware of logic ops)
    }
    
    int fbComponents = 0;
    const int masking = GGL_READ_NEEDS(MASK_ARGB, needs.n);
    for (int i=0 ; i<4 ; i++) {
        const int mask = 1<<i;
        component_info_t& info = mInfo[i];
        int fs = i==GGLFormat::ALPHA ? mBlendSrcA : mBlendSrc;
        int fd = i==GGLFormat::ALPHA ? mBlendDstA : mBlendDst;
        if (fs==GGL_SRC_ALPHA_SATURATE && i==GGLFormat::ALPHA)
            fs = GGL_ONE;
        info.masked =   !!(masking & mask);
        info.inDest =   !info.masked && mCbFormat.c[i].h && 
                        ((mLogicOp & LOGIC_OP_SRC) || (!mLogicOp));
        if (mCbFormat.components >= GGL_LUMINANCE &&
                (i==GGLFormat::GREEN || i==GGLFormat::BLUE)) {
            info.inDest = false;
        }
        info.needed =   (i==GGLFormat::ALPHA) && 
                        (isAlphaSourceNeeded() || mAlphaTest != GGL_ALWAYS);
        info.replaced = !!(mTextureMachine.replaced & mask);
        info.iterated = (!info.replaced && (info.inDest || info.needed)); 
        info.smooth =   mSmooth && info.iterated;
        info.fog =      mFog && info.inDest && (i != GGLFormat::ALPHA);
        info.blend =    (fs != int(GGL_ONE)) || (fd > int(GGL_ZERO));

        mBlending |= (info.blend ? mask : 0);
        mMasking |= (mCbFormat.c[i].h && info.masked) ? mask : 0;
        fbComponents |= mCbFormat.c[i].h ? mask : 0;
    }

    mAllMasked = (mMasking == fbComponents);
    if (mAllMasked) {
        mDithering = 0;
    }
    
    fragment_parts_t parts;

    // ------------------------------------------------------------------------
    prolog();
    // ------------------------------------------------------------------------

    build_scanline_prolog(parts, needs);

    if (registerFile().status())
        return registerFile().status();

    // ------------------------------------------------------------------------
    label("fragment_loop");
    // ------------------------------------------------------------------------
    {
        Scratch regs(registerFile());

        if (mDithering) {
            // update the dither index.
            MOV(AL, 0, parts.count.reg,
                    reg_imm(parts.count.reg, ROR, GGL_DITHER_ORDER_SHIFT));
            ADD(AL, 0, parts.count.reg, parts.count.reg,
                    imm( 1 << (32 - GGL_DITHER_ORDER_SHIFT)));
            MOV(AL, 0, parts.count.reg,
                    reg_imm(parts.count.reg, ROR, 32 - GGL_DITHER_ORDER_SHIFT));
        }

        // XXX: could we do an early alpha-test here in some cases?
        // It would probaly be used only with smooth-alpha and no texture
        // (or no alpha component in the texture).

        // Early z-test
        if (mAlphaTest==GGL_ALWAYS) {
            build_depth_test(parts, Z_TEST|Z_WRITE);
        } else {
            // we cannot do the z-write here, because
            // it might be killed by the alpha-test later
            build_depth_test(parts, Z_TEST);
        }

        { // texture coordinates
            Scratch scratches(registerFile());

            // texel generation
            build_textures(parts, regs);
            if (registerFile().status())
                return registerFile().status();
        }

        if ((blending & (FACTOR_DST|BLEND_DST)) || 
                (mMasking && !mAllMasked) ||
                (mLogicOp & LOGIC_OP_DST)) 
        {
            // blending / logic_op / masking need the framebuffer
            mDstPixel.setTo(regs.obtain(), &mCbFormat);

            // load the framebuffer pixel
            comment("fetch color-buffer");
            load(parts.cbPtr, mDstPixel);
        }

        if (registerFile().status())
            return registerFile().status();

        pixel_t pixel;
        int directTex = mTextureMachine.directTexture;
        if (directTex | parts.packed) {
            // note: we can't have both here
            // iterated color or direct texture
            pixel = directTex ? parts.texel[directTex-1] : parts.iterated;
            pixel.flags &= ~CORRUPTIBLE;
        } else {
            if (mDithering) {
                const int ctxtReg = mBuilderContext.Rctx;
                const int mask = GGL_DITHER_SIZE-1;
                parts.dither = reg_t(regs.obtain());
                AND(AL, 0, parts.dither.reg, parts.count.reg, imm(mask));
                ADDR_ADD(AL, 0, parts.dither.reg, ctxtReg, parts.dither.reg);
                LDRB(AL, parts.dither.reg, parts.dither.reg,
                        immed12_pre(GGL_OFFSETOF(ditherMatrix)));
            }
        
            // allocate a register for the resulting pixel
            pixel.setTo(regs.obtain(), &mCbFormat, FIRST);

            build_component(pixel, parts, GGLFormat::ALPHA,    regs);

            if (mAlphaTest!=GGL_ALWAYS) {
                // only handle the z-write part here. We know z-test
                // was successful, as well as alpha-test.
                build_depth_test(parts, Z_WRITE);
            }

            build_component(pixel, parts, GGLFormat::RED,      regs);
            build_component(pixel, parts, GGLFormat::GREEN,    regs);
            build_component(pixel, parts, GGLFormat::BLUE,     regs);

            pixel.flags |= CORRUPTIBLE;
        }

        if (registerFile().status())
            return registerFile().status();
        
        if (pixel.reg == -1) {
            // be defensive here. if we're here it's probably
            // that this whole fragment is a no-op.
            pixel = mDstPixel;
        }
        
        if (!mAllMasked) {
            // logic operation
            build_logic_op(pixel, regs);
    
            // masking
            build_masking(pixel, regs); 
    
            comment("store");
            store(parts.cbPtr, pixel, WRITE_BACK);
        }
    }

    if (registerFile().status())
        return registerFile().status();

    // update the iterated color...
    if (parts.reload != 3) {
        build_smooth_shade(parts);
    }

    // update iterated z
    build_iterate_z(parts);

    // update iterated fog
    build_iterate_f(parts);

    SUB(AL, S, parts.count.reg, parts.count.reg, imm(1<<16));
    B(PL, "fragment_loop");
    label("epilog");
    epilog(registerFile().touched());

    if ((mAlphaTest!=GGL_ALWAYS) || (mDepthTest!=GGL_ALWAYS)) {
        if (mDepthTest!=GGL_ALWAYS) {
            label("discard_before_textures");
            build_iterate_texture_coordinates(parts);
        }
        label("discard_after_textures");
        build_smooth_shade(parts);
        build_iterate_z(parts);
        build_iterate_f(parts);
        if (!mAllMasked) {
            ADDR_ADD(AL, 0, parts.cbPtr.reg, parts.cbPtr.reg, imm(parts.cbPtr.size>>3));
        }
        SUB(AL, S, parts.count.reg, parts.count.reg, imm(1<<16));
        B(PL, "fragment_loop");
        epilog(registerFile().touched());
    }
Пример #5
0
GFF3File::GFF3File(Common::SeekableReadStream *gff3, uint32 id) : _stream(gff3) {
	load(id);
}
Пример #6
0
iimage::iimage(const Size2D &size,Image<DetectorImgType> *i_load)
    :img_data(size),w(size.w),h(size.h)
{
    if(i_load)
        load(*i_load);
}
Пример #7
0
TGA::TGA(Common::SeekableReadStream &tga) {
	load(tga);
}
Пример #8
0
int main(int, const char * []) {
  IloEnv env;
  try {
    IloModel model(env);
    IloInt m, o, c, q;

    IloInt         nbOrders   = 12;
    IloInt         nbSlabs    = 12;
    IloInt         nbColors   = 8;
    IloIntArray    capacities(env, 20, 0, 11, 13, 16, 17, 19, 20,
                                       23, 24, 25, 26, 27, 28, 29,
                                       30, 33, 34, 40, 43, 45);
    IloIntArray    sizes(env, nbOrders, 22, 9, 9, 8, 8, 6, 5, 3, 3, 3, 2, 2);
    IloIntArray    colors(env, nbOrders,  5, 3, 4, 5, 7, 3, 6, 0, 2, 3, 1, 5);
    IloIntVarArray where(env, nbOrders, 0, nbSlabs-1);
    IloIntVarArray load(env, nbSlabs, 0, IloSum(sizes));
  // Pack constraint
    model.add(IloPack(env, load, where, sizes));
  // Color constraints
    for(m = 0; m < nbSlabs; m++) {
      IloExprArray colorExpArray(env);
      for(c = 0; c < nbColors; c++) {
        IloOr orExp(env);
        for(o = 0; o < nbOrders; o++){
          if (colors[o] == c){
            orExp.add(where[o] == m);
          }
        }
        colorExpArray.add(orExp);
      }
      model.add(IloSum(colorExpArray) <= 2);
    }

  // Objective function
    IloIntArray lossValues(env);
    lossValues.add(0);
    for(q = 1; q < capacities.getSize(); q++){
      for(IloInt p = capacities[q-1] + 1; p <= capacities[q]; p++){
        lossValues.add(capacities[q] - p);
      }
    }
    IloExpr obj(env);
    for(m = 0; m < nbSlabs; m++){
      obj += lossValues[load[m]];
    }
    model.add(IloMinimize(env, obj));
    for(m = 1; m < nbSlabs; m++){
      model.add(load[m-1] >= load[m]);
    }
    IloCP cp(model);
    if (cp.solve(IloSearchPhase(env, where))){
      cp.out() << "Optimal value: " << cp.getValue(obj) << std::endl;
      for (m = 0; m < nbSlabs; m++) {
        IloInt p = 0;
        for (o = 0; o < nbOrders; o++)
          p += cp.getValue(where[o]) == m;
        if (p == 0) continue;
        cp.out() << "Slab " << m << " is used for order";
        if (p > 1) cp.out() << "s";
        cp.out() << " :";
        for (o = 0; o < nbOrders; o++) {
          if (cp.getValue(where[o]) == m)
            cp.out() << " " << o;
        }
        cp.out() << std::endl;
      }
    }
  }
  catch (IloException& ex) {
    env.out() << "Error: " << ex << std::endl;
  }
  env.end();
  return 0;
}
void QgsDatumTransformDialog::on_mHideDeprecatedCheckBox_stateChanged( int )
{
  load();
}
Пример #10
0
Settings::Settings(AllocatorI* _allocator, const void* _data, uint32_t _len)
	: m_allocator(_allocator)
	, m_ini(NULL)
{
	load(_data, _len);
}
Пример #11
0
void Settings::clear()
{
	load(NULL, 0);
}
Пример #12
0
/*!
 * \brief Load a boot image from binary data
 *
 * This function loads a boot image from a vector containing the binary data.
 * The boot image headers and other images (eg. kernel and ramdisk) will be
 * copied and stored.
 *
 * \warning If the boot image cannot be loaded, do not use the same BootImage
 *          object to load another boot image as it may contain partially
 *          loaded data.
 *
 * \return Whether the boot image was successfully read and parsed.
 */
bool BootImage::load(const std::vector<unsigned char> &data)
{
    return load(data.data(), data.size());
}
Пример #13
0
 Shader::Shader(const std::string& path, Type type) {
     create(type);
     load(path, type);
 }
Пример #14
0
bool ConfigManager::initialize()
{
  if (isInitialized())
  {
    std::cerr << "CONFIG WARNING: The configuration framework is already initialized!" << std::endl;
    return true;
  }

  if (Getopt::instance().paramOptPresent("configfile"))
  {
    // Read the configuration file.
    icl_core::String filename = Getopt::instance().paramOpt("configfile");
    if (!load(filename))
    {
      std::cerr << "CONFIG ERROR: The configuration file '" << filename << "' could not be loaded!"
          << std::endl;
      return false;
    }
    insert(CONFIGFILE_CONFIG_KEY, filename);
    notify(CONFIGFILE_CONFIG_KEY);
  }

  // Check for registered parameters.
  for (ConfigParameterList::const_iterator it = m_parameter_list.begin(); it != m_parameter_list.end(); ++it)
  {
    if (it->configKey() != "")
    {
      // Fill the configuration parameter from the commandline.
      if (Getopt::instance().paramOptPresent(it->option()))
      {
        insert(it->configKey(), Getopt::instance().paramOpt(it->option()));
        notify(it->configKey());
      }
      // If the parameter is still not present but has a default value, then set it.
      else if (!hasKey(it->configKey()) && it->hasDefaultValue())
      {
          insert(it->configKey(), it->defaultValue());
          notify(it->configKey());
      }
    }
  }

  // Check for registered positional parameters.
  for (ConfigPositionalParameterList::const_iterator it = m_postional_parameter_list.begin(); it != m_postional_parameter_list.end(); ++it)
  {
    if (it->configKey() != "")
    {
      // Fill the configuration parameter from the commandline.
      if (Getopt::instance().paramOptPresent(it->name()))
      {
        insert(it->configKey(), Getopt::instance().paramOpt(it->name()));
        notify(it->configKey());
      }
      // If the parameter is still not present but has a default value, then set it.
      else if (!hasKey(it->configKey()) && it->hasDefaultValue())
      {
          insert(it->configKey(), it->defaultValue());
          notify(it->configKey());
      }
    }
  }

  // Check for option parameters.
  Getopt::KeyValueList option_params = Getopt::instance().paramPrefixOpt("config-option");
  for (Getopt::KeyValueList::const_iterator it = option_params.begin(); it != option_params.end(); ++it)
  {
    insert(it->m_key, it->m_value);
    notify(it->m_key);
  }

  // Optionally dump the configuration.
  if (Getopt::instance().paramOptPresent("dump-config"))
  {
    dump();
  }

  m_initialized = true;
  return true;
}
Пример #15
0
bool VBO::loadVolatile()
{
	return load(true);
}
Пример #16
0
ParameterEditor::ParameterEditor(QWidget* parent) :
        QDialog (parent)
{
    setAttribute(Qt::WA_DeleteOnClose,true);
    QSettings settings;
    settings.beginGroup("Editor");
    if (settings.contains("Geometry")) {
        restoreGeometry(settings.value("Geometry").toByteArray());
    } else {
        setGeometry(0,0,600,600);;
    }
    settings.endGroup();
    setAutoFillBackground(true);
    pixmapLabel = new QLabel(this);
    setWindowTitle("Editor");
    // This gets replaced with the controls from the 'plugins'.
    controlWidget = new QWidget (this);

    QWidget *controls_pane = new QWidget (this);
    controlLayout = new QGridLayout (this);
    controlLayout->setColumnMinimumWidth(0,150);
    controlLayout->setColumnMinimumWidth(1,150);
    controls_pane->setLayout(controlLayout);
    display = new DisplayFrame (this);
    display->setFixedSize(300,300);
    controlLayout->addWidget(display,0,0,1,2);
    controlLayout->addWidget(controlWidget,2,0,1,2);
    tree = new ShowTreeWidget (this);
    tree->setIconSize(QSize(48,48));
    QStringList headerlabels;
    headerlabels.push_back(tr("Source"));
    headerlabels.push_back(tr("Parameters"));
    tree->setHeaderLabels(headerlabels);
    tree->setColumnWidth (0,250);
    connect (tree,SIGNAL(itemClicked(QTreeWidgetItem *, int)),this,SLOT(itemClickedData(QTreeWidgetItem *, int)));
    connect (tree,SIGNAL(itemSelectionChanged()),this,SLOT(selectionChangedData()));
    root = NULL;
    available = new NodeSelectorWidget (this);
    available->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding);

    displayTimer = new QTimer (this);
    connect (displayTimer,SIGNAL(timeout()),this,SLOT(updateDisplay()));
    playbutton = new QPushButton (this);
    playbutton->setText(tr("Run"));
    playbutton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    connect (playbutton,SIGNAL(clicked(bool)),this,SLOT(playButtonData(bool)));
    stopbutton = new QPushButton (this);
    stopbutton->setText(tr("Stop/Reset"));
    stopbutton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    connect (stopbutton,SIGNAL(clicked(bool)),this,SLOT(stopButtonData(bool)));
    controlLayout->addWidget(playbutton,1,0);
    controlLayout->addWidget(stopbutton,1,1);

    hbox = new QHBoxLayout(this);
    hbox->addWidget(tree);
    hbox->addWidget(available);
    hbox->addWidget (controls_pane);

    load (SourceImplPtr());
    setLayout(hbox);
    
    show();
}
Пример #17
0
KRecConfigGeneral::KRecConfigGeneral( QWidget* p, const char*, const QStringList& s )
 : KCModule( KRecConfigGeneralFactory::instance(), p, s )
 , _layout( 0 ), _layout_display( 0 )
 , _display_title( 0 )
 , _displaybox( 0 ), _framebasebox( 0 )
 , _display0( 0 ), _display1( 0 ), _display2( 0 ), _display3( 0 )
 , _framebase30( 0 ), _framebase25( 0 ), _framebase75( 0 ), _framebaseother( 0 )
 , _framebaseotherbox( 0 ), _framebaseotherlabel( 0 ), _framebaseotherline( 0 )
 , _displaymode( 0 ), _framebase( 25 )
{
	_layout = new QBoxLayout( this, QBoxLayout::TopToBottom );

	_layout->addSpacing( 10 );
	_display_title = new QLabel( i18n( "<qt><b>Timedisplay Related Settings</b></qt>" ), this );
	_layout->addWidget( _display_title, -100 );

	_layout_display = new QBoxLayout( _layout, QBoxLayout::LeftToRight );
	_layout->setStretchFactor( _layout_display, -100 );

	_displaybox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Timedisplay Style" ), this );
	_layout_display->addWidget( _displaybox, 100 );
	connect( _displaybox, SIGNAL( clicked( int ) ), this, SLOT( displaychanged( int ) ) );
	_display0 = new QRadioButton( i18n( "Plain samples" ), _displaybox );
	_display1 = new QRadioButton( i18n( "[hours:]mins:secs:samples" ), _displaybox );
	_display2 = new QRadioButton( i18n( "[hours:]mins:secs:frames" ), _displaybox );
	_display3 = new QRadioButton( i18n( "MByte.KByte" ), _displaybox );
	_framebasebox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Framebase" ), this );
	_layout_display->addWidget( _framebasebox, 100 );
	connect( _framebasebox, SIGNAL( clicked( int ) ), this, SLOT( framebasechanged( int ) ) );
	_framebase30 = new QRadioButton( i18n( "30 frames per second (American TV)" ), _framebasebox );
	_framebase25 = new QRadioButton( i18n( "25 frames per second (European TV)" ), _framebasebox );
	_framebase75 = new QRadioButton( i18n( "75 frames per second (CD)" ), _framebasebox );
	_framebaseother = new QRadioButton( i18n( "Other" ), _framebasebox );
	_framebaseotherbox = new QHBox( _framebasebox );
	_framebaseotherbox->setSpacing( 2 );
	_framebaseotherlabel = new QLabel( i18n( "Other" ), _framebaseotherbox );
	_framebaseotherline = new QLineEdit( _framebaseotherbox );
	_framebaseotherline->setMaxLength( 10 );
	_framebaseotherbox->setEnabled( false );
	connect( _framebaseotherline, SIGNAL( textChanged( const QString& ) ), this, SLOT( framebaseotherchanged( const QString& ) ) );

	_layout->addSpacing( 5 );
	_verboseDisplayMode = new QCheckBox( i18n( "Show verbose times ( XXmins:XXsecs:XXframes instead of XX:XX::XX )" ), this );
	connect( _verboseDisplayMode, SIGNAL( toggled( bool ) ), this, SLOT( verboseDisplayChanged( bool ) ) );
	_layout->addWidget( _verboseDisplayMode );

	_layout->addSpacing( 10 );
	_other_title = new QLabel( i18n( "<qt><b>Miscellaneous Settings</b></qt>" ), this );
	_layout->addWidget( _other_title );

	_tipofday = new QCheckBox( i18n( "Show tip of the day at startup" ), this );
	connect( _tipofday, SIGNAL( toggled( bool ) ), this, SLOT( tipofdaychanged( bool ) ) );
	_layout->addWidget( _tipofday );
	QBoxLayout* _tmplayout = new QBoxLayout( this, QBoxLayout::LeftToRight );
	_enableAllMessages = new KPushButton( i18n( "Enable All Hidden Messages" ), this );
	connect( _enableAllMessages, SIGNAL( clicked() ), this, SLOT( enableallmessagesclicked() ) );
	_tmplayout->addWidget( _enableAllMessages );
	QLabel* _tmplbl = new QLabel( i18n( "<qt><i>All messages with the \"Don't show this message again\" option are shown again after selecting this button.</i></qt>" ), this );
	_tmplayout->addWidget( _tmplbl );
	_layout->addLayout( _tmplayout );

	_layout->addStretch( 100 );

	load();
}
Пример #18
0
IniFileConfiguration::IniFileConfiguration(std::istream& istr)
{
	load(istr);
}
Пример #19
0
/*!
  Load, parse, and process a qdoc configuration file. This
  function is only called by the other load() function, but
  this one is recursive, i.e., it calls itself when it sees
  an \c{include} statement in the qdog configuration file.
 */
void Config::load(Location location, const QString& fileName)
{
    QRegExp keySyntax("\\w+(?:\\.\\w+)*");

#define SKIP_CHAR() \
    do { \
        location.advance(c); \
        ++i; \
        c = text.at(i); \
        cc = c.unicode(); \
    } while (0)

#define SKIP_SPACES() \
    while (c.isSpace() && cc != '\n') \
        SKIP_CHAR()

#define PUT_CHAR() \
    word += c; \
    SKIP_CHAR();

    if (location.depth() > 16)
        location.fatal(tr("Too many nested includes"));

    QFile fin(fileName);
    if (!fin.open(QFile::ReadOnly | QFile::Text)) {
        fin.setFileName(fileName + ".qdoc");
        if (!fin.open(QFile::ReadOnly | QFile::Text))
            location.fatal(tr("Cannot open file '%1': %2").arg(fileName).arg(fin.errorString()));
    }

    QTextStream stream(&fin);
    stream.setCodec("UTF-8");
    QString text = stream.readAll();
    text += QLatin1String("\n\n");
    text += QChar('\0');
    fin.close();

    location.push(fileName);
    location.start();

    int i = 0;
    QChar c = text.at(0);
    uint cc = c.unicode();
    while (i < (int) text.length()) {
        if (cc == 0)
            ++i;
        else if (c.isSpace()) {
            SKIP_CHAR();
        }
        else if (cc == '#') {
            do {
                SKIP_CHAR();
            } while (cc != '\n');
        }
        else if (isMetaKeyChar(c)) {
            Location keyLoc = location;
            bool plus = false;
            QString stringValue;
            QStringList stringListValue;
            QString word;
            bool inQuote = false;
            bool prevWordQuoted = true;
            bool metWord = false;

            MetaStack stack;
            do {
                stack.process(c, location);
                SKIP_CHAR();
            } while (isMetaKeyChar(c));

            QStringList keys = stack.getExpanded(location);
            //qDebug() << "KEYS:" << keys;
            SKIP_SPACES();

            if (keys.count() == 1 && keys.first() == "include") {
                QString includeFile;

                if (cc != '(')
                    location.fatal(tr("Bad include syntax"));
                SKIP_CHAR();
                SKIP_SPACES();
                while (!c.isSpace() && cc != '#' && cc != ')') {
                    includeFile += c;
                    SKIP_CHAR();
                }
                SKIP_SPACES();
                if (cc != ')')
                    location.fatal(tr("Bad include syntax"));
                SKIP_CHAR();
                SKIP_SPACES();
                if (cc != '#' && cc != '\n')
                    location.fatal(tr("Trailing garbage"));

                /*
                  Here is the recursive call.
                 */
                load(location,
                      QFileInfo(QFileInfo(fileName).dir(), includeFile)
                      .filePath());
            }
            else {
                /*
                  It wasn't an include statement, so it;s something else.
                 */
                if (cc == '+') {
                    plus = true;
                    SKIP_CHAR();
                }
                if (cc != '=')
                    location.fatal(tr("Expected '=' or '+=' after key"));
                SKIP_CHAR();
                SKIP_SPACES();

                for (;;) {
                    if (cc == '\\') {
                        int metaCharPos;

                        SKIP_CHAR();
                        if (cc == '\n') {
                            SKIP_CHAR();
                        }
                        else if (cc > '0' && cc < '8') {
                            word += QChar(c.digitValue());
                            SKIP_CHAR();
                        }
                        else if ((metaCharPos = QString::fromLatin1("abfnrtv").indexOf(c)) != -1) {
                            word += "\a\b\f\n\r\t\v"[metaCharPos];
                            SKIP_CHAR();
                        }
                        else {
                            PUT_CHAR();
                        }
                    }
                    else if (c.isSpace() || cc == '#') {
                        if (inQuote) {
                            if (cc == '\n')
                                location.fatal(tr("Unterminated string"));
                            PUT_CHAR();
                        }
                        else {
                            if (!word.isEmpty()) {
                                if (metWord)
                                    stringValue += QLatin1Char(' ');
                                stringValue += word;
                                stringListValue << word;
                                metWord = true;
                                word.clear();
                                prevWordQuoted = false;
                            }
                            if (cc == '\n' || cc == '#')
                                break;
                            SKIP_SPACES();
                        }
                    }
                    else if (cc == '"') {
                        if (inQuote) {
                            if (!prevWordQuoted)
                                stringValue += QLatin1Char(' ');
                            stringValue += word;
                            if (!word.isEmpty())
                                stringListValue << word;
                            metWord = true;
                            word.clear();
                            prevWordQuoted = true;
                        }
                        inQuote = !inQuote;
                        SKIP_CHAR();
                    }
                    else if (cc == '$') {
                        QString var;
                        SKIP_CHAR();
                        while (c.isLetterOrNumber() || cc == '_') {
                            var += c;
                            SKIP_CHAR();
                        }
                        if (!var.isEmpty()) {
                            char *val = getenv(var.toLatin1().data());
                            if (val == 0) {
                                location.fatal(tr("Environment variable '%1' undefined").arg(var));
                            }
                            else {
                                word += QString(val);
                            }
                        }
                    }
                    else {
                        if (!inQuote && cc == '=')
                            location.fatal(tr("Unexpected '='"));
                        PUT_CHAR();
                    }
                }

                QStringList::ConstIterator key = keys.begin();
                while (key != keys.end()) {
                    if (!keySyntax.exactMatch(*key))
                        keyLoc.fatal(tr("Invalid key '%1'").arg(*key));

                    if (plus) {
                        if (locMap[*key].isEmpty()) {
                            locMap[*key] = keyLoc;
                        }
                        else {
                            locMap[*key].setEtc(true);
                        }
                        if (stringValueMap[*key].isEmpty()) {
                            stringValueMap[*key] = stringValue;
                        }
                        else {
                            stringValueMap[*key] +=
                                QLatin1Char(' ') + stringValue;
                        }
                        stringListValueMap[*key] += stringListValue;
                    }
                    else {
                        locMap[*key] = keyLoc;
                        stringValueMap[*key] = stringValue;
                        stringListValueMap[*key] = stringListValue;
                    }
                    ++key;
                }
            }
        }
        else {
            location.fatal(tr("Unexpected character '%1' at beginning of line")
                            .arg(c));
        }
    }
}
Пример #20
0
IniFileConfiguration::IniFileConfiguration(const std::string& path)
{
	load(path);
}
Пример #21
0
//---------------------------------------------------------------------------------------------------
void analyse(const char* directoryName, int chipId)
{
//--- initialize internal data-structures	
  initialize();

//--- read last DAC temperature information used as "training" data
  load(directoryName, chipId);

//--- prepare output graphs

  for ( Int_t itemprange = 0; itemprange < numTempRanges; itemprange++ ){
    TGraph* graph = gADCgraph_Measurement[chipId][itemprange];

    Int_t numPoints = 0;
    for ( Int_t itemperature = 0; itemperature < numTemperatures; itemperature++ ){
      Double_t adcValue   = gADCvalue_Measurement[chipId][itemprange][itemperature];
      Double_t blackLevel = gADCvalue_blackLevel[chipId][itemperature];
//--- only include measurements that correspond to a positive voltage difference
//    (i.e. have an ADC value above the black level)
//    and are within the amplification linear range, below the amplifier saturation
      if ( adcValue > minADCvalue_graph && adcValue < maxADCvalue_graph ){
	graph->SetPoint(numPoints, temperatureValues_target[itemperature], adcValue);
	numPoints++;
      }
    }
  }

  for ( Int_t itemprange = 0; itemprange < numTempRanges; itemprange++ ){
    TGraph* graph = gADCgraph_Calibration[chipId][itemprange];

    Int_t numPoints = 0;
    for ( Int_t itemperature = 0; itemperature < numTemperatures; itemperature++ ){
      Double_t adcValue   = gADCvalue_Calibration[chipId][itemprange][itemperature];
      Double_t blackLevel = gADCvalue_blackLevel[chipId][itemperature];
      //--- only include measurements that correspond to a positive voltage difference
      //    (i.e. have an ADC value above the black level)
      //    and are within the amplification linear range, below the amplifier saturation
      if ( adcValue > minADCvalue_graph && adcValue < maxADCvalue_graph ){
	graph->SetPoint(numPoints, temperatureValues_target[itemperature], adcValue);
	numPoints++;
      }
    }
  }


//--- initialise dummy histogram
//    (neccessary for drawing graphs)
  TH1F* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", numTemperatures, temperatureValues_target[0] - 1, temperatureValues_target[numTemperatures - 1] + 1);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetStats(false);
//   dummyHistogram->GetXaxis()->SetTitle("T / degrees");
  dummyHistogram->GetXaxis()->SetTitleOffset(1.2);
//   dummyHistogram->GetYaxis()->SetTitle("ADC");
  dummyHistogram->GetYaxis()->SetTitleOffset(1.3);
  dummyHistogram->SetMaximum(1.25*maxADCvalue_graph);

//--- prepare graph showing range in which the temperature has been measured
//    and the precision of the cooling-box of reaching the temperature setting
    dummyHistogram->GetXaxis()->SetTitle("T/C    ");
    dummyHistogram->GetXaxis()->SetTitleOffset(0.5);
    dummyHistogram->GetXaxis()->SetTitleSize(0.06);
//   dummyHistogram->GetYaxis()->SetTitle("T_{actual} / degrees");
  dummyHistogram->SetMinimum(minADCvalue_graph);
  dummyHistogram->SetMaximum(maxADCvalue_graph);

//--- draw output graphs
  TLegend* legendTempRanges = new TLegend(0.13, 0.47, 0.68, 0.87, NULL, "brNDC");
  legendTempRanges->SetFillColor(10);
  legendTempRanges->SetLineColor(10);

  c1->cd(14);
  //  TString title = Form("ADC Measurement for ROC%i", chipId);
  //  dummyHistogram->SetTitle(title);
  legendTempRanges->Clear();
  Int_t numGraphs = 0;
  for ( Int_t itemprange = 0; itemprange < numTempRanges; itemprange++ ){
    if ( gADCgraph_Measurement[chipId][itemprange]->GetN() >= 2 ){
      if ( numGraphs == 0 ) dummyHistogram->Draw();
      gADCgraph_Measurement[chipId][itemprange]->SetLineColor((itemprange % 8) + 1);
      gADCgraph_Measurement[chipId][itemprange]->SetLineStyle((itemprange / 8) + 1);
      gADCgraph_Measurement[chipId][itemprange]->SetLineWidth(2);
      gADCgraph_Measurement[chipId][itemprange]->Draw("L");
      numGraphs++;
      TString label = Form("Vref = %3.2f", vReference[itemprange]);
      legendTempRanges->AddEntry(gADCgraph_Measurement[chipId][itemprange], label, "l");
    }
  }
   
  tl->DrawLatex(0.12, 0.92, "ADC Measurement"); 
   if ( numGraphs > 0 ){
     legendTempRanges->Draw();
    
//     gCanvas->Update();
//     gPostScript->NewPage();
   }
  
  
  c1->cd(15);
//   TString title = Form("ADC Calibration for ROC%i", chipId);
//   dummyHistogram->SetTitle(title);
  legendTempRanges->Clear();
  Int_t numGraphs = 0;
  for ( Int_t itemprange = 0; itemprange < numTempRanges; itemprange++ ){
    if ( gADCgraph_Calibration[chipId][itemprange]->GetN() >= 2 ){
      if ( numGraphs == 0 ) dummyHistogram->Draw();
      gADCgraph_Calibration[chipId][itemprange]->SetLineColor((itemprange % 8) + 1);
      gADCgraph_Calibration[chipId][itemprange]->SetLineStyle((itemprange / 8) + 1);
      gADCgraph_Calibration[chipId][itemprange]->SetLineWidth(2);
      gADCgraph_Calibration[chipId][itemprange]->Draw("L");
      numGraphs++;
      TString label = Form("Vref = %3.2f", vReference[itemprange]);
      legendTempRanges->AddEntry(gADCgraph_Calibration[chipId][itemprange], label, "l");
    }
  }
 
  tl->DrawLatex(0.12, 0.92, "ADC Calibration");   
   if ( numGraphs > 0 ){
     legendTempRanges->Draw();
    
//     gCanvas->Update();
//     gPostScript->NewPage();
   }
   	
  //  delete gCanvas;
  //  delete gPostScript;
}
Пример #22
0
void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const {
	if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;

	_data->automaticLoad(_realParent->fullId(), _parent->data());
	bool loaded = _data->loaded(), displayLoading = _data->displayLoading();
	bool selected = (selection == FullSelection);

	auto paintx = 0, painty = 0, paintw = width(), painth = height();
	bool bubble = _parent->hasBubble();

	int captionw = paintw - st::msgPadding.left() - st::msgPadding.right();

	if (displayLoading) {
		ensureAnimation();
		if (!_animation->radial.animating()) {
			_animation->radial.start(_data->progress());
		}
	}
	updateStatusText();
	bool radial = isRadialAnimation(ms);

	if (bubble) {
		if (!_caption.isEmpty()) {
			painth -= st::mediaCaptionSkip + _caption.countHeight(captionw);
			if (isBubbleBottom()) {
				painth -= st::msgPadding.bottom();
			}
		}
	} else {
		App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners);
	}

	auto inWebPage = (_parent->media() != this);
	auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
	auto roundCorners = inWebPage ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
		| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
	QRect rthumb(rtlrect(paintx, painty, paintw, painth, width()));

	const auto good = _data->goodThumbnail();
	if (good && good->loaded()) {
		p.drawPixmap(rthumb.topLeft(), good->pixSingle({}, _thumbw, _thumbh, paintw, painth, roundRadius, roundCorners));
	} else {
		if (good) {
			good->load({});
		}
		p.drawPixmap(rthumb.topLeft(), _data->thumb->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, paintw, painth, roundRadius, roundCorners));
	}
	if (selected) {
		App::complexOverlayRect(p, rthumb, roundRadius, roundCorners);
	}

	QRect inner(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize);
	p.setPen(Qt::NoPen);
	if (selected) {
		p.setBrush(st::msgDateImgBgSelected);
	} else if (isThumbAnimation(ms)) {
		auto over = _animation->a_thumbOver.current();
		p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over));
	} else {
		bool over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel);
		p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg);
	}

	{
		PainterHighQualityEnabler hq(p);
		p.drawEllipse(inner);
	}

	if (!selected && _animation) {
		p.setOpacity(1);
	}

	auto icon = ([this, radial, selected, loaded]() -> const style::icon * {
		if (loaded && !radial) {
			return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay);
		} else if (radial || _data->loading()) {
			if (_parent->data()->id > 0 || _data->uploading()) {
				return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
			}
			return nullptr;
		}
		return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
	})();
	if (icon) {
		icon->paintInCenter(p, inner);
	}
	if (radial) {
		QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)));
		_animation->radial.draw(p, rinner, st::msgFileRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg);
	}

	auto statusX = paintx + st::msgDateImgDelta + st::msgDateImgPadding.x(), statusY = painty + st::msgDateImgDelta + st::msgDateImgPadding.y();
	auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x();
	auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y();
	App::roundRect(p, rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
	p.setFont(st::normalFont);
	p.setPen(st::msgDateImgFg);
	p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());

	// date
	if (!_caption.isEmpty()) {
		auto outbg = _parent->hasOutLayout();
		p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg));
		_caption.draw(p, st::msgPadding.left(), painty + painth + st::mediaCaptionSkip, captionw, style::al_left, 0, -1, selection);
	} else if (_parent->media() == this) {
		auto fullRight = paintx + paintw, fullBottom = painty + painth;
		_parent->drawInfo(p, fullRight, fullBottom, 2 * paintx + paintw, selected, InfoDisplayType::Image);
		if (!bubble && _parent->displayRightAction()) {
			auto fastShareLeft = (fullRight + st::historyFastShareLeft);
			auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize);
			_parent->drawRightAction(p, fastShareLeft, fastShareTop, 2 * paintx + paintw);
		}
	}
}
Пример #23
0
GFF3Struct::GFF3Struct(const GFF3File &parent, uint32 offset) : _parent(&parent) {
	load(offset);
}
Пример #24
0
Door::Door(Module &module, const Aurora::GFF3Struct &door) : Situated(kObjectTypeDoor),
	_module(&module), _genericType(Aurora::kFieldIDInvalid), _state(kStateClosed),
	_linkedToFlag(kLinkedToNothing), _linkedToType(kObjectTypeAll) {

	load(door);
}
Пример #25
0
blargg_err_t Nsfe_Emu::load( Emu_Reader& in )
{
	header_t h;
	BLARGG_RETURN_ERR( in.read( &h, sizeof h ) );
	return load( h, in );
}
Пример #26
0
AppleDisk::AppleDisk(std::shared_ptr<Reader> readerBlock0, std::shared_ptr<Reader> readerPM)
: m_reader(readerBlock0)
{
	load(readerPM);
}
Пример #27
0
CStage2::CStage2(std::ifstream& f) :
IStage("Stage2")
{
	load(f, 0);
}
Пример #28
0
AppleDisk::AppleDisk(std::shared_ptr<Reader> reader)
	: m_reader(reader)
{
	load(nullptr);
}
Пример #29
0
void lua_ai_context::load_and_inject_ai_table(ai::engine_lua* engine)
{
	load(); //stack size is 1 [-1: ai_context]
	generate_and_push_ai_table(L, engine); //stack size is 2 [-1: ai_table -2: ai_context]
	lua_setfield(L, -2, "ai"); //stack size is 1 [-1: ai_context]
}
Пример #30
0
int _tmain(int argc, _TCHAR* argv[])
{
    try
    {
        require( argc == 3, USAGE );
        require( fileExists( argv[1] ), "File not found" );
        require( fileExists( argv[2] ), "File not found" );

        TCOMIXMLDOMDocument3 xml = Msxml2_tlb::CoDOMDocument60::Create();
        TCOMIXMLDOMDocument3 xsl = Msxml2_tlb::CoDOMDocument60::Create();
        xsl->resolveExternals = VARIANT_TRUE;

        load( xml, argv[1] );
        load( xsl, argv[2] );

        BSTR result = NULL;
        Msxml2_tlb::IXMLDOMNodePtr pXSLDOM = xsl->documentElement;

        HRESULT hr = xml->transformNode( pXSLDOM, &result );

        if (FAILED(hr))
        {
            WideString errMsg = L"Failure code obtained from transformNode. ";

            // Try to get extended error info...
            IErrorInfo* errorInfo = NULL;

            if ( SUCCEEDED( GetErrorInfo( 0, &errorInfo ) ) )
            {
                boost::shared_ptr<void> releaseOnExit( errorInfo, release );

                BSTR reason = NULL;

                if ( SUCCEEDED( errorInfo->GetDescription( &reason ) ) )
                {
                    boost::shared_ptr<void> freeStringOnExit( reason, freeString );

                    if ( reason )
                    {
                        errMsg += WideString(reason);
                    }
                }
            }

            throw Exception( UnicodeString( errMsg ) );
        }

        boost::shared_ptr<void> freeStringOnExit( result, freeString );

        WideString ws(result);
        std::wcout << (wchar_t*)ws;

        return 0;
    }
    catch( Exception& e )
    {
        printError( e.Message );
    }
    catch( const std::exception& e )
    {
        printError( e.what() );
    }
    catch( ... )
    {
        printError( "Unspecified exception" );
    }
	return 1;
}