-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjsoniser.cpp~
More file actions
94 lines (75 loc) · 2.22 KB
/
jsoniser.cpp~
File metadata and controls
94 lines (75 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
*
*FILE NAME : Matcher.cpp
*FIRST VERSION : 31/12/2017
*PROGRAMMER : Nimal krishna
*DATE : 31/12/2017
*DESCRIPTION : This file imeplements the functions in Jsoniser class , which help to make JSON data based on the search performed by the matcher class.
*/
#include <iostream>
#include <string>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <stdlib.h>
#include <boost/boost/algorithm/string.hpp>
#include "Jsoniser.h"
#include <algorithm>
#include "Matcher.h"
//using namespace rapidjson;
using namespace std;
//using namespace boost;
Matcher matchobject;
int Matcher::NumberOfMatches;
bool Matcher::familyIspressent;
string Matcher::productFamily;
string Matcher::matchedList;
bool Matcher::familyInformationIsGiven ;
string Matcher::productModel;
string Matcher::productManafacturer;
string Matcher::productName;
Jsoniser::Jsoniser()
{
//constructor
}
Jsoniser::~Jsoniser()
{
//destructor
}
/*
*
*Function name : jsoniseData
*Parameters : none
*Return : string
*Description : to make JSON subdata based on the search performed by the matcher class.
*/
string Jsoniser::jsoniseData()
{
//Matcher matchedobject;
//json substring without the array of list objects
jsonSubstring=string("{\"product_name\":")+string("\"")+matchobject.productName+string("\"")+string(",")+string("\"listings\"")+string(":");
return jsonSubstring;
}
/*
*
*Function name : writeToOutputFile
*Parameters : none
*Return : int
*Description : The JSON data is written to 'output.txt'
*/
int Jsoniser::writeToOutputFile()
{
ofstream myfile;
myfile.open("output.txt",fstream::app);
fstream output;
output.open("output.txt",fstream::app); // data is added to the existing data without deleting it.But Before the writing starts the contents of 'output.txt' is cleared in matcher.cpp
output<<"dfsokdfsmdfmdsfmkdfmdf"<<endl;
myfile<<Jsoniser::jsonSubstring;
cout<<Jsoniser::jsonSubstring;
cout<<matchobject.matchedList<<endl;
myfile<<"["<<matchobject.matchedList<<"]"<<"}"<<endl; //Matched list has all the listings json data that matched with the product searched for.
return 1;
}