root/gsdl/trunk/runtime-src/src/oaiservr/resumptiontoken.cpp @ 20625

Revision 20625, 2.1 KB (checked in by mdewsnip, 10 years ago)

Fixed minor comment typo.

  • Property svn:keywords set to Author Date Id Revision
Line 
1#include "resumptiontoken.h"
2
3
4ResumptionToken::ResumptionToken(const text_t &build_date, const text_t &set, const text_t &metadata_prefix,
5                 const text_t &from, const text_t &until, const text_t &position)
6{
7  this->build_date = build_date;
8  this->set = set;
9  this->metadata_prefix = metadata_prefix;
10  this->from = from;
11  this->until = until;
12  this->position = position;
13  this->valid = true;
14}
15
16
17ResumptionToken::ResumptionToken(const text_t &resumption_token_string)
18{
19  this->build_date = "";
20  this->set = "";
21  this->metadata_prefix = "";
22  this->from = "";
23  this->until = "";
24  this->position = "";
25
26  // This uses custom code instead of the text_t splitchar() function because that is buggy
27  text_tarray resumption_token_string_parts;
28  text_t resumption_token_string_part;
29  text_t::const_iterator resumption_token_string_iterator = resumption_token_string.begin();
30  while (resumption_token_string_iterator != resumption_token_string.end())
31  {
32    if (*resumption_token_string_iterator == ',')
33    {
34      resumption_token_string_parts.push_back(resumption_token_string_part);
35      resumption_token_string_part.clear();
36    }
37    else
38    {
39      resumption_token_string_part.push_back(*resumption_token_string_iterator);
40    }
41
42    resumption_token_string_iterator++;
43  }
44  resumption_token_string_parts.push_back(resumption_token_string_part);
45
46  if (resumption_token_string_parts.size() != 6)
47  {
48    // The resumption token is invalid -- there should be exactly 6 parts
49    this->valid = false;
50    return;
51  }
52
53  this->build_date = resumption_token_string_parts[0];
54  this->set = resumption_token_string_parts[1];
55  this->metadata_prefix = resumption_token_string_parts[2];
56  this->from = resumption_token_string_parts[3];
57  this->until = resumption_token_string_parts[4];
58  this->position = resumption_token_string_parts[5];
59  this->valid = true;
60}
61
62
63text_t ResumptionToken::getResumptionTokenString()
64{
65  return this->build_date + "," + this->set + "," + this->metadata_prefix + "," + this->from + "," + this->until + "," + this->position;
66}
67
68
69bool ResumptionToken::isValid()
70{
71  return this->valid;
72}
Note: See TracBrowser for help on using the browser.