andy,


i have a couple of questions regarding usage of classes such as Mailbox and Message.



first question is, how can i make two differnt instance of Mailbox at the same time?


for example, the following code will end up showing exactly same list while my intention is obviously to print two different lists.


Mailbox* foo = depot.get("INBOX/foo"); Mailbox::iterator e1 = foo->end(); for (Mailbox::iterator i1 = foo->begin(); i1 != e1;++i1) { Message & message = *i1; logger << "INBOX/foo: " << message.getID() << endl; }

  Mailbox* bar = depot.get("INBOX/bar");
  Mailbox::iterator e2 = bar->end();
  for (Mailbox::iterator i2 = bar->begin(); i2 != e2;++i2) {
    Message & message = *i2;
    logger << "INBOX/bar: " << message.getID() << endl;
  }


second one is, how can i make an instance of Message from its `id' when i know it.


for example, the following code will not compile.

  const string &folder = "INBOX/foo";
  const string &id = "123456789.1234.foo.bar.com";

  Mailbox *mailbox = NULL;
  mailbox = depot.get(folder);

Message &message = mailbox->get(id); // error

Mailbox::get() is a `protected' method so that i can't make Message from `id' as simple as the above code. am i supposed to use Iterator to find it maybe like the following code? i hope not...

  Mailbox* foo = depot.get("INBOX/foo");
  Mailbox::iterator e = foo->end();
  for (Mailbox::iterator i = foo->begin(); i != e;++i) {
    Message & message = *i;
    if (message.getID() == "123456789.1234.foo.bar.com") {
      // manipulate the message here.
      break;
    }
  }


i know i have to read more of codes but since i haven't played with c++ for a long time, it's pretty tough for me to understand them clearly without any documents ;-)



thanks, -- Hiroshima



Reply via email to