【Poco】Poco::DynamicAny中的例子

來源:互聯網
上載者:User
#include "../tmain.hpp"void test_DynamicAnyInt(){Poco::Int32 src = 32;Poco::DynamicAny a1 = src;assert (a1.type() == typeid(Poco::Int32));std::string s1;Poco::Int8 s2;Poco::Int16 s3;Poco::Int32 s4;Poco::Int64 s5;Poco::UInt8 s6;Poco::UInt16 s7;Poco::UInt32 s8;Poco::UInt64 s9;float s10;double s11;bool s12;char s13;long s14;unsigned long s15;a1.convert(s1);a1.convert(s2);a1.convert(s3);a1.convert(s4);a1.convert(s5);a1.convert(s6);a1.convert(s7);a1.convert(s8);a1.convert(s9);a1.convert(s10);a1.convert(s11);a1.convert(s12);a1.convert(s13);a1.convert(s14);a1.convert(s15);assert (s1 == "32");assert (s2 == 32);assert (s3 == 32);assert (s4 == 32);assert (s5 == 32);assert (s6 == 32);assert (s7 == 32);assert (s8 == 32);assert (s9 == 32);assert (s10 == 32.0f);assert (s11 == 32.0);assert (s12);assert (s13 == ' ');assert (s14 == 32);assert (s15 == 32);Poco::DynamicAny a2(a1);std::string t2;a2.convert(t2);assert (s1 == t2);Poco::Int32 value = a1.extract<Poco::Int32>();assert (value == 32);try{Poco::Int16 value2; value2 = a1.extract<Poco::Int16>();}catch (Poco::BadCastException&){}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.