L
Lambda
The code is simple:
// Token.h
#ifndef TOKEN_H
#define TOKEN_H
#include <vector>
#include <string>
class Token
{
public:
Token() : type("word"), positionIncrement(1), startOffset(0),
endOffset(0) {}
void setPositionIncrement(const unsigned int increment)
{
positionIncrement = increment;
}
unsigned int getPositionIncrement() const
{
return positionIncrement;
}
void setTermBuffer(const std::vector<char>::size_type&,
const std::vector<char>::size_type&);
private:
std::vector<char> termBuffer;
std::vector<char> payload;
unsigned int startOffset;
unsigned int endOffset;
std::string type;
unsigned int positionIncrement;
};
#endif
// Token.cpp
#include <algorithm>
#include <iterator>
#include "Token.h"
using std::copy;
using std::back_inserter;
void Token::setTermBuffer(const std::vector<char>::size_type& b,
const std::vector<char>::size_type& e)
{
copy(b, e, back_inserter(termBuffer));
}
The setTermBuffer function is used to copy a vector into the
termBuffer vector.
But I got an error: 'error C2100: illegal indirection'
What does it mean?
BTW, as I include <vector> in the header file,
the cpp file include the header, need I add '#include <vector>' the
cpp file?
Best Regards,
Lambda
// Token.h
#ifndef TOKEN_H
#define TOKEN_H
#include <vector>
#include <string>
class Token
{
public:
Token() : type("word"), positionIncrement(1), startOffset(0),
endOffset(0) {}
void setPositionIncrement(const unsigned int increment)
{
positionIncrement = increment;
}
unsigned int getPositionIncrement() const
{
return positionIncrement;
}
void setTermBuffer(const std::vector<char>::size_type&,
const std::vector<char>::size_type&);
private:
std::vector<char> termBuffer;
std::vector<char> payload;
unsigned int startOffset;
unsigned int endOffset;
std::string type;
unsigned int positionIncrement;
};
#endif
// Token.cpp
#include <algorithm>
#include <iterator>
#include "Token.h"
using std::copy;
using std::back_inserter;
void Token::setTermBuffer(const std::vector<char>::size_type& b,
const std::vector<char>::size_type& e)
{
copy(b, e, back_inserter(termBuffer));
}
The setTermBuffer function is used to copy a vector into the
termBuffer vector.
But I got an error: 'error C2100: illegal indirection'
What does it mean?
BTW, as I include <vector> in the header file,
the cpp file include the header, need I add '#include <vector>' the
cpp file?
Best Regards,
Lambda