Ejemplo n.º 1
0
Archivo: status.cpp Proyecto: aox/aox
Status::Status( Command * c, Mailbox * m )
    : Command( c->imap() ), d( new StatusData )
{
    setGroup( 4 );
    d->mailbox = m;
    d->uidnext = true;

    IMAP * i = c->imap();
    if ( !i )
        return;

    if ( i->clientSupports( IMAP::Condstore ) )
        d->modseq = true;
    requireRight( d->mailbox, Permissions::Read );

    i->commands()->insert( i->commands()->find( c ), this );
    setState( Executing );
}
Ejemplo n.º 2
0
 value_type operator()(const CTYPE &index) const
 {
     return _data[_imap.offset(index)];
 }
Ejemplo n.º 3
0
 //-----------------------------------------------------------------
 //! 
 //! \brief get number of dimensions 
 //! 
 //! Returns the number of dimensions of the array. 
 //!
 //! \return number of dimensions
 //!
 size_t rank() const 
 { 
     return _imap.rank(); 
 }
Ejemplo n.º 4
0
 //----------------------------------------------------------------
 //! 
 //! \brief shape to container
 //! 
 //! This returns a container of type CTYPE with the number of
 //! elements stored in the array. 
 //! 
 //! \tparam CTYPE container type 
 //! \return instance of CTYPE with shape data
 //!
 template<typename CTYPE> CTYPE shape() const
 {
     auto c = container_utils<CTYPE>::create(_imap.rank());
     std::copy(_imap.begin(),_imap.end(),c.begin());
     return c;
 }
Ejemplo n.º 5
0
int main()
{
    IMAP items;
    IMAP::iterator it;

    Item item1;
    sprintf(item1.name, "%s", "long sword");
    item1.kind = 1;
    item1.cost = 200;
    item1.scode = 0;

    Item item2;
    sprintf(item2.name, "%s", "heritic shield");
    item2.kind = 2;
    item2.cost = 1000;
    item2.scode = 4;

    Item item3;
    sprintf(item3.name, "%s", "hammer");
    item3.kind = 1;
    item3.cost = 500;
    item3.scode = 0;

    // add items to "items"
    items.insert( IMAP::value_type(item2.name, item2) );
    items.insert( IPAIR(item1.name, item1) );

    if( false == items.empty() )
    {
        cout << "Number of items in \"items\" - " << items.size() << endl;
    }

    for( it=items.begin(); it!=items.end(); ++it )
    {
        cout << "name: " << it->first << ", cost: " << it->second.cost << endl;
    }

    it = items.find("long sword");
    if( it == items.end() )   {
        cout << "There's no \"long sword\" in item list" << endl;
    }
    cout << endl;

    cout << "map(string key) - ordered by asc" << endl;

    O_IMAP Items2;
    O_IMAP::iterator IterPos2;

    Items2.insert( O_IMAP::value_type(item2.name, item2) );
    Items2.insert( O_IPAIR(item1.name, item1) );

    // save item using operator[]
    Items2[item3.name] = item3;

    for( IterPos2 = Items2.begin(); IterPos2 != Items2.end(); ++IterPos2 )
    {
        cout << "name: " << IterPos2->first << ", cost: " << IterPos2->second.cost << endl;
    }
    cout << endl;

    cout << "How much is the hammer? ";
    IterPos2 = Items2.find("hammer");
    if( IterPos2 != Items2.end() )   {
        cout << IterPos2->second.cost << endl;
    }
    else {
        cout << "There's no hammer in item list." << endl;
    }
    cout << endl;

    // remove item "long sword"
    IterPos2 = Items2.find("long sword");
    if( IterPos2 != Items2.end() )   {
        Items2.erase( IterPos2 );
    }

    cout << "Number of items in \"Items2\" - " << Items2.size() << endl;

    return 0;
}