bool fetch_master_status(tcp::socket *socket, std::string *filename, unsigned long *position)
{
  boost::asio::streambuf server_messages;

  std::ostream command_request_stream(&server_messages);

  static boost::uint8_t com_query = COM_QUERY;
  Protocol_chunk<boost::uint8_t> prot_command(com_query);

  command_request_stream << prot_command
          << "SHOW MASTER STATUS";

  int size=server_messages.size();
  char command_packet_header[4];
  write_packet_header(command_packet_header, size, 0);

  // Send the request.
  boost::asio::write(*socket, boost::asio::buffer(command_packet_header, 4), boost::asio::transfer_at_least(4));
  boost::asio::write(*socket, server_messages, boost::asio::transfer_at_least(size));

  Result_set result_set(socket);

  Converter conv;
  BOOST_FOREACH(Row_of_fields row, result_set)
  {
    *filename= "";
    conv.to(*filename, row[0]);
    long pos;
    conv.to(pos, row[1]);
    *position= (unsigned long)pos;
  }
void Command::execute() const {
std::stringstream ss(m_command);
std::string help;
ss >> help;
Converter* first = ConverterFactory::_instance()->create(help);
if(!first)
{
std::cout<< help <<" is no Converter!\n";
return;
}
Converter* temp = first;
ss >> help;
Converter* temp2;
while(!isdigit(help.at(0)))
{
temp2 = ConverterFactory::_instance()->create(help);
if(!temp2)
{
std::cout<< help <<" is no Converter!\n";
return;
}
temp->link(temp2);
temp = temp2;
if(!(ss >> help))
{
std::cout<<"You need a conversionvalue!!!!\n";
return;
}
}
std::cout<<"Using converter: "<< first->toString() <<" converted: " <<std::stod(help)<< " to: "<< first->convert(std::stod(help)) <<std::endl;
}
Example #3
0
File: Profile.cpp Project: GHF/Raxo
void profileIntegerConverter( Format format, const integer32 *source, void *destination, int count )
{
    printf( "   truecolor -> %s", getFormatString(format) );

    Converter * converter = requestConverter( Format::XRGB8888, format );

    if ( !converter )
    {
        printf( "\n     failed: null converter\n" );
        exit(1);
    }

    double startTime = timer.time();

    double time = 0.0;

    int iterations = 0;

    while ( time < duration )
    {
        converter->convert( source, destination, count );
        time = timer.time() - startTime;
        iterations ++;
    }

    printf( " = %f ms\n", (double) time / iterations * 1000 );
}
Example #4
0
void ClusterRepository::commit(std::vector<Pattern> pattern_list, double threshold){
	Converter<Pattern> converter;

	std::for_each(pattern_list.begin(), pattern_list.end(), [&](Pattern pattern){
		try{
			std::vector<double> origin(pattern.size());
		
			std::fill(origin.begin(), origin.end(), (double)1);
			double feature = Math::cosSimilarity(origin, converter.convert(pattern));
	
			std::vector<Row> result;
	
			//しきい値以下のクラスタがあるか
			result = this->sqlite.execute(this->getSelectClusterQuery(feature,threshold));
	
			if(result.empty()){
				//なかったら新しく追加する
				this->sqlite.execute(this->getAddClusterQuery(feature));
			}else{
				int id;
				std::istringstream converter;
				converter.str(result[0]["label"]);
				converter >> id;
				//重要度を上げて、同じラベルで追加する
				this->sqlite.execute(this->getRaisePriorityQuery(result));
				this->sqlite.execute(this->getAddClusterQuery(feature,id));
			}
		}catch(std::exception e){
		}
	});
Example #5
0
void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, markers_symbolizer const& sym)
{
    std::size_t geom_count = feature.paths().size();
    if (geom_count == 1)
    {
        converter.apply(feature.paths()[0]);
    }
    else if (geom_count > 1)
    {
        marker_multi_policy_enum multi_policy = get<marker_multi_policy_enum>(sym, keys::markers_multipolicy, feature, vars, MARKER_EACH_MULTI);
        marker_placement_enum placement = get<marker_placement_enum>(sym, keys::markers_placement_type, feature, vars, MARKER_POINT_PLACEMENT);

        if (placement == MARKER_POINT_PLACEMENT &&
            multi_policy == MARKER_WHOLE_MULTI)
        {
            double x, y;
            if (label::centroid_geoms(feature.paths().begin(), feature.paths().end(), x, y))
            {
                geometry_type pt(geometry_type::types::Point);
                pt.move_to(x, y);
                // unset any clipping since we're now dealing with a point
                converter.template unset<clip_poly_tag>();
                converter.apply(pt);
            }
        }
        else if ((placement == MARKER_POINT_PLACEMENT || placement == MARKER_INTERIOR_PLACEMENT) &&
                 multi_policy == MARKER_LARGEST_MULTI)
        {
            // Only apply to path with largest envelope area
            // TODO: consider using true area for polygon types
            double maxarea = 0;
            geometry_type const* largest = 0;
            for (geometry_type const& geom : feature.paths())
            {
                const box2d<double>& env = geom.envelope();
                double area = env.width() * env.height();
                if (area > maxarea)
                {
                    maxarea = area;
                    largest = &geom;
                }
            }
            if (largest)
            {
                converter.apply(*largest);
            }
        }
        else
        {
            if (multi_policy != MARKER_EACH_MULTI && placement != MARKER_POINT_PLACEMENT)
            {
                MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'";
            }
            for (geometry_type const& path : feature.paths())
            {
                converter.apply(path);
            }
        }
    }
}
Example #6
0
void MainWindow::OnConverter(wxCommandEvent& event)
{
	int id = event.GetId();
	wxTreeItemId itemId = tree->GetSelection();
	NodeTree *itemData = itemId.IsOk() ? (NodeTree *) tree->GetItemData(itemId):NULL;
	Converter* conver;
	if(id == ID_CONVERMESH)
	{
		
		conver = new Converter(this,ID_CONVERMESH,wxT("CPP CODE"));
		conver->OnlyRead(itemData->pointer.meshpart);
		conver->ShowModal();
		wxLogStatus(wxT("See cpp code"));
		
	}
	if(id == ID_CONVER)
	{
		
		conver = new Converter(this,ID_CONVER,wxT("Converter .stl"));
		conver->ShowModal();
		wxLogStatus(wxT("Converter"));
	}

	delete conver;
}
Example #7
0
int main() {

	Converter convert;

	std::vector< int > intV( 8 );
	std::vector< char > charV;

	int intA[ 8 ] = { 0, 1, 0, 0, 0, 0, 0, 1 };

	for( int i = 0; i < 8; i++ ) {
		intV[ i ] = intA[ i ];
		std::cout << intV[ i ];
	}

	std::cout << std::endl;

	convert.binaryToText( intV, charV );

	for( int i = 0; i < charV.size(); i++ ) {
		std::cout << charV[ i ] << std::endl;
	}

	std::cout << std::endl;

	Converter::printAllASCII();
}
Example #8
0
int main(int argc, char* argv[])
{

  if (argc < 7) {
    usage(argv[0]);
  }

  std::string h5file = argv[1];
  std::string immfile = argv[2];
  std::string dataset = argv[3];
  unsigned int buffer_count = atoi(argv[4]);
  unsigned int frames = atoi(argv[5]);
  unsigned int frames_per_buffer = atoi(argv[6]);

  BufferPool *pool = new BufferPool(buffer_count, 1024, 1024, frames_per_buffer);
  Queue<FrameBuffer*> *readconvert = new Queue<FrameBuffer*>();
  Queue<FrameBuffer*> *convertwrite = new Queue<FrameBuffer*>();

  Reader *reader = new Reader(h5file, dataset, 1024, 1024, frames, frames_per_buffer, pool, readconvert);
  Converter *converter = new Converter(readconvert, convertwrite, frames);
  Writer *writer = new Writer(immfile, convertwrite, pool, frames);

  writer->start();
  converter->start();
  reader->start();


  reader->join();
  converter->join();
  writer->join();

  printf("Done\n");
}
bool fetch_master_status(tcp::socket *socket, std::string *filename, unsigned long *position)
{
  asio::streambuf server_messages;

  std::ostream command_request_stream(&server_messages);

  Protocol_chunk<uint8_t> prot_command(COM_QUERY);

  command_request_stream << prot_command
          << "SHOW MASTER STATUS";

  int size=server_messages.size();
  char command_packet_header[4];
  write_packet_header(command_packet_header, size, 0);

  // Send the request.
  asio::write(*socket, asio::buffer(command_packet_header, 4), asio::transfer_at_least(4));
  asio::write(*socket, server_messages, asio::transfer_at_least(size));

  Result_set result_set(socket);

  Converter conv;
  for(Result_set::iterator it = result_set.begin();
          it != result_set.end();
          it++)
  {
    Row_of_fields row(*it);
    *filename= "";
    conv.to(*filename, row[0]);
    long pos;
    conv.to(pos, row[1]);
    *position= (unsigned long)pos;
  }
  return false;
}
Example #10
0
casa::Vector<double> ConverterChannel::convert( const casa::Vector<double>& oldValues,
        casa::SpectralCoordinate spectralCoordinate ) {
    std::vector<double> resultValues( oldValues.size());
    for ( int i = 0; i < static_cast<int>(resultValues.size()); i++ ) {
        double result;
        bool correct = spectralCoordinate.toWorld( result, oldValues[i]);
        if ( correct ) {
            casa::Vector<casa::String> worldUnitsVector = spectralCoordinate.worldAxisUnits();
            QString worldUnit(worldUnitsVector[0].c_str());
            if ( worldUnit == newUnits ) {
                resultValues[i] = result;
            }
            else {
                qDebug() << "worldUnit="<<worldUnit<<" newUnit="<<newUnits;
                Converter* helper = Converter::getConverter( worldUnit, newUnits);
                if ( helper != nullptr ){
                    resultValues[i] = helper->convert( result, spectralCoordinate );
                    delete helper;
                }
                else {
                    qDebug() << "Could not convert from "<<worldUnit<<" to "<<newUnits;
                }
            }
        }
        else {
            qDebug() << "Could not convert channel="<<oldValues[i];
        }
    }
    return resultValues;
}
bool fetch_binlogs_name_and_size(tcp::socket *socket, std::map<std::string, unsigned long> &binlog_map)
{
  asio::streambuf server_messages;

  std::ostream command_request_stream(&server_messages);

  Protocol_chunk<uint8_t> prot_command(COM_QUERY);

  command_request_stream << prot_command
          << "SHOW BINARY LOGS";

  int size=server_messages.size();
  char command_packet_header[4];
  write_packet_header(command_packet_header, size, 0);

  // Send the request.
  asio::write(*socket, asio::buffer(command_packet_header, 4), asio::transfer_at_least(4));
  asio::write(*socket, server_messages, asio::transfer_at_least(size));

  Result_set result_set(socket);

  Converter conv;
  for(Result_set::iterator it = result_set.begin();
          it != result_set.end();
          it++)
  {
    Row_of_fields row(*it);
    std::string filename;
    long position;
    conv.to(filename, row[0]);
    conv.to(position, row[1]);
    binlog_map.insert(std::make_pair<std::string, unsigned long>(filename, (unsigned long)position));
  }
  return false;
}
Example #12
0
int main(int argc, char *argv[])
{
    QString outputFileName;

    if (argc < 2)
    {
        printf("xbm-epd version " APPVERSION " (C) kimmoli 2014\n\n");
        printf("xbm-epd inputfile {outputfile}\n");
        return 0;
    }

    if (argc == 3)
    {
        outputFileName = QString(argv[2]);
    }
    else
    {
        outputFileName = QString("%1.xbm").arg(QString(argv[1]).split('.').at(0));
    }

    printf("Writing output to %s\n", qPrintable(outputFileName));

    Converter* converter = new(Converter);

    converter->convert(QString(argv[1]), outputFileName);

    delete converter;
    return 1;
}
Example #13
0
  Converter* Converter::allocate(STATE, Object* self) {
    Class* cls = Encoding::converter_class(state);
    Converter* c = state->new_object<Converter>(cls);

    c->klass(state, as<Class>(self));

    return c;
  }
 Unit unit(const QString& unit)
 {
     if (!unit.isEmpty() && unit[0].isDigit()) {
         // PORT?
         return converter.unit(static_cast<UnitId>(unit.toInt()));
     }
     // Support < 4.4 config values
     return converter.unit(unit);
 }
Example #15
0
void Graph::printGraph() const {
    Converter c;
    for (auto &v : vertexes) {
        cout << "\t" << c.convert(v.getValue()) << ":\n";
        for (auto &succ : v.getSuccessors()) {
            cout << "\t\t" << c.convert(succ.first->getValue()) << ": " << succ.second << "\n";
        }
    }
}
Example #16
0
        void conversionTest() {
            string randomSequence, processedSequence;
            for (int i = 0; i < 100; ++i) {
                randomSequence    = generateRandomSequence(Options::getInstance().getBasePairsPerOligonucleotide());
                processedSequence = c.convert(c.convert(randomSequence));

                CPPUNIT_ASSERT_MESSAGE("Converter changed sequence during conversion!",
                    randomSequence == processedSequence);
            }
        }
Example #17
0
 Verifier::Verifier(const std::string& raw_public_key)
 {
   Converter conv;
   public_key_t public_key = conv.read_public_key(raw_public_key);
   m_modulus = public_key.modulus;
   m_generator = public_key.generator;
   m_gen_power = public_key.gen_power;
   m_r_length = m_modulus.size() * sizeof(number_t::part_type);
   m_s_length = m_modulus.size() * sizeof(number_t::part_type);
   m_signature_length = m_r_length + m_s_length;
 }
Example #18
0
 Decrypter::Decrypter(const std::string& raw_private_key)
 {
   Converter conv;
   private_key_t private_key = conv.read_private_key(raw_private_key);
   m_modulus = private_key.modulus;
   m_exponent = private_key.exponent;
   m_plain_length = LongIntConverter::byte_size(m_modulus) - 1;
   m_key_part_length = LongIntConverter::byte_size(m_modulus);
   m_cipher_part_length = LongIntConverter::byte_size(m_modulus);
   m_cipher_length = m_key_part_length + m_cipher_part_length;
 }
Example #19
0
	KernelTable::KernelTable(const Converter& converter) :
		converter(converter),
	    declaration(c_ast::CCodeFragment::createNew(
			converter.getFragmentManager(),
			converter.getCNodeManager()->create<c_ast::OpaqueCode>("extern irt_opencl_kernel_implementation *" KERNEL_TABLE_NAME "[];"))) {
		addDependency(declaration);
		runtime::ContextHandlingFragmentPtr ctx = runtime::ContextHandlingFragment::get(converter);
		// add the dataReq. table as well
		ctx->addInitExpression("\tirt_opencl_init_context(%s, " KERNEL_TABLE_NAME ");\n");
		ctx->addCleanupExpression("\tirt_opencl_cleanup_context(%s);\n");
	}
Example #20
0
  Converter* Converter::allocate(STATE, Object* self) {
    Class* cls = Encoding::converter_class(state);
    Converter* c = state->new_object<Converter>(cls);

    c->klass(state, as<Class>(self));

    c->set_converter(NULL);

    state->memory()->needs_finalization(c, (FinalizerFunction)&Converter::finalize);

    return c;
  }
 void DynamicsReader::parseDynamics( std::vector<api::MarkData>& outMarks ) const
 {
     const auto dynamicType = myDynamic.getValue().getValue();
     Converter converter;
     const auto markType = converter.convertDynamic( dynamicType );
     auto markData = api::MarkData{};
     markData.markType = markType;
     markData.tickTimePosition = myCursor.tickTimePosition;
     markData.name = myDynamic.getValue().getValueString();
     markData.positionData = impl::getPositionData( *myDynamic.getAttributes() );
     outMarks.emplace_back( std::move( markData ) );
 }
Example #22
0
string convertData(string data){
	Converter converter;
	SocketData* socketData = converter.toSocketData(data);
#ifdef DEBUG
//	if(socketData != NULL) socketData->print();
#endif
	string sendData = Converter::toSendData(socketData);
#ifdef DEBUG
	printf("sendData : %s\n", sendData.c_str());
#endif
	return sendData;
}
Example #23
0
	void EnumTypes::installOn(Converter& converter) const {

		// registers type handler
		converter.getTypeManager().addTypeHandler(EnumTypeHandler);

		// register additional operators
		converter.getFunctionManager().getOperatorConverterTable().insertAll(getEnumTypeOperatorTable(converter.getNodeManager()));

		// register additional StatementConverter
		converter.getStmtConverter().addStmtHandler(EnumLiteralHandler);

	}
Example #24
0
int main(int argc, char **argv)
{
	if (argc == 2)
	{
		std::cout.precision(1);
		Converter converter;
		std::string literal = std::string(argv[1]);
		converter.printResults(literal);
	}
	else
		std::cout << std::endl;
}
Example #25
0
CMarkdown::HSTR CMarkdown::_HSTR::Convert(const Converter &converter)
{
	HSTR H = this;
	size_t s = SysStringByteLen(B);
	if (size_t d = converter.Convert(A, s, 0, 0))
	{
		H = (HSTR)SysAllocStringByteLen(0, d);
		converter.Convert(A, s, H->A, d);
		SysFreeString(B);
	}
	return H;
}
Example #26
0
 Signer::Signer(const std::string& raw_private_key)
 {
   Converter conv;
   private_key_t private_key = conv.read_private_key(raw_private_key);
   m_modulus = private_key.modulus;
   m_generator = private_key.generator;
   m_phi_modulus = m_modulus - ONE;
   m_exponent = private_key.exponent;
   m_k_distribution = UniformLongIntDistribution(ONE, m_phi_modulus - ONE);
   m_r_length = m_modulus.size() * sizeof(number_t::part_type);
   m_s_length = m_modulus.size() * sizeof(number_t::part_type);
   m_signature_length = m_r_length + m_s_length;
 }
Example #27
0
Row ClusterRepository::search(Pattern pattern, double threshold){
	std::vector<double> origin(pattern.size());
	Converter<Pattern> converter;

	std::fill(origin.begin(), origin.end(), (double)1);
	double feature = Math::cosSimilarity(origin, converter.convert(pattern));

	//しきい値以下のクラスタ
	std::vector<Row> result = this->sqlite.execute(this->getSelectClusterQuery(feature, threshold));
	
	if(result.empty()) throw std::exception("not found");

	return result[0];
}
Example #28
0
/**
 * Test case for Converter class
 * @param none 
 */
void testConverter(Converter &conv, const string &sentence) {
    std::cout << "---   Testing Converter -----\n";
    try {
        conv.setString (sentence);
        vector<NLP::Word> myParsedWords = conv.getWords();

        for(NLP::Word wd: myParsedWords)
            cout << wd << " : " << wd.getRawtypes() << endl;

    } catch (const char* e) {
        cout << "something went wrong : " << "Converter" << endl;
    }
    cout << "-------- End of Converter test case -----\n\n";
}
Example #29
0
int main(int argc, char const *argv[]) {
  Converter converter;
  {
    using namespace std;
      // get input from screen
      string input;
      cout << "Please enter the number to convert to words :" << endl << "Input : ";
      cin >> input;

      string output=converter.convert(input);
      cout << " The result is : "<< output << endl;
  }

  return 0;
}
 void ArticulationsFunctions::parseArticulations( std::vector<api::MarkData>& outMarks ) const
 {
     for( const auto& articulation : myArticulations )
     {
         const auto articulationType = articulation->getChoice();
         Converter converter;
         const auto markType = converter.convertArticulation( articulationType );
         auto markData = api::MarkData{};
         markData.markType = markType;
         markData.tickTimePosition = myCursor.tickTimePosition;
         
         parseArticulation( *articulation, markData );
         outMarks.emplace_back( std::move( markData ) );
     }
 }