Ensures normalization on waitfe/fc-xml operations
[anna.git] / source / http / Method.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
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 //
7
8
9 #include <anna/http/Method.hpp>
10 #include <anna/http/internal/Token.hpp>
11
12 using namespace std;
13 using namespace anna;
14
15 anna_assign_enum(http::Method::Type) = {
16   "POST", "OPTIONS", "GET", "HEAD", "PUT", "DELETE", "TRACE", "CONNECT", NULL
17 };
18
19 http::Method::Type::_v http::Method::asType(const http::Token* token)
20 throw() {
21   for(int ii = 0; anna_item_enum(http::Method::Type, ii) != NULL; ii ++) {
22     if(token->match(anna_item_enum(http::Method::Type, ii)) == true)
23       return (Type::_v) ii;
24   }
25
26   return Type::None;
27 }
28
29 string http::Method::asString(const http::Method::Type::_v type)
30 throw() {
31   string result("http::Method { Name: ");
32   result += Type::asCString(type);
33   return result += " }";
34 }
35