1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
12 #include <anna/config/defines.hpp>
13 #include <anna/core/functions.hpp>
15 #include <anna/http/internal/Token.hpp>
20 const string& http::Token::getStringValue() const
22 if(contains(0) == false)
23 const_cast <Token*>(this)->a_aux.assign(DataBlock::getData(), DataBlock::getSize());
25 const_cast <Token*>(this)->a_aux = DataBlock::getData();
30 int http::Token::getIntegerValue() const
32 if(contains(0) == false) {
33 const_cast <Token*>(this)->a_aux.assign(DataBlock::getData(), DataBlock::getSize());
34 return atoi(a_aux.c_str());
37 return atoi(DataBlock::getData());
40 bool http::Token::contains(const char byte) const
45 for(p = DataBlock::getData(), maxp = p + DataBlock::getSize(); p < maxp; p ++) {
53 int http::Token::calculeOffset(const DataBlock& base) const
54 throw(RuntimeException) {
55 const int result = getData() - base.getData();
58 string msg("anna::http::Token::calculeOffset | Invalid address for the token: ");
59 msg += functions::asString(*this);
60 throw RuntimeException(msg, ANNA_FILE_LOCATION);
66 bool http::Token::match(const char* str) const
68 const char* pp = DataBlock::getData();
69 int size = DataBlock::getSize();
79 return (anna_strlen(str) != size) ? false : (strncasecmp(pp, str, size) == 0);