Exemplo n.º 1
0
int main()
{
    std::cout<< "hello, this is mystring plugin" << std::endl;

    MyString str0("AAA");
    std::cout << "str0="<< str0 << std::endl;

    MyString str1(NULL);
    std::cout << "str1="<< str1 << std::endl;

    //MyString str2; // compile error, cause lacking of default constructor
    //std::cout << "str2="<< str2 << std::endl;

    str0 += "BBB";
    std::cout << "str0="<< str0 << std::endl;

    MyString str3("CCC");
    str0 += str3;
    std::cout << "str0="<< str0 << std::endl;

    MyString str4("DDD");
    MyString str5("DDD");
    std::cout << "str4==str5:"<< ((str4==str5)? "true":"false") << std::endl;

    std::vector<MyString> vec;
    vec.push_back(MyString("aaa"));
    vec.push_back(MyString("bbb"));
    std::cout << "vec:"<< vec[0] << ", " << vec[1] << std::endl;

    return 0;
}
Exemplo n.º 2
0
int CTest::test_caseInsensitiveButCasePreserving(int argc, char* argv[])
{
    AutoPtr<IRawHeaders> h;
    CRawHeaders::New((IRawHeaders**)&h);
    String str0("Content-Type");
    String str1("text/plain");
    h->Add(str0, str1);
    // Case-insensitive:
    String strOut;
    h->Get(str0, &strOut);
    Boolean flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str2("Content-type");
    h->Get(str2, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str3("content-type");
    h->Get(str3, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str4("CONTENT-TYPE");
    h->Get(str4, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    // ...but case-preserving:
    AutoPtr<IMap> innerMap;
    h->ToMultimap((IMap**)&innerMap);
    AutoPtr<ISet> keyset;
    innerMap->KeySet((ISet**)&keyset);
    AutoPtr<ArrayOf<IInterface*> > array;
    keyset->ToArray((ArrayOf<IInterface*>**)&array);
    AutoPtr<ICharSequence> cs = (ICharSequence*)ICharSequence::Probe((*array)[0]);
    String str5(String("Content-Type"));
    cs->ToString(&strOut);
    flag = strOut.Equals(str5);
    assert(flag == TRUE);

    // We differ from the RI in that the Map we return is also case-insensitive.
    // Our behavior seems more consistent. (And code that works on the RI will work on Android.)
    // AutoPtr<ICharSequence> cs1;
    // CString::New(String("Content-Type"), (ICharSequence**)&cs1);
    // AutoPtr<IInterface> value;
    // innerMap->Get(cs1, (IInterface**)&value);
    // assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-Type"));
    // assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-type")); // RI fails this.
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
  // BinaryCode *bc = new BinaryCode();
  auto_ptr<BinaryCode> bc (new BinaryCode());
  string str1 ("123210122");
  vector<string> str1Response = bc->decode(str1);
  cout << "Dla stringa: " << str1 << endl;
  cout << "Pierwsza wartość: " << str1Response[0] << endl;
  cout << "Druga wartość: " << str1Response[1] << endl << endl;
  
  string str2 ("11");
  vector<string> str2Response = bc->decode(str2);
  cout << "Dla stringa: " << str2 << endl;
  cout << "Pierwsza wartość: " << str2Response[0] << endl;
  cout << "Druga wartość: " << str2Response[1] << endl << endl;;
  
  string str3 ("22111");
  vector<string> str3Response = bc->decode(str3);
  cout << "Dla stringa: " << str3 << endl;
  cout << "Pierwsza wartość: " << str3Response[0] << endl;
  cout << "Druga wartość: " << str3Response[1] << endl << endl;;
  
  string str4 ("123210120");
  vector<string> str4Response = bc->decode(str4);
  cout << "Dla stringa: " << str4 << endl;
  cout << "Pierwsza wartość: " << str4Response[0] << endl;
  cout << "Druga wartość: " << str4Response[1] << endl << endl;;
  
  string str5 ("3");
  vector<string> str5Response = bc->decode(str5);
  cout << "Dla stringa: " << str5 << endl;
  cout << "Pierwsza wartość: " << str5Response[0] << endl;
  cout << "Druga wartość: " << str5Response[1] << endl << endl;;
  
  string str6 ("12221112222221112221111111112221111");
  vector<string> str6Response = bc->decode(str6);
  cout << "Dla stringa: " << str6 << endl;
  cout << "Pierwsza wartość: " << str6Response[0] << endl;
  cout << "Druga wartość: " << str6Response[1] << endl << endl;;
  return 0;
}
Exemplo n.º 4
0
int init() {
    QTextStream out(stdout);
    
    QString str1 = "The night train";
    out << str1 << endl;
    
    QString str2("A yellow rose");
    out << str2 << endl;
    
    std::string s1 = "A blue sky";
    QString str3 = s1.c_str();
    out << str3 << endl;
    
    std::string s2 = "A think fog";
    QString str4 = QString::fromAscii(s2.data(), s2.size());
    out << str4 << endl;
    
    char s3[] = "A deep forest";
    QString str5(s3);
    out << str5 << endl;
    
    return 0;
}
Exemplo n.º 5
0
Arquivo: post.cpp Projeto: dmsTest/dms
void post::pushB1_clicked()
{
    client.dataMine();
    list<MLogRec> logList_temp= logreader.getLogList();
    list<MLogRec>::iterator it=logList_temp.begin();
    while(it!=logList_temp.end()){
        QString str1(it->logname);
        QString str2(it->logip);
        int pid=it->pid;
        QString str3(QString::number(pid));
        long logintime=it->logintime;
        QString str4(QString::number(logintime));
        long logouttime=it->logouttime;
        QString str5(QString::number(logouttime));
        long logtime=it->logtime;
        QString str6(QString::number(logtime));
        QString str=str1+"  "+str2+"  "+str3+"  "+str4+"  "+str5+"  "+str6+'\n';
        ui->textEdit->append(str);
        it++;
    }
    ui->textEdit->append("***************************Send data over!***********************");
    ui->textEdit->append("total:"+QString::number(logList_temp.size()));

}
Exemplo n.º 6
0
int main(){
  String str;
  String str2("Salut");
  String str4("Beaucoup");
  String str3(str2);

  printf("Length : %zu \n",str2.length());
  printf("Max_Size : %zu \n",str2.max_size());

  str2.resize((size_t)7);
  printf("Size: %zu \n",str2.size());
  
  str2.clear();
  printf("Size: %zu \n",str2.size());
  
  const char* essai=str3.c_str();
  printf(essai);
  
  String str6=str4 +" trop" ;

  str2='c';


  str2.resize((size_t)3,'c');
  //~ String str6(str);

  str2.resize((size_t)102,'c');

  str2='c';
  String operatoregal;
  operatoregal=str4;
  printf("Size: %zu \n",operatoregal.size());

  printf("%zu \n",str2.capacity()) ;
  printf("%d \n",str2.empty()) ;
  printf("%d \n",str.empty()) ;
  String str5("Hello !") ;
  printf("Size : %zu\n",str5.length()) ;
  printf("Capacity : %zu\n",str5.capacity()) ;
  str5.reserve((size_t)10) ;
  printf("Size : %zu\n",str5.length()) ;
  printf("Capacity : %zu\n",str5.capacity()) ;
  str5.reserve((size_t)9) ;
  printf("Size : %zu\n",str5.length()) ;
  printf("Capacity : %zu\n",str5.capacity()) ;
  str5.reserve((size_t)5) ;
  printf("Size : %zu\n",str5.length()) ;
  printf("Capacity : %zu\n",str5.capacity()) ;
  //~ str5.reserve((size_t)200) ;
  //~ printf("Size : %zu\n",str5.length()) ;
  //~ printf("Capacity : %zu\n",str5.capacity()) ;
  //~ 
  String str360;
  str360=str2+'d';
  printf("Size : %zu\n",str360.length()) ;
  String elea1("Bla");
  printf("Size : %zu\n",elea1.length()) ;
  printf("Capacity : %zu\n",elea1.capacity()) ;

  String elea2(" bla");
  String elea3 = elea1 + elea2 ;
  printf("Size : %zu\n",elea3.length()) ;
  printf("Capacity : %zu\n",elea3.capacity()) ;
  return 0 ;
}
/*  the gateway routine.  */
void mexFunction( int nlhs, mxArray *plhs[],
        int nrhs, const mxArray *prhs[] )
{
    
    /* create a pointer to the real data in the input matrix  */
    int nfields = mxGetNumberOfFields(prhs[0]); // number of fields in each constraint
    mwSize NStructElems = mxGetNumberOfElements(prhs[0]); // number of constraints
    const char **fnames = (const char **)mxCalloc(nfields, sizeof(*fnames)); /* pointers to field names */
    double *sw = mxGetPr(prhs[1]); /* switch vector */ 
    double *xs = mxGetPr(prhs[2]); /* linearisation point */
    long unsigned int nrow = mxGetM(prhs[2]);
    double *ptr = mxGetPr(prhs[3]); /* number of cameras */
    int ncams = ptr[0];
    
    /* initialise a PwgOptimiser object */
    PwgOptimiser *Object; // pointer initialisation
    Object = new PwgOptimiser (ncams, nrow-6*ncams) ; // pointer initialisation
    
    /* get constraints from Matlab to C++ and initialise a constraint */
    double *pr;
    mxArray *tmp;
    int cam, kpt;
    std::vector<double> p1(2), z(2), R(4,0.0);//, Y(49,0.0), y(7,0.0);
    std::string str1 ("cam");
    std::string str2 ("kpt");
    std::string str3 ("p1");
    std::string str4 ("z");
    std::string str5 ("R");
    std::string str6 ("y");
    std::string str7 ("Y");
    Eigen::MatrixXd yz = Eigen::MatrixXd::Zero(7,1);
    Eigen::VectorXd Yz = Eigen::MatrixXd::Zero(7,7);
    for (mwIndex jstruct = 0; jstruct < NStructElems; jstruct++) { /* loop the constraints */
        for (int ifield = 0; ifield < nfields; ifield++) {  /* loop the fields */
            fnames[ifield] = mxGetFieldNameByNumber(prhs[0],ifield); // get field name
            tmp = mxGetFieldByNumber(prhs[0], jstruct, ifield); // get field
            pr = (double *)mxGetData(tmp); // get the field data pointer
            if (str1.compare(fnames[ifield]) == 0) // cam
                cam = pr[0];
            if (str2.compare(fnames[ifield]) == 0) // kpt
                kpt = pr[0];
            if (str3.compare(fnames[ifield]) == 0){ // p1
                p1[0] = pr[0]; p1[1] = pr[1];}
            if (str4.compare(fnames[ifield]) == 0){ // z
                z[0] = pr[0]; z[1] = pr[1];}
            if (str5.compare(fnames[ifield]) == 0){ // R
                R[0] = pr[0]; R[3] = pr[3];}
        } // end of nfields loop
        Object->initialise_a_constraint(cam, kpt, p1, z, R, Yz, yz, (int)sw[jstruct]) ; // using pointer to object
    } // end of NStructElems loop
    
    // optimise constraints information
    Object->optimise_constraints_image_inverse_depth_Mviews( xs ) ;
            
    /* get output state vector */
    int ncol = (Object->xhat).size();
    plhs[0] = mxCreateDoubleMatrix(ncol, 1, mxREAL);
    double *vec_out = mxGetPr(plhs[0]);
    for (int i=0; i<ncol; i++)
        vec_out[i] = (Object->xhat).coeffRef(i);
    
    /* get output sparse covariance matrix */
    ncol = (Object->Phat).outerSize();
    long unsigned int nzmax = (Object->Phat).nonZeros();
    plhs[1] = mxCreateSparse(ncol, ncol, nzmax, mxREAL);
    double *mat_out = mxGetPr(plhs[1]);
    long unsigned int *ir2 = mxGetIr(plhs[1]);
    long unsigned int *jc2 = mxGetJc(plhs[1]);
    int index=0;
    for (int k=0; k < (Object->Phat).outerSize(); ++k)
    {
        jc2[k] = index;
        for (Eigen::SparseMatrix<double>::InnerIterator it(Object->Phat,k); it; ++it)
        {
            ir2[index] = it.row();
            mat_out[index] = it.value();
            index++;
        }
    }
    jc2[(Object->Phat).outerSize()] = index;
    
    /* Free memory */
    mxFree((void *)fnames);
    delete Object; // delete class pointer
    //mxFree(tmp);
}