コード例 #1
0
void KeypadProcessor_Tests::OnKeyPressed_WillNotifyAboutDelCharChange_OnlyAfterChangeHasOccurred()
{
    QString wholeInputOnChangeNotification;
    KeypadProcessor processor([](){}
                            , [](){}
                            , [&](){ wholeInputOnChangeNotification = processor.GetWholeInput(); });
    processor.OnKeyPressed("1");
    processor.OnKeyPressed("2");

    processor.OnKeyPressed(KeypadProcessor::delChar);

    QCOMPARE(wholeInputOnChangeNotification, QString("1"));
}
コード例 #2
0
/**************************************************************************
Function  : ProcessLine
Parameters: Line    character pointer to line of input data
Returns   : nothing

If line type has been determined, call correct line processor through
a function pointer.  Else try testing for both Tasm style line and Masm
style line to determine if either one is the input to the filter.
**************************************************************************/
void ProcessLine(char *Line)
{
    if (processor == NULL)
    {
       if (ProcessTasmLine(Line))            /* check for TASM line */
          processor = ProcessTasmLine;
       else
          if (ProcessNonTasmLine(Line))      /* check MASM or OPTASM style */
             processor = ProcessNonTasmLine;
    }
    else
       processor(Line);                      /* type already determined */
}
コード例 #3
0
void ClientConnection::processLogs(const std::string& employeeId)
{
    LogProcessor processor(employeeId);
    processor.checkEmployeeId();
    auto& query = findUnprocessedLogEntriesForEmployeeQ();
    query.execute(employeeId);
    ServerLogEntry entry;
    while (query.next(entry))
    {
        processor.process(std::move(entry));
    }
    processor.finish();
}
コード例 #4
0
void KeypadProcessor_Tests::OnKeyPressed_WillNotifyAboutChange_WhenDivByTenPressed()
{
    bool changeCallbackCalled = false;
    KeypadProcessor processor([](){}
                            , [](){}
                            , [&](){ changeCallbackCalled = true; });
    processor.OnKeyPressed("1");
    changeCallbackCalled = false;

    processor.OnKeyPressed(KeypadProcessor::divByTen);

    QCOMPARE(changeCallbackCalled, true);
}
コード例 #5
0
ファイル: unicode.cpp プロジェクト: 315234/lyx-retina
vector<char_type>
eightbit_to_ucs4(char const * s, size_t ls, string const & encoding)
{
	static QThreadStorage<map<string, IconvProcessor> *> static_processors;
	if (!static_processors.hasLocalData())
		static_processors.setLocalData(new map<string, IconvProcessor>);
	map<string, IconvProcessor> & processors = *static_processors.localData();
	if (processors.find(encoding) == processors.end()) {
		IconvProcessor processor(ucs4_codeset, encoding.c_str());
		processors.insert(make_pair(encoding, processor));
	}
	return iconv_convert<char_type>(processors[encoding], s, ls);
}
コード例 #6
0
ファイル: A3.cpp プロジェクト: Wooklien/Operation-Systems
int main(int argc, char* argv[]) {
	string runtime;
	/* Checks for valid number of arguments passed in. */
	if(argc < 2) {
		runtime = "10";
	}
	else {
		runtime = argv[1];
	}

	A3 processor(runtime);
	processor.timers();
}
U_NAMESPACE_BEGIN

void GlyphPositioningTableHeader::process(LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments, le_bool rightToLeft,
                                          LETag scriptTag, LETag languageTag,
                                          const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
                                          const LEFontInstance *fontInstance, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const
{
    GlyphPositioningLookupProcessor processor(this, scriptTag, languageTag, featureMap, featureMapCount, featureOrder);

    processor.process(glyphStorage, glyphPositionAdjustments, rightToLeft, glyphDefinitionTableHeader, fontInstance);

    glyphPositionAdjustments->applyCursiveAdjustments(glyphStorage, rightToLeft, fontInstance);
}
コード例 #8
0
void CppEditorDocument::setPreprocessorSettings(const CppTools::ProjectPart::Ptr &projectPart,
        const QByteArray &defines)
{
    const auto parser = processor()->parser();
    QTC_ASSERT(parser, return);
    if (parser->projectPart() != projectPart || parser->configuration().editorDefines != defines) {
        CppTools::BaseEditorDocumentParser::Configuration config = parser->configuration();
        config.manuallySetProjectPart = projectPart;
        config.editorDefines = defines;
        parser->setConfiguration(config);

        emit preprocessorSettingsChanged(!defines.trimmed().isEmpty());
    }
}
コード例 #9
0
ファイル: utility.cpp プロジェクト: Dj-Corps/jstoolnpp
void loadOption(HWND nppHandle, StruOptions& struOptions)
{
    loadDefaultOption(struOptions);
    tstring tsConfigFilePath = GetConfigFilePath(nppHandle);

    IniFileProcessor processor(tsConfigFilePath);
    IniFileProcessor::IniMap map;

    map = processor.GetInfo(true);
    IniFileProcessor::IniMap::iterator itrEnd = map.end();

    if(map.find(keyPutCR) != itrEnd)
    {
        if(!map[keyPutCR].GetStrValue().compare("0"))
            struOptions.bPutCR = false;
    }

    if(map.find(keyChIndent) != itrEnd)
    {
        string strIndent = map[keyChIndent].GetStrValue();
        if(!strIndent.compare("tab"))
            struOptions.chIndent = '\t';
        else if(!strIndent.compare("space"))
            struOptions.chIndent = ' ';
    }

    if(map.find(keyChPerInd) != itrEnd)
    {
        struOptions.nChPerInd = atoi(map[keyChPerInd].GetStrValue().c_str());
    }

    if(map.find(keyNLBracket) != itrEnd)
    {
        if(!map[keyNLBracket].GetStrValue().compare("1"))
            struOptions.bNLBracket = true;
    }

    if(map.find(keyKeepTopComt) != itrEnd)
    {
        if(!map[keyKeepTopComt].GetStrValue().compare("1"))
            struOptions.bKeepTopComt = true;
    }

    if(map.find(keyIndentInEmpty) != itrEnd)
    {
        if(!map[keyIndentInEmpty].GetStrValue().compare("1"))
            struOptions.bIndentInEmpty = true;
    }
}
コード例 #10
0
void analyze_binary_region(const RT::BinaryRegion& binaryRegion, std::set<RT::BinaryBlock*>& binaryBlocks) {


	RT::RecursiveTraversalInstructionProcessor processor(
		&binaryRegion, binaryRegion.baseAddress() + binaryRegion.entryPointOffset()
	);
	
	processor.setBinaryBlocks(&binaryBlocks);

	
	// The current_memory_address should not be into any pre-existing binary block
	if(is_address_within_blocks(processor.currentAddress(), binaryBlocks)) {
		return;
	}
	
	processor.pushAddressToDisassemble(processor.currentAddress());
	
	while(1) {
		// Empty stack? End.
		if(processor.addressesToDisassemble().empty()) {
			break;
		}
		
		// Get last address to disassemble
		processor.setCurrentAddressToDisassemble(processor.popLastAddressToDisassemble());
		
		// if our address doesn't overlays any block and is within the binary region, keep disassembling
		while(!is_address_within_blocks(processor.currentAddress(), binaryBlocks) && 
			is_address_within_binary_region(binaryRegion,processor.currentAddress()))
		{

			RT::Instruction* inst = my_disass_function(binaryRegion, processor.currentAddress());

			std::cout << "Current address: " << processor.currentAddress() << std::endl;

			std::cout << "Length: " << inst->length() << std::endl;
			
			// According to the instruction type, need to do something
			inst->getExecuted(processor);
			
			delete inst;
		}
		
		// Register the last block
		processor.fillBinaryBlocks();
	}
	
	dump_binary_blocks(binaryBlocks);
}
コード例 #11
0
ファイル: unicode.cpp プロジェクト: djmitche/lyx
char ucs4_to_eightbit(char_type ucs4, string const & encoding)
{
	static map<string, IconvProcessor> processors;
	map<string, IconvProcessor>::iterator it = processors.find(encoding);
	if (it == processors.end()) {
		IconvProcessor processor(encoding.c_str(), ucs4_codeset);
		it = processors.insert(make_pair(encoding, processor)).first;
	}

	char out;
	int const bytes = it->second.convert((char *)(&ucs4), 4, &out, 1);
	if (bytes > 0)
		return out;
	return 0;
}
コード例 #12
0
void AudioBasicProcessorNode::process(size_t framesToProcess)
{
    AudioBus* destinationBus = output(0)->bus();
    
    // The realtime thread can't block on this lock, so we call tryLock() instead.
    if (m_processLock.tryLock()) {
        if (!isInitialized() || !processor())
            destinationBus->zero();
        else {
            AudioBus* sourceBus = input(0)->bus();

            // FIXME: if we take "tail time" into account, then we can avoid calling processor()->process() once the tail dies down.
            if (!input(0)->isConnected())
                sourceBus->zero();
            
            processor()->process(sourceBus, destinationBus, framesToProcess);  
        }

        m_processLock.unlock();
    } else {
        // Too bad - the tryLock() failed.  We must be in the middle of re-connecting and were already outputting silence anyway...
        destinationBus->zero();
    }
}
コード例 #13
0
ファイル: readfilemap.c プロジェクト: 252525fb/rpcs3
int
filemap(const char *name,
        void (*processor)(const void *, size_t, const char *, void *arg),
        void *arg)
{
  size_t nbytes;
  int fd;
  int n;
  struct stat sb;
  void *p;

  fd = open(name, O_RDONLY|O_BINARY);
  if (fd < 0) {
    perror(name);
    return 0;
  }
  if (fstat(fd, &sb) < 0) {
    perror(name);
    return 0;
  }
  if (!S_ISREG(sb.st_mode)) {
    fprintf(stderr, "%s: not a regular file\n", name);
    return 0;
  }
  nbytes = sb.st_size;
  p = malloc(nbytes);
  if (!p) {
    fprintf(stderr, "%s: out of memory\n", name);
    return 0;
  }
  n = read(fd, p, nbytes);
  if (n < 0) {
    perror(name);
    free(p);
    close(fd);
    return 0;
  }
  if (n != nbytes) {
    fprintf(stderr, "%s: read unexpected number of bytes\n", name);
    free(p);
    close(fd);
    return 0;
  }
  processor(p, nbytes, name, arg);
  free(p);
  close(fd);
  return 1;
}
コード例 #14
0
ファイル: starview.cpp プロジェクト: lizardo/Iceberg
void StarView::update(const Job &job)
{
    if (job.state() == Job::WaitingForCS) {
        drawNodeStatus();
        return;
    }

    unsigned int hostid = processor(job);
    if (!hostid)
        return;

    HostItem *hostItem = findHostItem(hostid);
    if (!hostItem)
        return;

    hostItem->update(job);

    bool finished = job.state() == Job::Finished || job.state() == Job::Failed;

    QMap<unsigned int, HostItem *>::Iterator it;
    it = m_jobMap.find(job.jobId());
    if (it != m_jobMap.end()) {
        (*it)->update(job);
        if (finished) {
            m_jobMap.erase(it);
            unsigned int clientid = job.client();
            HostItem *clientItem = findHostItem(clientid);
            if (clientItem)
                clientItem->setIsActiveClient(false);
        }
        drawNodeStatus();
        return;
    }

    if (!finished)
        m_jobMap.insert(job.jobId(), hostItem);

    if (job.state() == Job::Compiling) {
        unsigned int clientid = job.client();
        HostItem *clientItem = findHostItem(clientid);
        if (clientItem) {
            clientItem->setClient(clientid);
            clientItem->setIsActiveClient(true);
        }
    }

    drawNodeStatus();
}
コード例 #15
0
ファイル: rmdup.cpp プロジェクト: cboursnell/sga
// Compute the hits for each read in the input file without threading
// Return the number of reads processed
size_t computeRmdupHitsSerial(const std::string& prefix, const std::string& readsFile, 
                              const OverlapAlgorithm* pOverlapper, StringVector& filenameVec)
{
    std::string filename = prefix + RMDUPHITS_EXT + GZIP_EXT;
    filenameVec.push_back(filename);

    RmdupProcess processor(filename, pOverlapper);
    RmdupPostProcess postProcessor;

    size_t numProcessed = 
           SequenceProcessFramework::processSequencesSerial<SequenceWorkItem,
                                                            OverlapResult, 
                                                            RmdupProcess, 
                                                            RmdupPostProcess>(readsFile, &processor, &postProcessor);
    return numProcessed;
}
コード例 #16
0
void profile() {
   MapSafeVector loadedMaps;
   RouteProcessor processor(&loadedMaps);
   while(!feof(stdin)) {
      char packinfo[Processor::c_maxPackInfo];
      DataBuffer buf(4);
      if ( fread( buf.getBufferAddress(), 4, 1, stdin) != 1 )
         exit(0);
      uint32 packSize = buf.readNextLong();
      RequestPacket* packet = new RequestPacket(packSize+4);
      if ( fread ( packet->getBuf(), packSize, 1, stdin ) != 1 )
         exit(0); 
      processor.handleRequest(packet, packinfo);
   }
   exit(0);
}
コード例 #17
0
 virtual void StartEndpoints(const std::vector<EndpointDescription>& endpoints, OpcUa::Services::SharedPtr server) override
 {
   for (const EndpointDescription endpoint : endpoints)
   {
     const Common::Uri uri(endpoint.EndpointURL);
     if (uri.Scheme() == "opc.tcp")
     {
       std::shared_ptr<IncomingConnectionProcessor> processor(new OpcTcp(server, Debug));
       TcpParameters tcpParams;
       tcpParams.Port = uri.Port();
       if (Debug) std::clog << "opc_tcp_processor| Starting listen port " << tcpParams.Port << std::endl;
       TcpAddon.Listen(tcpParams, processor);
       Ports.push_back(tcpParams);
     }
   }
 }
コード例 #18
0
ファイル: overlap.cpp プロジェクト: Bioinformaticsnl/sga
// Compute the hits for each read in the input file without threading
// Return the number of reads processed
size_t computeHitsSerial(const std::string& prefix, const std::string& readsFile, 
                         const OverlapAlgorithm* pOverlapper, int minOverlap, 
                         StringVector& filenameVec, std::ostream* pASQGWriter)
{
    std::string filename = prefix + HITS_EXT + GZIP_EXT;
    filenameVec.push_back(filename);

    OverlapProcess processor(filename, pOverlapper, minOverlap);
    OverlapPostProcess postProcessor(pASQGWriter, pOverlapper);

    size_t numProcessed = 
           SequenceProcessFramework::processSequencesSerial<SequenceWorkItem,
                                                            OverlapResult, 
                                                            OverlapProcess, 
                                                            OverlapPostProcess>(readsFile, &processor, &postProcessor);
    return numProcessed;
}
コード例 #19
0
ファイル: unicode.cpp プロジェクト: djmitche/lyx
void ucs4_to_multibytes(char_type ucs4, vector<char> & out,
	string const & encoding)
{
	static map<string, IconvProcessor> processors;
	map<string, IconvProcessor>::iterator it = processors.find(encoding);
	if (it == processors.end()) {
		IconvProcessor processor(encoding.c_str(), ucs4_codeset);
		it = processors.insert(make_pair(encoding, processor)).first;
	}

	out.resize(4);
	int bytes = it->second.convert((char *)(&ucs4), 4, &out[0], 4);
	if (bytes > 0)
		out.resize(bytes);
	else
		out.clear();
}
コード例 #20
0
// Compute the gap array for the first n items in pReader
void computeGapArray(SeqReader* pReader, size_t n, const BWT* pBWT, bool doReverse, int numThreads, GapArray* pGapArray, 
                     bool removeMode, size_t& num_strings_read, size_t& num_symbols_read)
{
    // Create the gap array
    size_t gap_array_size = pBWT->getBWLen() + 1;
    pGapArray->resize(gap_array_size);

    // The rank processor calculates the rank of every suffix of a given sequence
    // and returns a vector of ranks. The postprocessor takes in the vector
    // and updates the gap array
    RankPostProcess postProcessor(pGapArray);
    size_t numProcessed = 0;
    if(numThreads <= 1)
    {
        RankProcess processor(pBWT, pGapArray, doReverse, removeMode);

        numProcessed = 
           SequenceProcessFramework::processSequencesSerial<SequenceWorkItem,
                                                            RankResult, 
                                                            RankProcess, 
                                                            RankPostProcess>(*pReader, &processor, &postProcessor, n);
    }
    else
    {
        typedef std::vector<RankProcess*> RankProcessVector;
        RankProcessVector rankProcVec;
        for(int i = 0; i < numThreads; ++i)
        {
            RankProcess* pProcess = new RankProcess(pBWT, pGapArray, doReverse, removeMode);
            rankProcVec.push_back(pProcess);
        }
    
        numProcessed = 
           SequenceProcessFramework::processSequencesParallel<SequenceWorkItem,
                                                              RankResult, 
                                                              RankProcess, 
                                                              RankPostProcess>(*pReader, rankProcVec, &postProcessor, n);

        for(int i = 0; i < numThreads; ++i)
            delete rankProcVec[i];
    }

    num_strings_read = postProcessor.getNumStringsProcessed();
    num_symbols_read = postProcessor.getNumSymbolsProcessed();
    assert(n == (size_t)-1 || (numProcessed == n));
}
コード例 #21
0
ファイル: SimpleCli.cpp プロジェクト: jaychhatpar/Galileo
int SimpleCli::interact(int ch)
{
	if ((ch == ARROW_UP) && (cursor == 0)) {
		// execute last successful command
		for(cursor = 0; ; cursor++) {
			cmd[cursor] = hist[cursor];
			if (cmd[cursor] == '\0')
				break;
		}
		if (term) term->puts(cmd);
		return 0;
	}

	if (ch == '\n' && *cmd) {
		if (processor && (processor(cmd, term) == 0))
			memcpy(hist, cmd, sizeof(cmd));
		for(uint8_t i = 0; i < cursor; i++)
			cmd[i] = '\0';
		cursor = 0;
	}

	// backspace processing
	if ((ch == '\b') || (ch == 127)) { // Backspace coded as 'Ctr+?' == 127
		if (cursor) {
			cursor--;
			cmd[cursor] = '\0';
			if (term) {
				term->putch(' ');
				term->putch('\b');
			}
		}
	}

	if (ch < ' ' || ch == 127)
		return 0;

	cmd[cursor++] = (uint8_t)ch;
	cursor &= CMD_LEN;
	// clean up in case of overflow (command too long)
	if (!cursor) {
		for(uint8_t i = 0; i <= CMD_LEN; i++)
			cmd[i] = '\0';
	}

	return 0;
}
コード例 #22
0
ファイル: Pass.cpp プロジェクト: obhi-d/nextar
// todo Optimize.
void Pass::View::UpdateParams(CommitContext& ctx, ParameterContext type,
		uint32 id) {
	NEX_ASSERT(this == ctx.pass);

	ParameterGroupItem& item = paramGroupEntries[(uint32) type];
	ctx.paramContext = CommitContext::ParamContext(
			item.offsetInParamBuffer, ctx.paramBuffers[(uint32) type]);

	for (auto it = item.beginIt; it != item.endIt; ++it) {
		ParameterGroup* group = (*it).group;
		NEX_ASSERT(group->context == type);
		if (group->lastUpdateId == id) {
			ctx.paramContext.first += group->size;
			if (type == ParameterContext::CTX_OBJECT)
				group->lastUpdateId = id;
			continue;
		}

		ctx.paramGroup = group;
		if (group->processor) {
			ctx.groupDataPtr = nullptr;
			group->Map(ctx.renderContext);
			group->processor(ctx, group);
			group->Unmap(ctx.renderContext);
		} else {
			ctx.groupDataPtr = group->Map(ctx.renderContext);
			for (uint32 i = 0; i < group->numParams; ++i) {
				ConstantParameter* parameter = group->GetParamByIndex(i);
				NEX_ASSERT(parameter->processor);
				parameter->processor(ctx, parameter);
			}
			group->Unmap(ctx.renderContext);
		}
		(*it)->lastUpdateId = id;
	}

	ctx.paramGroup = nullptr;
	for (auto it = item.beginSamplerIt; it != item.endSamplerIt; it =
			SamplerParameter::Next(it)) {
		NEX_ASSERT(it->processor);
		if (it->context == type)
			it->processor(ctx, it);
	}
}
コード例 #23
0
int main(int argc, char ** argv)
{
  google::SetUsageMessage("This tool extracts some staticstics about features and its altitudes.");
  google::ParseCommandLineFlags(&argc, &argv, true);

  LOG(LINFO, ("srtm_dir_path =", FLAGS_srtm_dir_path));
  LOG(LINFO, ("mwm_file_path =", FLAGS_mwm_file_path));

  classificator::Load();
  generator::SrtmTileManager manager(FLAGS_srtm_dir_path);

  Processor processor(manager);
  feature::ForEachFromDat(FLAGS_mwm_file_path, processor);

  cout << endl << "Road feature count = " << processor.m_roadCount << endl;
  cout << "Empty road feature count = " << processor.m_emptyRoadCount << endl;
  cout << "Unique road points count = " << processor.m_uniqueRoadPoints.size() << endl;
  cout << "All road point count = " << processor.m_roadPointCount << endl;
  cout << "Not road feature count = " << processor.m_notRoadCount << endl;

  PrintCont(processor.m_altitudeDiffs, "Altitude difference between start and end of features.",
            " feature(s) with altitude difference ", " meter(s)");
  WriteCSV(processor.m_altitudeDiffs, "altitude_difference.csv");

  PrintCont(processor.m_featureLength, "Feature length.", " feature(s) with length ", " meter(s)");
  WriteCSV(processor.m_featureLength, "feature_length.csv");

  PrintCont(processor.m_segLength, "Feature segment length.", " segment(s) with length ",
            " meter(s)");

  PrintCont(processor.m_featureWave, "Wave factor", " feature(s) with wave factor ", "");
  WriteCSV(processor.m_featureWave, "feature_wave.csv");

  PrintCont(processor.m_featureUp, "Feature go up in meters", " feature(s) go up ", " meter(s)");
  WriteCSV(processor.m_featureUp, "feature_up.csv");

  PrintCont(processor.m_featureDown, "Feature go down in meters", " feature(s) go down ", " meter(s)");
  WriteCSV(processor.m_featureDown, "feature_down.csv");

  PrintCont(processor.m_diffFromLinear, "Altitude deviation of internal feature points from linear model.",
            " internal feature point(s) deviate from linear model with ", " meter(s)");
  return 0;
}
コード例 #24
0
ファイル: pagemarker.cpp プロジェクト: nctan/quneiform
void PageMarker::processShortVerticalLines()
{
    SVLProcessor processor(image_data_);

    // count short lines
    processor.countSVLStep1();

    BigImage big_image(image_data_->hCPAGE);

    // obvious pictures search
    searchPictures(big_image.hCCOM);
    searchNegatives(big_image.hCCOM);
    linePass3();

    // снова подсчитываем короткие вертикальные линии
    processor.countSVLStep2();
    // и сравниваем с предыдущим результатом
    processor.filter();
}
コード例 #25
0
U_NAMESPACE_BEGIN

void GlyphPositioningTableHeader::process(const LEReferenceTo<GlyphPositioningTableHeader> &base, LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments, le_bool rightToLeft,
                                          LETag scriptTag, LETag languageTag,
                                          const LEReferenceTo<GlyphDefinitionTableHeader> &glyphDefinitionTableHeader, LEErrorCode &success,
                                          const LEFontInstance *fontInstance, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const
{
    if (LE_FAILURE(success)) {
        return;
    } 

    GlyphPositioningLookupProcessor processor(base, scriptTag, languageTag, featureMap, featureMapCount, featureOrder, success);
    if (LE_FAILURE(success)) {
        return;
    } 

    processor.process(glyphStorage, glyphPositionAdjustments, rightToLeft, glyphDefinitionTableHeader, fontInstance, success);

    glyphPositionAdjustments->applyCursiveAdjustments(glyphStorage, rightToLeft, fontInstance);
}
コード例 #26
0
ファイル: unicode.cpp プロジェクト: 315234/lyx-retina
void ucs4_to_multibytes(char_type ucs4, vector<char> & out,
	string const & encoding)
{
	static QThreadStorage<map<string, IconvProcessor> *> static_processors;
	if (!static_processors.hasLocalData())
		static_processors.setLocalData(new map<string, IconvProcessor>);
	map<string, IconvProcessor> & processors = *static_processors.localData();
	map<string, IconvProcessor>::iterator it = processors.find(encoding);
	if (it == processors.end()) {
		IconvProcessor processor(encoding.c_str(), ucs4_codeset);
		it = processors.insert(make_pair(encoding, processor)).first;
	}

	out.resize(4);
	int bytes = it->second.convert((char *)(&ucs4), 4, &out[0], 4);
	if (bytes > 0)
		out.resize(bytes);
	else
		out.clear();
}
コード例 #27
0
ファイル: utility.cpp プロジェクト: Dj-Corps/jstoolnpp
void saveOption(HWND nppHandle, StruOptions struOptions)
{
    tstring tsConfigFilePath = GetConfigFilePath(nppHandle);

    IniFileProcessor processor(tsConfigFilePath);
    IniFileProcessor::IniMap map;

    map[keyPutCR] = IniValue(struOptions.bPutCR ? string("1") : string("0"));
    map[keyChIndent] = IniValue(struOptions.chIndent == '\t' ? string("tab") : string("space"));
    char buffer[256];
    itoa(struOptions.nChPerInd, buffer, 10);
    map[keyChPerInd] = IniValue(string(buffer));
    map[keyNLBracket] = IniValue(struOptions.bNLBracket ? string("1") : string("0"));
    map[keyKeepTopComt] = IniValue(struOptions.bKeepTopComt ? string("1") : string("0"));
    map[keyIndentInEmpty] = IniValue(struOptions.bIndentInEmpty ? string("1") : string("0"));

    processor.SetMap(map);

    processor.Save();
}
コード例 #28
0
static std::string extractFromConfig(
        const std::string & config_path, const std::string & key, bool process_zk_includes, bool try_get = false)
{
    DB::ConfigProcessor processor(config_path, /* throw_on_bad_incl = */ false, /* log_to_console = */ false);
    bool has_zk_includes;
    DB::XMLDocumentPtr config_xml = processor.processConfig(&has_zk_includes);
    if (has_zk_includes && process_zk_includes)
    {
        DB::ConfigurationPtr bootstrap_configuration(new Poco::Util::XMLConfiguration(config_xml));
        zkutil::ZooKeeperPtr zookeeper = std::make_shared<zkutil::ZooKeeper>(
                *bootstrap_configuration, "zookeeper");
        zkutil::ZooKeeperNodeCache zk_node_cache([&] { return zookeeper; });
        config_xml = processor.processConfig(&has_zk_includes, &zk_node_cache);
    }
    DB::ConfigurationPtr configuration(new Poco::Util::XMLConfiguration(config_xml));
    // do not throw exception if not found
    if (try_get)
        return configuration->getString(key, "");
    return configuration->getString(key);
}
コード例 #29
0
int main(int argc, char* argv[])
{ 
    eva::stopwatch watch;
    eva::queue* queue_in = new eva::queue();
    eva::queue* queue_out = new eva::queue();

    test_source source( *queue_in );
    test_processor processor( *queue_in, *queue_out );
    test_sink sink( *queue_out );

    watch.start();
    sink.start();
    processor.start();
    source.start();

    sink.join();
    processor.join();
    source.join();

    std::cout << N << " events in " << watch.elapsed_ms() << " ms. " << (int)( N / watch.elapsed_s() ) << " per sec" << std::endl;
}
コード例 #30
0
U_NAMESPACE_BEGIN

le_int32 GlyphSubstitutionTableHeader::process(const LEReferenceTo<GlyphSubstitutionTableHeader> &base,
                                               LEGlyphStorage &glyphStorage,
                                               le_bool rightToLeft,
                                               LETag scriptTag,
                                               LETag languageTag,
                                               const LEReferenceTo<GlyphDefinitionTableHeader> &glyphDefinitionTableHeader,
                                               const LEGlyphFilter *filter,
                                               const FeatureMap *featureMap,
                                               le_int32 featureMapCount,
                                               le_bool featureOrder,
                                               LEErrorCode &success) const
{
    if (LE_FAILURE(success)) {
        return 0;
    }

    GlyphSubstitutionLookupProcessor processor(base, scriptTag, languageTag, filter, featureMap, featureMapCount, featureOrder, success);
    return processor.process(glyphStorage, NULL, rightToLeft, glyphDefinitionTableHeader, NULL, success);
}