Am Montag, 29. November 2010, um 16:53:14 schrieb Dmitriy Igrishin:
> Hey Jan,
> 
> I don't clearly understand what are you want.
> All I can see that you are trying to call Wt::WString::operator[](int).
> 
> Probably, you want to get values of each Post by identifier ?
> 
> 2010/11/29 Jan Köster <[email protected]>
> 
> > why can't I access a collection like a vector ?
> > 
> > blog.h
> > /*
> > 
> >   Copyright 2010 Jan Koester
> >   
> >   Licensed under the Apache License, Version 2.0 (the "License");
> >   you may not use this file except in compliance with the License.
> >   You may obtain a copy of the License at
> >   
> >       http://www.apache.org/licenses/LICENSE-2.0
> >   
> >   Unless required by applicable law or agreed to in writing, software
> >   distributed under the License is distributed on an "AS IS" BASIS,
> >   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> >   implied. See the License for the specific language governing
> >   permissions and limitations under the License.
> > 
> > */
> > #ifndef VIEWPOSTS_H_
> > #define VIEWPOSTS_H_
> > 
> > #include <Wt/Dbo/Dbo>
> > #include <Wt/Dbo/Query>
> > #include <Wt/Dbo/WtSqlTraits>
> > #include <Wt/Dbo/Types>
> > 
> > class Posts : public  Wt::Dbo::Dbo<Posts>
> > {
> > 
> >  private:
> >    Wt::Dbo::Session Session;
> >  
> >  public:
> >    void setSession(Wt::Dbo::Session *session){
> >    
> >      Session = *session;
> >      Session.mapClass<Posts>("blog");
> >    
> >    };
> >    
> >    void setCategory(int *category){
> >    
> >      Category =*category;
> >    
> >    };
> >    
> >    void setQuery();
> >    
> >    int getCounts();
> >    
> >    int getId(){
> >    
> >      return Id;
> >    
> >    }
> >    
> >       /*Problem here*/
> >    
> >    Wt::WString getTitle(int id){
> >    
> >      return Title[id];
> >    
> >    }
> >    
> >    Wt::WString getAuthor(int id){
> >    
> >      return Author[id];
> >    
> >    }
> >    
> >    Wt::WString getCreated(int id){
> >    
> >      return Created.toString("dd.MM.yyyy")[id];
> >    
> >    }
> >    Wt::WString getContent(int id){
> >    
> >      return Content[id];
> >    
> >    }
> >    /* what could be wrong ?*/
> >    typedef Wt::Dbo::collection<Wt::Dbo::ptr<Posts>> ViewPostings;
> >    Wt::Dbo::ptr<Posts> entry;
> >    int Id,Category;
> >    Wt::WDate Created;
> >    Wt::WString Title;
> >    Wt::WString Author;
> >    Wt::WString Content;
> >    
> >    template<class Action>
> >    void persist(Action& a)
> >    {
> >    
> >       Wt::Dbo::field(a, Id, "id");
> >       Wt::Dbo::field(a, Category, "category");
> >       Wt::Dbo::field(a, Title, "title");
> >       Wt::Dbo::field(a, Author, "author");
> >       Wt::Dbo::field(a, Created, "created");
> >       Wt::Dbo::field(a, Content, "content");
> >    
> >    }
> > 
> > };
> > #endif
> > 
> > blog.cpp
> > /*
> > 
> >   Copyright 2010 Jan Koester
> >   
> >   Licensed under the Apache License, Version 2.0 (the "License");
> >   you may not use this file except in compliance with the License.
> >   You may obtain a copy of the License at
> >   
> >       http://www.apache.org/licenses/LICENSE-2.0
> >   
> >   Unless required by applicable law or agreed to in writing, software
> >   distributed under the License is distributed on an "AS IS" BASIS,
> >   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> >   implied. See the License for the specific language governing
> >   permissions and limitations under the License.
> > 
> > */
> > #include <iostream>
> > #include <string>
> > #include <vector>
> > 
> > #include "viewposts.h"
> > 
> > void Posts::setQuery()
> > {
> > 
> >  try {
> >  
> >    Session.createTables();
> >  
> >  }catch (...) { }
> >  Wt::Dbo::Transaction transaction(Session);
> >  ViewPostings viewpostings;
> >  if(Category>=0){
> >  
> >    viewpostings = Session.find<Posts>();
> >  
> >  }else{
> >  
> >    viewpostings = Session.find<Posts>().where("category =
> > 
> > ?").bind(Category);
> > 
> >  }
> > 
> > /*
> > 
> >  for (ViewPostings::const_iterator i = viewpostings.begin(); i !=
> > 
> > viewpostings.end(); ++i){
> > 
> >       (*i)->Title;
> >       (*i)->Author;
> >       (*i)->Created.toString("dd.MM.yyyy");
> >       (*i)->Content;
> >    
> >    }*/
> >  
> >  transaction.commit();
> > 
> > }
> > 
> > 
> > int Posts::getCounts()
> > {
> > 
> >  try {
> >  
> >    Session.createTables();
> >  
> >  }catch (...) { }
> >  Wt::Dbo::Transaction transaction(Session);
> >  ViewPostings viewpostings;
> >  if(Category>=0){
> >  
> >    viewpostings = Session.find<Posts>();
> >  
> >  }else{
> >  
> >    viewpostings = Session.find<Posts>().where("category =
> > 
> > ?").bind(Category);
> > 
> >  }
> >  transaction.commit();
> >  return viewpostings.size();
> > 
> > }
> > 
> > 
> > -------------------------------------------------------------------------
> > ----- Increase Visibility of Your 3D Game App & Earn a Chance To Win
> > $500! Tap into the largest installed PC base & get more eyes on your
> > game by optimizing for Intel(R) Graphics Technology. Get started today
> > with the Intel(R) Software Partner Program. Five $500 cash prizes are up
> > for grabs. http://p.sf.net/sfu/intelisp-dev2dev
> > _______________________________________________
> > witty-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/witty-interest

yes i would access every element by row number

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to