コード例 #1
0
ファイル: bundle.hpp プロジェクト: diegofps/wup
std::ostream & operator<<(std::ostream & o, const wup::Bundle<T> & bundle)
{
    for (uint i=0; i<bundle.numRows(); ++i)
    {
        o << bundle(i, 0);

        for (uint j=1; j<bundle.numCols(); ++j)
            o << "," << bundle(i, j);

        o << "\n";
    }

    return o;
}
コード例 #2
0
ファイル: Region.cpp プロジェクト: breznak/nupic.core
void Region::save(std::ostream &f) const {
  f << "{\n";
  f << "name: " << name_ << "\n";
  f << "nodeType: " << type_ << "\n";
  f << "phases: [ " << phases_.size() << "\n";
  for (const auto &phases_phase : phases_) {
      f << phases_phase << " ";
  }
  f << "]\n";
  f << "outputs: [\n";
  for(auto out: outputs_) {
    f << out.first << " " << out.second->getDimensions() << "\n";
  }
  f << "]\n";
  f << "inputs: [\n";
  for(auto in: inputs_) {
    f << in.first << " " << in.second->getDimensions() << "\n";
  }
  f << "]\n";
  f << "RegionImpl:\n";
  // Now serialize the RegionImpl plugin.
  BundleIO bundle(&f);
  impl_->serialize(bundle);

  f << "}\n";
}
コード例 #3
0
ファイル: GAFAsset.cpp プロジェクト: w1ng/Quick-3.3
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate /*= NULL*/)
{
    GAFLoader* loader = new GAFLoader();

    m_gafFileName = zipFilePath;
    m_gafFileName.append("/" + entryFile);
    std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath);

    cocos2d::ZipFile bundle(fullfilePath);
    ssize_t sz = 0;
    unsigned char* gafData = bundle.getFileData(entryFile, &sz);

    bool isLoaded = false;

    if (gafData && sz)
    {
        isLoaded = loader->loadData(gafData, sz, this);
    }
    if (isLoaded)
    {
        loadTextures(entryFile, delegate, &bundle);
    }

    delete loader;

    return isLoaded;
}
コード例 #4
0
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate, GAFLoader* customLoader /*= nullptr*/)
{
    m_gafFileName = zipFilePath;
    m_gafFileName.append("/" + entryFile);
    std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath);

    cocos2d::ZipFile bundle(fullfilePath);
    ssize_t sz = 0;
    unsigned char* gafData = bundle.getFileData(entryFile, &sz);

    bool isLoaded = false;

    if (gafData && sz)
    {
        if (customLoader)
        {
            customLoader->loadData(gafData, sz, this);
        }
        else
        {
            GAFLoader* loader = new GAFLoader();
            isLoaded = loader->loadData(gafData, sz, this);
            delete loader;
        }
    }
    if (isLoaded && m_state == State::Normal)
    {
        m_textureManager = new GAFAssetTextureManager();
        GAFShaderManager::Initialize();
        loadTextures(entryFile, delegate, &bundle);
    }

    return isLoaded;
}
コード例 #5
0
ファイル: step4.c プロジェクト: jimjag/libdill
int main(int argc, char *argv[]) {

    int port = 5555;
    if(argc > 1)
        port = atoi(argv[1]);

    struct ipaddr addr;
    int rc = ipaddr_local(&addr, NULL, port, 0);
    assert(rc == 0);
    int ls = tcp_listen(&addr, 10);
    if(ls < 0) {
        perror("Can't open listening socket");
        return 1;
    }

    int b = bundle();
    assert(b >= 0);

    int i;
    for(i = 0; i != 3; i++) {
        int s = tcp_accept(ls, NULL, -1);
        assert(s >= 0);
        s = suffix_attach(s, "\r\n", 2);
        assert(s >= 0);
        rc = bundle_go(b, dialogue(s));
        assert(rc == 0);
    }

    rc = hclose(b);
    assert(rc == 0);
    rc = hclose(ls);
    assert(rc == 0);

    return 0; 
}
コード例 #6
0
ファイル: Network.cpp プロジェクト: Asele/nupic.core
Region* Network::addRegionFromBundle(const std::string& name, 
                                     const std::string& nodeType, 
                                     const Dimensions& dimensions, 
                                     const std::string& bundlePath, 
                                     const std::string& label)
{
  if (regions_.contains(name))
    NTA_THROW << "Invalid saved network: two or more instance of region '" << name << "'";

  if (! Path::exists(bundlePath))
    NTA_THROW << "addRegionFromBundle -- bundle '" << bundlePath 
              << " does not exist";
  
  BundleIO bundle(bundlePath, label, name, /* isInput: */ true );
  Region *r = new Region(name, nodeType, dimensions, bundle, this);
  regions_.add(name, r);
  initialized_ = false;
    
  // In the normal use case (deserializing a network from a bundle)
  // this default phase will immediately be overridden with the
  // saved phases. Having it here makes it possible for user code
  // to safely call addRegionFromBundle directly.
  setDefaultPhase_(r);
  return r;
}
コード例 #7
0
ファイル: main.cpp プロジェクト: ACGaming/MultiMC5
bool unpackBundle(int argc, char** argv)
{
	MacBundle bundle(FileUtils::tempPath(),AppInfo::name());
	std::string currentExePath = ProcessUtils::currentProcessPath();

	if (currentExePath.find(bundle.bundlePath()) != std::string::npos)
	{
		// already running from a bundle
		return false;
	}
	LOG(Info,"Creating bundle " + bundle.bundlePath());

	// create a Mac app bundle
	std::string plistContent(reinterpret_cast<const char*>(Info_plist),Info_plist_len);
	std::string iconContent(reinterpret_cast<const char*>(mac_icns),mac_icns_len);
	bundle.create(plistContent,iconContent,ProcessUtils::currentProcessPath());

	std::list<std::string> args;
	for (int i = 1; i < argc; i++)
	{
		args.push_back(argv[i]);
	}
	ProcessUtils::runSync(bundle.executablePath(),args);
	return true;
}
コード例 #8
0
ファイル: berryBundleLoader.cpp プロジェクト: AGrafmint/MITK
Bundle::Pointer
BundleLoader::CreateBundle(const Poco::Path& path)
{
  BundleDirectory::Pointer bundleStorage(new BundleDirectory(path));
  Bundle::Pointer bundle(new Bundle(*this, bundleStorage));

  if (bundle->GetState() == IBundle::BUNDLE_INSTALLED &&
      installedCTKPlugins.contains(QString::fromStdString(bundle->GetSymbolicName())))
  {
    BERRY_WARN << "Ignoring legacy BlueBerry bundle " << bundle->GetSymbolicName()
               << " because a CTK plug-in with the same name already exists.";
    return Bundle::Pointer(0);
  }

  if (bundle->GetState() == IBundle::BUNDLE_INSTALLED &&
      bundle->IsSystemBundle()) {
    bundle = new SystemBundle(*this, bundleStorage);
    m_SystemBundle = bundle;
  }

  //BundleEvent event(bundle, BundleEvent::EV_BUNDLE_INSTALLED);
  //m_BundleEvents.bundleInstalled(this, event);

  return bundle;
}
コード例 #9
0
ファイル: NetWork.cpp プロジェクト: minuowa/Monos
void NetWork::prosess()
{
	mLock.lock();
	uArray<Packet*> pktArray;
	for (int i = 0; i < mDataArray.size(); ++i)
	{
		Packet* pkt = mDataArray[i];
		pktArray.push_back(pkt);
	}
	mDataArray.clear();
	mLock.unlock();

	for (int i = 0; i < pktArray.size(); ++i)
	{
		Packet* pkt = pktArray[i];
		BundleReceiver bundle(pkt->con, pkt->data, pkt->len);
		if (bundle.valid())
		{
			PKG* pkg = bundle.get();
			NetWork::MsgArgs arg;
			arg.pkg = pkg;
			arg.connect = pkt->con;
			App::Net.onMessage.trigger(&arg);
		}
	}
	pktArray.destroy();
}
コード例 #10
0
ファイル: engine.hpp プロジェクト: Halfnhav4/methcla
        Engine(const Options& options={})
            : m_nodeIds(1, 1023) // FIXME: Get max number of nodes from options
            , m_requestId(kMethcla_Notification+1)
            , m_packets(8192)
        {
            OSCPP::Client::DynamicPacket bundle(8192);
            bundle.openBundle(1);
            for (auto option : options) {
                option->put(bundle);
            }
            bundle.closeBundle();
            const Methcla_OSCPacket packet = { .data = bundle.data(), .size = bundle.size() };
            detail::checkReturnCode(methcla_engine_new(handlePacket, this, &packet, &m_engine));
        }
        ~Engine()
        {
            methcla_engine_free(m_engine);
        }

        operator const Methcla_Engine* () const
        {
            return m_engine;
        }

        operator Methcla_Engine* ()
        {
            return m_engine;
        }

        void start()
        {
            detail::checkReturnCode(methcla_engine_start(m_engine));
        }
コード例 #11
0
Thread* ThreadManager::createThread( const stringptr& name ) {
	auto it = std::find( mThreads.begin(), mThreads.end(), name );
	assert( it == mThreads.end() );
	Thread* t = new Thread();
	ThreadNameBundle bundle( name, t );
	mThreads.push_back( bundle );
	return t;
}
コード例 #12
0
void
PipelineSimpleBundleExample::draw(IGrafPort& port)
{
        IGPolygon2D polygon(IGRect2D(20,20,220,180));
        IGrafBundle bundle(kDefaultFillColor, kDefaultFrameColor);

        port.draw(polygon, bundle);
}
コード例 #13
0
bool WorkbenchPlugin::IsBundleLoadedForExecutableExtension(
    IConfigurationElement::Pointer element, const std::string& extensionName)
{
  IBundle::Pointer bundle(WorkbenchPlugin::GetBundleForExecutableExtension(element, extensionName));

  if (bundle.IsNull())
    return true;
  return bundle->GetState() == IBundle::BUNDLE_ACTIVE;
}
コード例 #14
0
QCA::KeyBundle keyBundle_( const QString &path, const QString &pass )
{
  QCA::SecureArray passarray;
  if ( !pass.isEmpty() )
    passarray = QCA::SecureArray( pass.toUtf8() );
  QCA::ConvertResult res;
  QCA::KeyBundle bundle( QCA::KeyBundle::fromFile( path, passarray, &res, QString( "qca-ossl" ) ) );
  return ( res == QCA::ConvertGood ? bundle : QCA::KeyBundle() );
}
コード例 #15
0
void
PipelineSimpleLinkedPortExample::draw(IGrafPort& port)
{
        IGrafBundle bundle(kDefaultFillColor, kDefaultFrameColor);
        ILinkedGrafPort bundlePort(&port, &bundle);

        IGPolygon2D polygon(IGRect2D(20,20,220,180));
        bundlePort.draw(polygon);
}
コード例 #16
0
NS_IMETHODIMP ImportOutlookMailImpl::ImportMailbox(  nsIImportMailboxDescriptor *pSource,
        nsIFile *pDestination,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    NS_PRECONDITION(pSource != nsnull, "null ptr");
    NS_PRECONDITION(pDestination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

    nsCOMPtr<nsIStringBundle>  bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));

    nsString  success;
    nsString  error;
    if (!pSource || !pDestination || !fatalError) {
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_BADPARAM, error, bundle);
        if (fatalError)
            *fatalError = PR_TRUE;
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }

    PRBool    abort = PR_FALSE;
    nsString  name;
    PRUnichar *  pName;
    if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
        name = pName;
        NS_Free( pName);
    }

    PRUint32 mailSize = 0;
    pSource->GetSize( &mailSize);
    if (mailSize == 0) {
        ReportSuccess( name, 0, &success);
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_OK);
    }

    PRUint32 index = 0;
    pSource->GetIdentifier( &index);
    PRInt32  msgCount = 0;
    nsresult rv = NS_OK;

    m_bytesDone = 0;

    rv = m_mail.ImportMailbox( &m_bytesDone, &abort, (PRInt32)index, name.get(), pDestination, &msgCount);

    if (NS_SUCCEEDED( rv))
        ReportSuccess( name, msgCount, &success);
    else
        ReportError( OUTLOOKIMPORT_MAILBOX_CONVERTERROR, name, &error);

    SetLogs( success, error, pErrorLog, pSuccessLog);

    return( rv);
}
コード例 #17
0
void
PipelineClippingExample::draw(IGrafPort& port)
{
        IGArea clipArea(IGRect2D(140,100,300,300));
        ILinkedGrafPort clipPort(&port, &clipArea);

        IGEllipse2D ellipse(IGRect2D(20,20,220,180));
        IGrafBundle bundle(kDefaultFillColor, kDefaultFrameColor);

        clipPort.draw(ellipse, bundle);
}
コード例 #18
0
// static
const QString QgsAuthProviderPkiPkcs12::certAsPem( const QString &bundlepath, const QString &bundlepass )
{
  QString cert;
  if ( !QCA::isSupported( "pkcs12" ) )
    return cert;

  QCA::KeyBundle bundle( keyBundle_( bundlepath, bundlepass ) );
  if ( bundle.isNull() )
    return cert;

  return bundle.certificateChain().primary().toPEM();
}
コード例 #19
0
ファイル: pragmatics.c プロジェクト: linwukang/pcp
/* organize fetch bundling for given expression */
static void
bundle(Task *t, Expr *x)
{
    Metric	*m;
    Host	*h;
    int		i;

    if (x->op == CND_FETCH) {
	m = x->metrics;
	for (i = 0; i < x->hdom; i++) {
	    h = findHost(t, m);
	    m->host = h;
	    if (m->conv)	/* initialized Metric */
		bundleMetric(h, m);
	    else		/* uninitialized Metric */
		waitMetric(m);
	    m++;
	}
#if PCP_DEBUG
	if (pmDebug & DBG_TRACE_APPL1) {
 	    fprintf(stderr, "bundle: task " PRINTF_P_PFX "%p nth=%d prev=" PRINTF_P_PFX "%p next=" PRINTF_P_PFX "%p delta=%.3f nrules=%d\n",
 		t, t->nth, t->prev, t->next, t->delta, t->nrules+1);
	    __dumpExpr(1, x);
	    m = x->metrics;
	    for (i = 0; i < x->hdom; i++) {
		__dumpMetric(2, m);
		m++;
	    }
	}
#endif
    }
    else {
	if (x->arg1) {
	    bundle(t, x->arg1);
	    if (x->arg2)
		bundle(t, x->arg2);
	}
    }
}
コード例 #20
0
ファイル: hex3function.cpp プロジェクト: reolyze/wallgen
std::complex<double> hex3Function::operator ()(double i, double j)
{
    std::complex<double> ans(0,0);
    for(unsigned int k=0; k<terms; k++)
    {
        std::complex<double> thisterm = bundle(i, j, k);
        thisterm *= coeffs[k].combined();
        ans+= thisterm;
    }

    ans *= scale.combined();
    return ans;
}
コード例 #21
0
ファイル: AppRes.cpp プロジェクト: tsiru/pcsx2
const wxIconBundle& Pcsx2App::GetIconBundle()
{
    ScopedPtr<wxIconBundle>& bundle( GetResourceCache().IconBundle );
    if( !bundle )
    {
        bundle = new wxIconBundle();
        bundle->AddIcon( EmbeddedImage<res_AppIcon32>().GetIcon() );
        bundle->AddIcon( EmbeddedImage<res_AppIcon64>().GetIcon() );
        bundle->AddIcon( EmbeddedImage<res_AppIcon16>().GetIcon() );
    }

    return *bundle;
}
コード例 #22
0
ファイル: step6.c プロジェクト: jimjag/libdill
int main(int argc, char *argv[]) {

    int port = 5555;
    if(argc > 1)
        port = atoi(argv[1]);

    struct ipaddr addr;
    int rc = ipaddr_local(&addr, NULL, port, 0);
    assert(rc == 0);
    int ls = tcp_listen(&addr, 10);
    if(ls < 0) {
        perror("Can't open listening socket");
        return 1;
    }

    int ch[2];
    rc = chmake(ch);
    assert(rc == 0);
    int cr = go(statistics(ch[0]));
    assert(cr >= 0);

    int b = bundle();
    assert(b >= 0);

    int i;
    for(i = 0; i != 3; i++) {
        int s = tcp_accept(ls, NULL, -1);
        assert(s >= 0);
        s = suffix_attach(s, "\r\n", 2);
        assert(s >= 0);
        rc = bundle_go(b, dialogue(s, ch[1]));
        assert(rc == 0);
    }

    rc = bundle_wait(b, now() + 10000);
    assert(rc == 0 || (rc < 0 && errno == ETIMEDOUT));

    rc = hclose(b);
    assert(rc == 0);
    rc = hclose(cr);
    assert(rc == 0);
    rc = hclose(ch[0]);
    assert(rc == 0);
    rc = hclose(ch[1]);
    assert(rc == 0);
    rc = hclose(ls);
    assert(rc == 0);

    return 0;
}
コード例 #23
0
NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
        nsIAddrDatabase *destination,
        nsIImportFieldMap *fieldMap,
        nsISupports *aSupportService,
        PRBool isAddrLocHome,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    m_msgCount = 0;
    m_msgTotal = 0;
    NS_PRECONDITION(source != nsnull, "null ptr");
    NS_PRECONDITION(destination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

    nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));

    nsString  success;
    nsString  error;
    if (!source || !destination || !fatalError) {
        IMPORT_LOG0( "*** Bad param passed to outlook address import\n");
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error, bundle);
        if (fatalError)
            *fatalError = PR_TRUE;
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }

    nsString name;
    source->GetPreferredName(name);

    PRUint32  id;
    if (NS_FAILED( source->GetIdentifier( &id))) {
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_ERROR_FAILURE);
    }

    nsresult rv = NS_OK;
    rv = m_address.ImportAddresses( &m_msgCount, &m_msgTotal, name.get(), id, destination, error);
    if (NS_SUCCEEDED( rv) && error.IsEmpty())
        ReportSuccess( name, &success);
    else
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_CONVERTERROR, name, &error);

    ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
    IMPORT_LOG0( "*** Returning from outlook address import\n");
    return destination->Commit(nsAddrDBCommitType::kLargeCommit);
}
コード例 #24
0
void
PipelineConcatExample::draw(IGrafPort& port)
{
        IGrafMatrix matrix(15.0, IGPoint2D(140,100)); // 15 degree rotation matrix centered on (140,100)
        IGrafBundle bundle(kDefaultFillColor, kDefaultFrameColor);

        ILinkedGrafPort matrixPort(&port, kViewMatrix, &matrix);
        ILinkedGrafPort bundlePort(&matrixPort, &bundle);

        IGPolygon2D polygon(IGRect2D(20,20,220,180));
        IGEllipse2D ellipse(IGRect2D(20,20,220,180));

        bundlePort.draw(polygon);
        bundlePort.draw(ellipse);
}
コード例 #25
0
ファイル: pragmatics.c プロジェクト: linwukang/pcp
/* pragmatics analysis */
void
pragmatics(Symbol rule, RealTime delta)
{
    Expr	*x = symValue(rule);
    Task	*t;

    if (x->op != NOP) {
	t = findTask(delta);
	bundle(t, x);
	t->nrules++;
	t->rules = (Symbol *) ralloc(t->rules, t->nrules * sizeof(Symbol));
	t->rules[t->nrules-1] = symCopy(rule);
	perf->eval_expected += (float)1/delta;
    }
}
コード例 #26
0
// static
const QString QgsAuthProviderPkiPkcs12::keyAsPem( const QString &bundlepath, const QString &bundlepass, bool reencrypt )
{
  QString key;
  if ( !QCA::isSupported( "pkcs12" ) )
    return key;

  QCA::KeyBundle bundle( keyBundle_( bundlepath, bundlepass ) );
  if ( bundle.isNull() )
    return key;

  QCA::SecureArray passarray;
  if ( reencrypt && !bundlepass.isEmpty() )
    passarray = QCA::SecureArray( bundlepass.toUtf8() );

  return bundle.privateKey().toPEM( passarray );
}
コード例 #27
0
ファイル: dbmgr.cpp プロジェクト: guozanhua/kbengine
//-------------------------------------------------------------------------------------
void Dbmgr::onReqAllocEntityID(Mercury::Channel* pChannel, int8 componentType, COMPONENT_ID componentID)
{
	KBEngine::COMPONENT_TYPE ct = static_cast<KBEngine::COMPONENT_TYPE>(componentType);

	// 获取一个id段 并传输给IDClient
	std::pair<ENTITY_ID, ENTITY_ID> idRange = idServer_.allocRange();
	Mercury::Bundle bundle(pChannel);

	if(ct == BASEAPP_TYPE)
		bundle.newMessage(BaseappInterface::onReqAllocEntityID);
	else	
		bundle.newMessage(CellappInterface::onReqAllocEntityID);

	bundle << idRange.first;
	bundle << idRange.second;
	bundle.send(this->getNetworkInterface(), pChannel);
}
コード例 #28
0
ファイル: qgsauthconfig.cpp プロジェクト: GeoCat/QGIS
const QgsPkiBundle QgsPkiBundle::fromPkcs12Paths( const QString &bundlepath,
    const QString &bundlepass )
{
  QgsPkiBundle pkibundle;
  if ( QCA::isSupported( "pkcs12" )
       && !bundlepath.isEmpty()
       && ( bundlepath.endsWith( QLatin1String( ".p12" ), Qt::CaseInsensitive )
            || bundlepath.endsWith( QLatin1String( ".pfx" ), Qt::CaseInsensitive ) )
       && QFile::exists( bundlepath ) )
  {
    QCA::SecureArray passarray;
    if ( !bundlepass.isNull() )
      passarray = QCA::SecureArray( bundlepass.toUtf8() );
    QCA::ConvertResult res;
    QCA::KeyBundle bundle( QCA::KeyBundle::fromFile( bundlepath, passarray, &res, QStringLiteral( "qca-ossl" ) ) );
    if ( res == QCA::ConvertGood && !bundle.isNull() )
    {
      const QCA::CertificateChain cert_chain( bundle.certificateChain() );
      QSslCertificate cert( cert_chain.primary().toPEM().toLatin1() );
      if ( !cert.isNull() )
      {
        pkibundle.setClientCert( cert );
      }
      QSslKey cert_key( bundle.privateKey().toPEM().toLatin1(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray() );
      if ( !cert_key.isNull() )
      {
        pkibundle.setClientKey( cert_key );
      }

      if ( cert_chain.size() > 1 )
      {
        QList<QSslCertificate> ca_chain;
        for ( const auto &ca_cert : cert_chain )
        {
          if ( ca_cert != cert_chain.primary() )
          {
            ca_chain << QSslCertificate( ca_cert.toPEM().toLatin1() );
          }
        }
        pkibundle.setCaChain( ca_chain );
      }

    }
  }
  return pkibundle;
}
コード例 #29
0
ファイル: restsnew.cpp プロジェクト: LocutusOfBorg/poedit
void
NewResourceBundleTest::TestNewTypes() {
    char action[256];
    const char* testdatapath;
    UErrorCode status = U_ZERO_ERROR;
    uint8_t *binResult = NULL;
    int32_t len = 0;
    int32_t i = 0;
    int32_t intResult = 0;
    uint32_t uintResult = 0;
    UChar expected[] = { 'a','b','c','\0','d','e','f' };
    const char* expect ="tab:\t cr:\r ff:\f newline:\n backslash:\\\\ quote=\\\' doubleQuote=\\\" singlequoutes=''";
    UChar uExpect[200];

    testdatapath=loadTestData(status);

    if(U_FAILURE(status))
    {
        dataerrln("Could not load testdata.dat %s \n",u_errorName(status));
        return;
    }

    ResourceBundle theBundle(testdatapath, "testtypes", status);
    ResourceBundle bundle(testdatapath, Locale("te_IN"),status);

    UnicodeString emptyStr = theBundle.getStringEx("emptystring", status);
    if(emptyStr.length() != 0) {
      logln("Empty string returned invalid value\n");
    }

    CONFIRM_UErrorCode(status, U_ZERO_ERROR);

    /* This test reads the string "abc\u0000def" from the bundle   */
    /* if everything is working correctly, the size of this string */
    /* should be 7. Everything else is a wrong answer, esp. 3 and 6*/

    strcpy(action, "getting and testing of string with embeded zero");
    ResourceBundle res = theBundle.get("zerotest", status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_STRING);
    UnicodeString zeroString=res.getString(status);
    len = zeroString.length();
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(len, 7);
        CONFIRM_NE(len, 3);
    }
    for(i=0;i<len;i++){
        if(zeroString[i]!= expected[i]){
            logln("Output didnot match Expected: \\u%4X Got: \\u%4X", expected[i], zeroString[i]);
        }
    }

    strcpy(action, "getting and testing of binary type");
    res = theBundle.get("binarytest", status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_BINARY);
    binResult=(uint8_t*)res.getBinary(len, status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(len, 15);
        for(i = 0; i<15; i++) {
            CONFIRM_EQ(binResult[i], i);
        }
    }

    strcpy(action, "getting and testing of imported binary type");
    res = theBundle.get("importtest",status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_BINARY);
    binResult=(uint8_t*)res.getBinary(len, status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(len, 15);
        for(i = 0; i<15; i++) {
            CONFIRM_EQ(binResult[i], i);
        }
    }

    strcpy(action, "getting and testing of integer types");
    res = theBundle.get("one",  status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_INT);
    intResult=res.getInt(status);
    uintResult = res.getUInt(status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(uintResult, (uint32_t)intResult);
        CONFIRM_EQ(intResult, 1);
    }

    strcpy(action, "getting minusone");
    res = theBundle.get((const char*)"minusone", status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_INT);
    intResult=res.getInt(status);
    uintResult = res.getUInt(status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(uintResult, 0x0FFFFFFF); /* a 28 bit integer */
        CONFIRM_EQ(intResult, -1);
        CONFIRM_NE(uintResult, (uint32_t)intResult);
    }

    strcpy(action, "getting plusone");
    res = theBundle.get("plusone",status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_INT);
    intResult=res.getInt(status);
    uintResult = res.getUInt(status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(uintResult, (uint32_t)intResult);
        CONFIRM_EQ(intResult, 1);
    }

    res = theBundle.get("onehundredtwentythree",status);
    CONFIRM_UErrorCode(status, U_ZERO_ERROR);
    CONFIRM_EQ(res.getType(), URES_INT);
    intResult=res.getInt(status);
    if(U_SUCCESS(status)){
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        CONFIRM_EQ(intResult, 123);
    }

    /* this tests if escapes are preserved or not */
    {
        UnicodeString str = theBundle.getStringEx("testescape",status);
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        if(U_SUCCESS(status)){
            u_charsToUChars(expect,uExpect,(int32_t)uprv_strlen(expect)+1);
            if(str.compare(uExpect)!=0){
                errln("Did not get the expected string for testescape expected. Expected : " 
                    +UnicodeString(uExpect )+ " Got: " + str);
            }
        }
    }
    /* test for jitterbug#1435 */
    {
        UnicodeString str = theBundle.getStringEx("test_underscores",status);
        expect ="test message ....";
        CONFIRM_UErrorCode(status, U_ZERO_ERROR);
        u_charsToUChars(expect,uExpect,(int32_t)uprv_strlen(expect)+1);
        if(str.compare(uExpect)!=0){
            errln("Did not get the expected string for test_underscores.\n");
        }
    }


}
コード例 #30
0
ファイル: cfutilities.cpp プロジェクト: Proteas/codesign
string cfStringRelease(CFBundleRef inBundle)
{
	CFRef<CFBundleRef> bundle(inBundle);
	return cfString(bundle);
}