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


C++ Format类代码示例

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


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

示例1: testReadWriteFormula

void DocumentTest::testReadWriteFormula()
{
    QBuffer device;
    device.open(QIODevice::WriteOnly);

    Document xlsx1;
    xlsx1.write("A1", "=11+22");
    Format format;
    format.setFontColor(Qt::blue);
    format.setBorderStyle(Format::BorderDashDotDot);
    format.setFillPattern(Format::PatternSolid);
    xlsx1.write("A2", "=22+33", format);
    xlsx1.saveAs(&device);


    device.open(QIODevice::ReadOnly);
    Document xlsx2(&device);
    QCOMPARE(xlsx2.cellAt("A1")->dataType(), Cell::Formula);
//    QCOMPARE(xlsx2.cellAt("A1")->value().toDouble(), 0.0);
    QCOMPARE(xlsx2.cellAt("A1")->formula(), QStringLiteral("11+22"));
    QCOMPARE(xlsx2.cellAt("A2")->dataType(), Cell::Formula);
//    QCOMPARE(xlsx2.cellAt("A2")->value().toDouble(), 0.0);
    QCOMPARE(xlsx2.cellAt("A2")->formula(), QStringLiteral("22+33"));
    QVERIFY(xlsx2.cellAt("A2")->format().isValid());
    QCOMPARE(xlsx2.cellAt("A2")->format(), format);
}
开发者ID:BlackNib,项目名称:QtXlsxWriter,代码行数:26,代码来源:tst_documenttest.cpp

示例2: writePatternFillCell

void Xlsxcontrol::writePatternFillCell(Document &xlsx, const QString &cell, Format::FillPattern pattern, const QColor &color)
{
    Format format;
    format.setPatternForegroundColor(color);
    format.setFillPattern(pattern);
    xlsx.write(cell, QVariant(), format);
}
开发者ID:vbirds,项目名称:QtXlsxWriterQuick,代码行数:7,代码来源:xlsxcontrol.cpp

示例3: writeFontNameCell

void Xlsxcontrol::writeFontNameCell(Document &xlsx, const QString &cell, const QString &text)
{
    Format format;
    format.setFontName(text);
    format.setFontSize(16);
    xlsx.write(cell, text, format);
}
开发者ID:vbirds,项目名称:QtXlsxWriterQuick,代码行数:7,代码来源:xlsxcontrol.cpp

示例4: getValue

IECore::MurmurHash FormatPlug::hash() const
{
	IECore::MurmurHash result;

	if( direction()==Plug::In && !getInput<ValuePlug>() )
	{
		Format v = getValue();
		if( v.getDisplayWindow().isEmpty() )
		{
			const Gaffer::Node *n( node() );
			if( n )
			{
				const Gaffer::ScriptNode *s( n->scriptNode() );
				if ( s )
				{
					const GafferImage::FormatPlug *p( s->getChild<FormatPlug>( GafferImage::Format::defaultFormatPlugName ) );
					if ( p )
					{
						v = p->getValue();
					}
				}
			}
		}

		result.append( v.getDisplayWindow().min );
		result.append( v.getDisplayWindow().max );
		result.append( v.getPixelAspect() );
	}
	else
	{
		result = ValuePlug::hash();
	}

	return result;
} // namespace Gaffer
开发者ID:CRiant,项目名称:gaffer,代码行数:35,代码来源:FormatPlug.cpp

示例5: FloatPlug

FormatPlug::FormatPlug( const std::string &name, Direction direction, Format defaultValue, unsigned flags )
	:	ValuePlug( name, direction, flags ), m_defaultValue( defaultValue )
{
	const unsigned childFlags = flags & ~Dynamic;
	addChild( new Box2iPlug( "displayWindow", direction, defaultValue.getDisplayWindow(), childFlags ) );
	addChild( new FloatPlug( "pixelAspect", direction, defaultValue.getPixelAspect(), Imath::limits<float>::min(), Imath::limits<float>::max(), childFlags ) );
}
开发者ID:ImageEngine,项目名称:gaffer,代码行数:7,代码来源:FormatPlug.cpp

示例6: LeanifyFile

// Leanify the file
// and move the file ahead size_leanified bytes
// the new location of the file will be file_pointer - size_leanified
// it's designed this way to avoid extra memmove or memcpy
// return new size
size_t LeanifyFile(void* file_pointer, size_t file_size, size_t size_leanified /*= 0*/,
                   const string& filename /*= ""*/) {
  Format* f = GetType(file_pointer, file_size, filename);
  size_t r = f->Leanify(size_leanified);
  delete f;
  return r;
}
开发者ID:miniers,项目名称:Leanify,代码行数:12,代码来源:leanify.cpp

示例7: main

int main() 
{
    Book* book = xlCreateBook();
    if(book) 
    {         
        Font* font = book->addFont();
        font->setName(L"Impact");
        font->setSize(36);        

        Format* format = book->addFormat();
        format->setAlignH(ALIGNH_CENTER);
        format->setBorder(BORDERSTYLE_MEDIUMDASHDOTDOT);
        format->setBorderColor(COLOR_RED);
        format->setFont(font);
	               
        Sheet* sheet = book->addSheet(L"Custom");
        if(sheet)
        {
            sheet->writeStr(2, 1, L"Format", format);
            sheet->setCol(1, 1, 25);
        }

        if(book->save(L"format.xls")) 
        {
            ::ShellExecute(NULL, L"open", L"format.xls", NULL, NULL, SW_SHOW);
        }
    }
    
    return 0;
}
开发者ID:icune,项目名称:R,代码行数:30,代码来源:format.cpp

示例8: memcpy

void PCMCoder::encode(const Buffer &buffer, std::ofstream &out) const {
	RIFFHeaderChunk header_chunk;

	try {
		Format fmt = buffer.format();

		memcpy(header_chunk.id,     "RIFF", 4);
		memcpy(header_chunk.format, "WAVE", 4);
		header_chunk.size = 4 + sizeof(WaveFormatChunk) + sizeof(WaveDataChunk) + fmt.sizeForFrameCount(buffer.frameCount());
		debug_riff_header_chunk(header_chunk);
		out.write((const char *)&header_chunk, sizeof(RIFFHeaderChunk));

		WaveFormatChunk wave_format;
		memcpy(wave_format.id, "fmt ", 4);
		wave_format.size = sizeof(WaveFormatChunk) - sizeof(wave_format.id) - sizeof(wave_format.size);
		wave_format.audioFormat = 1;
		wave_format.channelCount = fmt.channelCount();
		wave_format.sampleRate = fmt.sampleRate();
		wave_format.byteRate = fmt.sizeForFrameCount(fmt.sampleRate());
		wave_format.bytePerFrame = fmt.sizeForFrameCount(1);
		wave_format.bitPerSample = fmt.bitDepth();
		debug_wave_format_chunk(wave_format);
		out.write((const char *)&wave_format, sizeof(WaveFormatChunk));

		WaveDataChunk wave_data;
		memcpy(wave_data.id, "data", 4);
		wave_data.size = fmt.sizeForFrameCount(buffer.frameCount());
		debug_wave_data_chunk(wave_data);
		out.write((const char *)&wave_data, sizeof(WaveDataChunk));
		out.write((const char *)buffer.data(), fmt.sizeForFrameCount(buffer.frameCount()));
	} catch (std::ofstream::failure ioerr) {
		Error::raise(Error::Status::IOError, ioerr.what());
	}
}
开发者ID:DarkAriel2A,项目名称:nr-audio-lib,代码行数:34,代码来源:AudioPCMCodec.cpp

示例9: shared_from_this

void Device::updateFormat( const Format &format )
{
	size_t sampleRate = format.getSampleRate();
	size_t framesPerBlock = format.getFramesPerBlock();
	if( mSampleRate == sampleRate && mFramesPerBlock == framesPerBlock )
		return;

	auto deviceMgr = Context::deviceManager();

	mSignalParamsWillChange.emit();

	if( sampleRate && sampleRate != mSampleRate ) {
		// set the samplerate to 0, forcing it to refresh on next get.
		mSampleRate = 0;
		deviceMgr->setSampleRate( shared_from_this(), sampleRate );
	}
	if( framesPerBlock && framesPerBlock != mFramesPerBlock ) {
		// set the frames per block to 0, forcing it to refresh on next get
		mFramesPerBlock = 0;
		deviceMgr->setFramesPerBlock( shared_from_this(), framesPerBlock );
	}

	if( ! deviceMgr->isFormatUpdatedAsync() )
		mSignalParamsDidChange.emit();
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:25,代码来源:Device.cpp

示例10: main

int main() 
{	
    Book* book = xlCreateBook();
    if(book)
    {
        Sheet* sheet = book->addSheet("Sheet1");
        if(sheet)
        {
            sheet->writeStr(2, 1, "Hello, World !");
            sheet->writeNum(3, 1, 1000);

            Format* dateFormat = book->addFormat();
            dateFormat->setNumFormat(NUMFORMAT_DATE);
            sheet->writeNum(4, 1, book->datePack(2008, 4, 29), dateFormat);

            sheet->setCol(1, 1, 12);
        }

        if(book->save("example.xls")) std::cout << "\nFile example.xls has been created." << std::endl;
        book->release();		
    } 

    std::cout << "\nPress any key to exit...";
    _getch();
	
    return 0;
}
开发者ID:icune,项目名称:R,代码行数:27,代码来源:generate.cpp

示例11: qWarning

bool FontSettings::loadColorScheme(const QString &fileName,
                                   const FormatDescriptions &descriptions)
{
    bool loaded = true;
    m_schemeFileName = fileName;

    if (!m_scheme.load(m_schemeFileName)) {
        loaded = false;
        m_schemeFileName.clear();
        qWarning() << "Failed to load color scheme:" << fileName;
    }

    // Apply default formats to undefined categories
    foreach (const FormatDescription &desc, descriptions) {
        const TextStyle id = desc.id();
        if (!m_scheme.contains(id)) {
            Format format;
            format.setForeground(desc.foreground());
            format.setBackground(desc.background());
            format.setBold(desc.format().bold());
            format.setItalic(desc.format().italic());
            m_scheme.setFormatFor(id, format);
        }
    }

    return loaded;
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:27,代码来源:fontsettings.cpp

示例12: get_format_info

void Grammar::get_format_info( SchemeFormatInfo* info, const string& cur_code, INFO type ) const
{
    // TODO: Adjust priority for inherited grammars.
    for( FormatMap::const_iterator it = m_formats.begin() ; it != m_formats.end() ; it++ ) {
        Format* fmt = it->second;
        string str = type == INPUT_INFO ? fmt->get_user_input_str() : fmt->get_user_output_str();
        if( str.empty() ) {
            continue;
        }
        PCode pcode;
        pcode.code = fmt->get_code();
        pcode.priority = fmt->get_priority();
        bool found = false;
        for( size_t i = 0 ; i < info->descs.size() ; i++ ) {
            if( info->descs[i].desc == str ) {
                // We are already there.
                found = true;
                if( pcode.code == cur_code ) {
                    info->current = i;
                }
                bool inserted = false;
                for( size_t j = 0 ; j < info->descs[i].codes.size() ; j++ ) {
                    int p = info->descs[i].codes[j].priority;
                    if( pcode.priority > p ) {
                        // Insert it here.
                        info->descs[i].codes.insert( info->descs[i].codes.begin() + j, pcode );
                        inserted = true;
                        break;
                    }
                }
                if( !inserted ) {
                    info->descs[i].codes.push_back( pcode );
                }
                break;
            } else {
                for ( size_t j = 0; j < info->descs[i].codes.size(); j++ ) {
                    if ( pcode.code == info->descs[i].codes[j].code ) {
                        found = true;
                        break;
                    }
                }
                if ( found ) {
                    break;
                }
            }
        }
        if( !found ) {
            PDesc desc;
            desc.desc = str;
            desc.codes.push_back( pcode );
            if( pcode.code == cur_code ) {
                info->current = info->descs.size();
            }
            info->descs.push_back( desc );
        }
    }
    if( m_inherit ) {
        m_inherit->get_format_info( info, cur_code, type );
    }
}
开发者ID:nickmat,项目名称:HistoryCal,代码行数:60,代码来源:calgrammar.cpp

示例13: parse

/*#
   @method format Format
   @brief Performs desired formatting on a target item.
   @param item The item to be formatted
   @optparam dest A string where to store the formatted data.
   @return A formatted string
   @raise ParamError if a format specifier has not been set yet.
   @raise TypeError if the format specifier can't be applied the item because of
         incompatible type.

   Formats the variable as per the given format descriptor. If the class has been
   instantiated without format, and the parse() method has not been called yet,
   a ParamError is raised. If the type of the variable is incompatible with the
   format descriptor, the method returns nil; a particular format specifier allows
   to throw a TypeError in this case.

   On success, the method returns a string containing a valid formatted representation
   of the variable.

   It is possible to provide a pre-allocated string where to store the formatted
   result to improve performace and spare memory.
*/
FALCON_FUNC  Format_format ( ::Falcon::VMachine *vm )
{
   CoreObject *einst = vm->self().asObject();
   Format *fmt = dyncast<Format*>( einst->getFalconData() );

   Item *param = vm->param( 0 );
   Item *dest = vm->param( 1 );
   if( param == 0 || ( dest != 0 && ! dest->isString() ) )
   {
      throw new ParamError( ErrorParam( e_inv_params ).extra( "X,[S]" ) );
   }
   else
   {
      CoreString *tgt;

      if( dest != 0 )
      {
         tgt = dest->asCoreString();
      }
      else {
         tgt = new CoreString;
      }

      if( ! fmt->format( vm, *param, *tgt ) )
         vm->retnil();
      else
         vm->retval( tgt );
   }
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:51,代码来源:format_ext.cpp

示例14: xlsx2

void DocumentTest::testReadWriteString()
{
    QBuffer device;
    device.open(QIODevice::WriteOnly);

    Document xlsx1;
    xlsx1.write("A1", "Hello Qt!");

    Format format;
    format.setFontColor(Qt::blue);
    format.setBorderStyle(Format::BorderDashDotDot);
    format.setFillPattern(Format::PatternSolid);
    xlsx1.write("A2", "Hello Qt again!", format);

    xlsx1.write("A3", "12345");

    xlsx1.saveAs(&device);

    device.open(QIODevice::ReadOnly);
    Document xlsx2(&device);
    QCOMPARE(xlsx2.cellAt("A1")->dataType(), Cell::String);
    QCOMPARE(xlsx2.cellAt("A1")->value().toString(), QString("Hello Qt!"));
    QCOMPARE(xlsx2.cellAt("A2")->dataType(), Cell::String);
    QCOMPARE(xlsx2.cellAt("A2")->value().toString(), QString("Hello Qt again!"));
    Format format2 = xlsx2.cellAt("A2")->format();
    QVERIFY(format2.isValid());
//    qDebug()<<format2;
//    qDebug()<<format;
    QCOMPARE(format2, format);

    QCOMPARE(xlsx2.cellAt("A3")->dataType(), Cell::String);
    QCOMPARE(xlsx2.cellAt("A3")->value().toString(), QString("12345"));
}
开发者ID:BlackNib,项目名称:QtXlsxWriter,代码行数:33,代码来源:tst_documenttest.cpp

示例15: writeHorizontalAlignCell

void Xlsxcontrol::writeHorizontalAlignCell(Document &xlsx, const QString &cell, const QString &text, Format::HorizontalAlignment align)
{
    Format format;
    format.setHorizontalAlignment(align);
    format.setBorderStyle(Format::BorderThin);
    xlsx.write(cell, text, format);
}
开发者ID:vbirds,项目名称:QtXlsxWriterQuick,代码行数:7,代码来源:xlsxcontrol.cpp


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