本文整理汇总了C++中Converter类的典型用法代码示例。如果您正苦于以下问题:C++ Converter类的具体用法?C++ Converter怎么用?C++ Converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Converter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fetch_master_status
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;
}
示例2: ss
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;
}
示例3: profileIntegerConverter
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 );
}
示例4: commit
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){
}
});
示例5: apply_markers_multi
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);
}
}
}
}
示例6: Converter
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;
}
示例7: main
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();
}
示例8: main
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");
}
示例9: fetch_master_status
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;
}
示例10: resultValues
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;
}
示例11: fetch_binlogs_name_and_size
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;
}
示例12: main
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;
}
示例13: allocate
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;
}
示例14: printGraph
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";
}
}
}
示例15: conversionTest
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);
}
}