Remove unused old API.
[platform/upstream/iotivity.git] / examples / OICMiddle / LineInput.h
1 #ifndef LINEINPUT_H
2 #define LINEINPUT_H
3
4 //******************************************************************
5 //
6 // Copyright 2014 Intel Corporation.
7 //
8 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 //      http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23
24 #include "OICMiddle.h"
25 #include "Client.h"
26 #include "Server.h"
27
28 typedef vector<string> elements_t;
29
30 enum ParseState {
31     PS_None,
32     PS_Between,
33     PS_Infirst,
34     PS_Startsecond,
35     PS_Insecond,
36     PS_Endsecond,
37 };
38
39 class LineInput
40 {
41 public:
42     LineInput(MiddleClient *client);
43     void setServer(MiddleServer *server);
44     int run();
45     LineResult processLine(string command, stringstream& result, observecb_t cb);
46
47 protected:
48     MiddleClient *m_client;
49     MiddleServer *m_server;
50     vector<string> m_resourceList;
51     observecb_t m_obsCB;
52     WrapResource *m_observer;
53     char m_elem[1000];
54
55     LineResult processHelp(elements_t& elems, stringstream& ss);
56     LineResult processUnrecognized(elements_t& elems, stringstream& ss);
57     LineResult processFind(elements_t& elems, stringstream& ss);
58     LineResult processShow(elements_t& elems, stringstream& ss);
59     LineResult processDetails(elements_t& elems, stringstream& ss);
60     LineResult processGet(elements_t& elems, stringstream& ss);
61     LineResult processPut(elements_t& elems, stringstream& ss);
62     LineResult processObserve(elements_t& elems, stringstream& ss, observecb_t cb);
63     LineResult processCancel(elements_t& elems, stringstream& ss);
64     WrapResource *resolveResource(string resID, stringstream& ss);
65     LineResult parseLine(string lineIn, elements_t& elems);
66     ParseState finishElem(char*& e, elements_t& elems);
67     ParseState putCharInElem(char c, char *& e, ParseState newState);
68     void obsCB(const token_t token, const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode, const int sequenceNumber);
69     void registerResourceWithServer(std::string &url);
70 };
71
72 #endif // LINEINPUT_H