Esempio n. 1
0
int main()
{
    {
        std::ios ios(0);
        ios.register_callback(f1, 4);
        ios.register_callback(f2, 5);
        ios.register_callback(f3, 6);
        std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
        assert(l.name() == std::string("C"));
        assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
        assert(f1_called);
        assert(f2_called);
        assert(f3_called);
    }
    f1_called = false;
    f2_called = false;
    f3_called = false;
    {
        testbuf sb;
        std::ios ios(&sb);
        ios.register_callback(f1, 4);
        ios.register_callback(f2, 5);
        ios.register_callback(f3, 6);
        std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
        assert(l.name() == std::string("C"));
        assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
        assert(sb.getloc().name() == std::string(LOCALE_en_US_UTF_8));
        assert(f1_called);
        assert(f2_called);
        assert(f3_called);
    }
}
Esempio n. 2
0
int main()
{
    const my_facet f(1);
    {
        std::ios ios(0);
        {
            bool v = false;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "0");
        }
        {
            bool v = true;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "1");
        }
    }
    {
        std::ios ios(0);
        boolalpha(ios);
        {
            bool v = false;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "false");
        }
        {
            bool v = true;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "true");
        }
    }
    {
        std::ios ios(0);
        boolalpha(ios);
        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
        {
            bool v = false;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "no");
        }
        {
            bool v = true;
            char str[50];
            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
            std::string ex(str, iter.base());
            assert(ex == "yes");
        }
    }
}
Esempio n. 3
0
static void dump_io_bitmap(void)
{
	int i, j;
	int numl = sizeof(current->tss.io_bitmap) >> 2;

	for (i = j = 0; j < numl; ++i)
	{
		printk("%4d [%3x]: ", 64*i, 64*i);
		printk("%s ", ios(current->tss.io_bitmap[j++]));
		if (j < numl)
			printk("%s", ios(current->tss.io_bitmap[j++]));
		printk("\n");
	}
}
Esempio n. 4
0
int main(int, char**)
{
    {
        std::ios ios(0);
        ios.clear();
        assert(ios.rdstate() == std::ios::badbit);
#ifndef TEST_HAS_NO_EXCEPTIONS
        try
        {
            ios.exceptions(std::ios::badbit);
            assert(false);
        }
        catch (...)
        {
        }
        try
        {
            ios.clear();
            assert(false);
        }
        catch (std::ios::failure&)
        {
            assert(ios.rdstate() == std::ios::badbit);
        }
        try
        {
            ios.clear(std::ios::eofbit);
            assert(false);
        }
        catch (std::ios::failure&)
        {
            assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
        }
#endif
    }
    {
        testbuf sb;
        std::ios ios(&sb);
        ios.clear();
        assert(ios.rdstate() == std::ios::goodbit);
        ios.exceptions(std::ios::badbit);
        ios.clear();
        assert(ios.rdstate() == std::ios::goodbit);
        ios.clear(std::ios::eofbit);
        assert(ios.rdstate() == std::ios::eofbit);
    }

  return 0;
}
Esempio n. 5
0
int main( int argc, char * const argv[] )
{
	// Write apple.com to ~/apple.com.html
	fli::fli_istream is( fli::loadURL( "http://apple.com" ) );
	fli::fli_ostream os( fli::writeFile( fli::getHomeDirectory() + "apple.com.html" ) );

	std::string line;
	while( ! is.eof() ) {
		std::getline( is, line );
		os << line << std::endl; // write it to a file
		std::cout << line << std::endl; // and also write it to stdout
	}

	// create an iostream and exercise it
	fli::fli_iostream ios( fli::readWriteFile( fli::getHomeDirectory() + "someio.txt" ) );
	for( int i = 0; i < 10; ++i ) {
		ios << i << " ";
	}
	ios.seekg( 0, std::ios::beg );
	for( int i = 0; i < 10; ++i ) {
		int anInt;
		ios >> anInt;
		std::cout << anInt;
		assert( i == anInt );
	}

    return 0;
}
Esempio n. 6
0
void test_neg_one() {
    const my_facet f(1);
    std::ios ios(0);
    T v = static_cast<T>(42);
    {
        const char str[] = "-1";
        std::ios_base::iostate err = ios.goodbit;
        input_iterator<const char*> iter =
            f.get(input_iterator<const char*>(str),
                  input_iterator<const char*>(str+sizeof(str)),
                  ios, err, v);
        assert(iter.base() == str+sizeof(str)-1);
        assert(err == ios.goodbit);
        assert(v == T(-1));
    }
    v = 42;
    {
        const char str[] = "-";
        std::ios_base::iostate err = ios.goodbit;
        input_iterator<const char*> iter =
            f.get(input_iterator<const char*>(str),
                  input_iterator<const char*>(str+sizeof(str)),
                  ios, err, v);
        assert(iter.base() == str+sizeof(str)-1);
        assert(err == ios.failbit);
        assert(v == 0);
    }
}
Esempio n. 7
0
int main()
{
    char str[200];
    output_iterator<char*> iter;
    tm t;
    t.tm_sec = 6;
    t.tm_min = 3;
    t.tm_hour = 13;
    t.tm_mday = 2;
    t.tm_mon = 4;
    t.tm_year = 109;
    t.tm_wday = 6;
    t.tm_yday = -1;
    t.tm_isdst = 1;
    std::ios ios(0);
    {
        const my_facet f(LOCALE_en_US_UTF_8, 1);
        std::string pat("Today is %A which is abreviated %a.");
        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
                     pat.data(), pat.data() + pat.size());
        std::string ex(str, iter.base());
        assert(ex == "Today is Saturday which is abreviated Sat.");
    }
    {
        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
        std::string pat("Today is %A which is abreviated %a.");
        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
                     pat.data(), pat.data() + pat.size());
        std::string ex(str, iter.base());
        assert((ex == "Today is Samedi which is abreviated Sam.")||
               (ex == "Today is samedi which is abreviated sam." ));
    }
}
Esempio n. 8
0
int main()
{
    const my_facet f(1);
    std::ios ios(0);
    {
        const char str[] = "0x0";
        std::ios_base::iostate err = ios.goodbit;
        void* p;
        input_iterator<const char*> iter =
            f.get(input_iterator<const char*>(str),
                  input_iterator<const char*>(str+sizeof(str)),
                  ios, err, p);
        assert(iter.base() == str+sizeof(str)-1);
        assert(err == ios.goodbit);
        assert(p == 0);
    }
    {
        const char str[] = "0x73";
        std::ios_base::iostate err = ios.goodbit;
        void* p;
        input_iterator<const char*> iter =
            f.get(input_iterator<const char*>(str),
                  input_iterator<const char*>(str+sizeof(str)),
                  ios, err, p);
        assert(iter.base() == str+sizeof(str)-1);
        assert(err == ios.goodbit);
        assert(p == (void*)0x73);
    }
}
Esempio n. 9
0
     int main() 
	{
	int num = 0;
	std::string str;
	std::ifstream ios("mass_tr.cpp");
	while(ios.good())
	{
		num++;
		std::getline(ios, str);
		if (str.length() == 0)
		{
			std::cout << "Empty string in " << num << std::endl;
		}
	}
      //   std::thread t[num_threads];
 
        //for (int i = 0; i < num_threads; ++i) 
//	{
  //           t[i] = std::thread(call_from_thread, i);
    //     }

//        std::cout << "Launched from the main\n";
 
 //       for (int i = 0; i < num_threads; ++i) 
//	{
  //           t[i].join();
    //     }
 
         return 0;
     }
Esempio n. 10
0
File: main.cpp Progetto: ATNoG/ODiMM
int main(int argc, char** argv)
{
	opmip::setup_crash_handler();

	try {
		size_t                       concurrency = boost::thread::hardware_concurrency();
		boost::asio::io_service      ios(concurrency);
		boost::asio::signal_set      sigs(ios, SIGINT, SIGTERM);

		sigs.async_wait(boost::bind(signal_handler, _1, drv, boost::ref(mag)));

		//start odimm code here

		boost::thread_group tg;
		for (size_t i = 1; i < concurrency; ++i)
			tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));

		ios.run();
		tg.join_all();

	} catch(opmip::exception& e) {
		std::cerr << e.what() << std::endl;
		return 1;

	} catch(std::exception& e) {
		std::cerr << "exception: " << e.what() << std::endl;
		return 1;
	}

	return 0;
}
NS_IMETHODIMP
nsAboutFeeds::NewChannel(nsIURI* uri, nsIChannel** result)
{

  nsresult rv;
  nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIChannel> channel;
  rv = ios->NewChannel(NS_LITERAL_CSTRING(FEEDS_PAGE_URI),
                       nsnull, nsnull, getter_AddRefs(channel));
  if (NS_FAILED(rv))
    return rv;

  channel->SetOriginalURI(uri);

  nsCOMPtr<nsIScriptSecurityManager> ssm =
    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIPrincipal> principal;
  rv = ssm->GetCodebasePrincipal(uri, getter_AddRefs(principal));
  if (NS_FAILED(rv))
    return rv;

  rv = channel->SetOwner(principal);
  if (NS_FAILED(rv))
    return rv;

  NS_ADDREF(*result = channel);
  return NS_OK;
}
Esempio n. 12
0
int main()
{
    {
        std::ios ios(0);
        assert(!ios.eof());
        ios.setstate(std::ios::eofbit);
        assert(ios.eof());
    }
    {
        testbuf sb;
        std::ios ios(&sb);
        assert(!ios.eof());
        ios.setstate(std::ios::eofbit);
        assert(ios.eof());
    }
}
Esempio n. 13
0
//*****************************************************************************
//*****************************************************************************
XBridge::XBridge()
    : m_timerIoWork(m_timerIo)
    , m_timerThread(boost::bind(&boost::asio::io_service::run, &m_timerIo))
    , m_timer(m_timerIo, boost::posix_time::seconds(TIMER_INTERVAL))
{
    try
    {
        // services and threas
        for (int i = 0; i < THREAD_COUNT; ++i)
        {
            IoServicePtr ios(new boost::asio::io_service);

            m_services.push_back(ios);
            m_works.push_back(boost::asio::io_service::work(*ios));

            m_threads.create_thread(boost::bind(&boost::asio::io_service::run, ios));
        }

        // listener
        boost::asio::ip::tcp::endpoint ep(boost::asio::ip::tcp::v4(), LISTEN_PORT);
        m_acceptor = std::shared_ptr<boost::asio::ip::tcp::acceptor>
                        (new boost::asio::ip::tcp::acceptor
                                (*m_services.front(), ep));

        LOG() << "xbridge service listen at port " << LISTEN_PORT;

        m_timer.async_wait(boost::bind(&XBridge::onTimer, this));

    }
    catch (std::exception & e)
    {
        ERR() << e.what();
        ERR() << __FUNCTION__;
    }
}
Esempio n. 14
0
int main()
{
    testbuf sb1;
    testbuf sb2;
    testios ios(&sb1);
    try
    {
        ios.setstate(std::ios::badbit);
        ios.exceptions(std::ios::badbit);
    }
    catch (...)
    {
    }
    ios.set_rdbuf(&sb2);
    assert(ios.rdbuf() == &sb2);
    try
    {
        ios.setstate(std::ios::badbit);
        ios.exceptions(std::ios::badbit);
    }
    catch (...)
    {
    }
    ios.set_rdbuf(0);
    assert(ios.rdbuf() == 0);
}
Esempio n. 15
0
int main()
{
    testbuf sb1;
    testbuf sb2;
    testios ios(&sb1);
#ifndef TEST_HAS_NO_EXCEPTIONS
    try
    {
        ios.setstate(std::ios::badbit);
        ios.exceptions(std::ios::badbit);
        assert(false);
    }
    catch (...)
    {
    }
#endif
    ios.set_rdbuf(&sb2);
    assert(ios.rdbuf() == &sb2);
#ifndef TEST_HAS_NO_EXCEPTIONS
    try
    {
        ios.setstate(std::ios::badbit);
        ios.exceptions(std::ios::badbit);
    }
    catch (...)
    {
    }
#endif
    ios.set_rdbuf(0);
    assert(ios.rdbuf() == 0);
}
Esempio n. 16
0
int main()
{
    std::ios ios(0);
    assert(static_cast<bool>(ios) == !ios.fail());
    ios.setstate(std::ios::failbit);
    assert(static_cast<bool>(ios) == !ios.fail());
}
Esempio n. 17
0
bool
WyciwygChannelParent::RecvInit(const IPC::URI& aURI)
{
  nsresult rv;

  nsCOMPtr<nsIURI> uri(aURI);

  nsCString uriSpec;
  uri->GetSpec(uriSpec);
  LOG(("WyciwygChannelParent RecvInit [this=%x uri=%s]\n",
       this, uriSpec.get()));

  nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
  if (NS_FAILED(rv))
    return SendCancelEarly(rv);

  nsCOMPtr<nsIChannel> chan;
  rv = NS_NewChannel(getter_AddRefs(chan), uri, ios);
  if (NS_FAILED(rv))
    return SendCancelEarly(rv);

  mChannel = do_QueryInterface(chan, &rv);
  if (NS_FAILED(rv))
    return SendCancelEarly(rv);

  return true;
}
/**
 * Main routine
 *
 * @param argc number of arguments
 * @param argv pointers to arguments
 *
 * @return error code
 */
int main(int argc, char** argv) {
	try {
		int thread_num=10;
		// read number of threads with io_services from command line, if provided
		if(argc > 1)
			thread_num=boost::lexical_cast<int>(argv[1]);
		ios_deque io_services;

		boost::thread_group thr_grp;
		// create threads for each io_service
		for (int i = 0; i < thread_num; ++i) {
			io_service_ptr ios(new ba::io_service);
			io_services.push_back(ios);
			// run io_service in their own thread
			thr_grp.create_thread(boost::bind(&ba::io_service::run, ios));
		}
		// create server
		server server(io_services);
		// wait until all thread will finished
		thr_grp.join_all();
	} catch (std::exception& e) {
		std::cerr << e.what() << std::endl;
	}


	return 0;
}
Esempio n. 19
0
int main()
{
    testbuf sb;
    std::ios ios(&sb);
    std::ios_base& r = std::showpos(ios);
    assert(&r == &ios);
    assert(ios.flags() & std::ios::showpos);
}
Esempio n. 20
0
int main()
{
    testbuf sb;
    std::ios ios(&sb);
    std::uppercase(ios);
    std::ios_base& r = std::nouppercase(ios);
    assert(&r == &ios);
    assert(!(ios.flags() & std::ios::uppercase));
}
Esempio n. 21
0
int main()
{
    testbuf sb;
    std::ios ios(&sb);
    std::skipws(ios);
    std::ios_base& r = std::noskipws(ios);
    assert(&r == &ios);
    assert(!(ios.flags() & std::ios::skipws));
}
Esempio n. 22
0
static PRBool
IsOffline()
{
    PRBool offline = PR_TRUE;
    nsCOMPtr<nsIIOService> ios(do_GetIOService());
    if (ios)
        ios->GetOffline(&offline);
    return offline;
}
Esempio n. 23
0
//*****************************************************************************
//*****************************************************************************
XBridge::XBridge()
    : m_timerIoWork(m_timerIo)
    , m_timerThread(boost::bind(&boost::asio::io_service::run, &m_timerIo))
    , m_timer(m_timerIo, boost::posix_time::seconds(TIMER_INTERVAL))
{
    try
    {
        // services and threas
        for (int i = 0; i < THREAD_COUNT; ++i)
        {
            IoServicePtr ios(new boost::asio::io_service);

            m_services.push_back(ios);
            m_works.push_back(boost::asio::io_service::work(*ios));

            m_threads.create_thread(boost::bind(&boost::asio::io_service::run, ios));
        }

        m_timer.async_wait(boost::bind(&XBridge::onTimer, this));

        // sessions
        XBridgeApp & app = XBridgeApp::instance();
        {
            Settings & s = settings();
            std::vector<std::string> wallets = s.exchangeWallets();
            for (std::vector<std::string>::iterator i = wallets.begin(); i != wallets.end(); ++i)
            {
                // std::string label   = s.get<std::string>(*i + ".Title");
                // std::string address = s.get<std::string>(*i + ".Address");
                std::string ip       = s.get<std::string>(*i + ".Ip");
                std::string port     = s.get<std::string>(*i + ".Port");
                std::string user     = s.get<std::string>(*i + ".Username");
                std::string passwd   = s.get<std::string>(*i + ".Password");
                std::string prefix   = s.get<std::string>(*i + ".AddressPrefix");
                boost::uint64_t COIN = s.get<boost::uint64_t>(*i + ".COIN", 0);

                if (ip.empty() || port.empty() ||
                    user.empty() || passwd.empty() ||
                    prefix.empty() || COIN == 0)
                {
                    LOG() << "read wallet " << *i << " with empty parameters>";
                    continue;
                }

                XBridgeSessionPtr session(new XBridgeSession(*i, ip, port, user, passwd, prefix, COIN));
                app.addSession(session);
                // session->requestAddressBook();
            }
        }
    }
    catch (std::exception & e)
    {
        ERR() << e.what();
        ERR() << __FUNCTION__;
    }
}
Esempio n. 24
0
int main(int, char**)
{
    testbuf sb;
    std::ios ios(&sb);
    std::ios_base& r = std::uppercase(ios);
    assert(&r == &ios);
    assert(ios.flags() & std::ios::uppercase);

  return 0;
}
Esempio n. 25
0
    virtual int ProcessMessage(int fd, char *data, int size) {

        TCPSocket *sk = ios()->FindTCPSocket(fd);
        BFContext *ctx = new BFContext;
        ctx->user_id = -1;
        ctx->user_salary = -1;
        ctx->user_age = -1;
        ctx->sid = 100;

        ios()->SetContextByFD(sk->fd(), ctx);
        BFReq *req = data + 4;
        int userid = req->user_id;

        BBReq1 *r1 = new BBReq1;
        r1->user_id = userid;
        BackendPool *pool = ios()->backendpool();
        TCPSocket *bb1 = pool->GetClient(0);
        bb1->AsyncSend();
        // if (ctx->state == S_INIT) {
        //     MyBackendRequest1 req1;
        // 	req1.field1 = 1;
        // 	req1.field2 = 2;
        // 	char *req1_buf = new char[req1.size()];
        // 	req1.Serialize(req1_buf);
        // 	TCPSocket *backend1 = ClientPool.GetClient(2); // or, just send throught udp
        // 	backend1->set_context(ctx);
        // 	backend1->AsyncSend(req1...);
        // 	MyBackendRequest2 req2;
        // 	//...
        // 	TCPSocket *backend2 = ClientPool.GetClient(4);
        // 	backend2->set_context(ctx);
        // 	backend2->AsyncSend(req2...);
        // 	ctx->state = S_ALL_BACKEND_REQ_SENT;

        // } else if (ctx->state == S_ALL_BACKEND_REQ_SENT) {

        // } else if (ctx->state == S_BACKEND_RSP1_RECVED) {
        // } else if (ctx->state == S_BACKEND_RSP2_RECVED) {
        // } else {
        // }

    };
Esempio n. 26
0
int main(int argc, char** argv) {

  //google::InitGoogleLogging(argv[0]);
  //FLAGS_stderrthreshold = 0;
  //FLAGS_colorlogtostderr = true;

  try {
    int thread_num = 4, port = 20003;
    std::string interface_address = "0.0.0.0";

    // Read thread count from command line, if provided
    if (argc > 1)
      thread_num = boost::lexical_cast<int>(argv[1]);

    // Read port number from command line, if provided
    if (argc > 2)
      port = boost::lexical_cast<int>(argv[2]);

    // Read local interfac¡¤e address from command line, if provided
    if (argc > 3)
      interface_address = argv[3];

    ios_deque io_services;
    // See http://stackoverflow.com/questions/13219296/why-should-i-use-io-servicework
    std::deque<ba::io_service::work> io_service_work;
    io_service_ptr accpet_service(new ba::io_service);
    io_service_work.push_back(ba::io_service::work(*accpet_service));

    boost::thread_group thr_grp;

    for (int i = 0; i < thread_num; ++i) {
      // Create io server object
      io_service_ptr ios(new ba::io_service);
      // Save this io server object ot deque
      io_services.push_back(ios);
      io_service_work.push_back(ba::io_service::work(*ios));
      thr_grp.create_thread(boost::bind(ThreadIoServiceRun, ios));
    }
    // -------------------------------------------------------------------------
    // Run Firewall Manager
    // -------------------------------------------------------------------------

    proxy::FakeServer::Ptr server = proxy::FakeServer::CreateFakeServer(
      io_services, *accpet_service, interface_address, port);
    server->Start();
    // Sleep at here
    accpet_service->run();
  }
  catch (std::exception& e) {
    std::cerr << e.what() << std::endl;
  }

  return 0;
}
Esempio n. 27
0
int main()
{
    std::ios ios(0);
    std::ios_base::iostate err;
    std::tm t;
    {
        const my_facet f(LOCALE_en_US_UTF_8, 1);
        const wchar_t in[] = L"13:14:15";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_hour == 13);
        assert(t.tm_min == 14);
        assert(t.tm_sec == 15);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
        const wchar_t in[] = L"13:14:15";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_hour == 13);
        assert(t.tm_min == 14);
        assert(t.tm_sec == 15);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
        const wchar_t in[] = L"13:14:15";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_hour == 13);
        assert(t.tm_min == 14);
        assert(t.tm_sec == 15);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
        const wchar_t in[] = L"13:14:15";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_hour == 13);
        assert(t.tm_min == 14);
        assert(t.tm_sec == 15);
        assert(err == std::ios_base::eofbit);
    }
}
Esempio n. 28
0
int main()
{
    std::ios ios(0);
    std::ios_base::iostate err;
    std::tm t;
    {
        const my_facet f("en_US", 1);
        const wchar_t in[] = L"06/10/2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f("fr_FR", 1);
        const wchar_t in[] = L"10.06.2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f("ru_RU", 1);
        const wchar_t in[] = L"10.06.2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f("zh_CN", 1);
        const wchar_t in[] = L"2009/06/10";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
}
Esempio n. 29
0
std::vector< std::shared_ptr<ImageOverSegmentation> > generateGeodesicKMeans( const BDetector & det, const list & ims, int approx_N ) {
	const int N = len(ims);
	std::vector<Image8u*> img(N);
	for( int i=0; i<N; i++ )
		img[i] = extract<Image8u*>( ims[i] );
	std::vector< std::shared_ptr<ImageOverSegmentation> > ios( N );
#pragma omp parallel for
	for( int i=0; i<N; i++ )
		ios[i] = geodesicKMeans( *img[i], det, approx_N, 2 );
	return ios;
}
Esempio n. 30
0
int main()
{
    std::ios ios(0);
    std::ios_base::iostate err;
    std::tm t;
    {
        const my_facet f(LOCALE_en_US_UTF_8, 1);
        const char in[] = "06/10/2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
        const char in[] = "10.06.2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
        const char in[] = "10.06.2009";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
    {
        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
        const char in[] = "2009/06/10";
        err = std::ios_base::goodbit;
        t = std::tm();
        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
        assert(t.tm_mon == 5);
        assert(t.tm_mday == 10);
        assert(t.tm_year == 109);
        assert(err == std::ios_base::eofbit);
    }
}