Udacity C++ nanodegree Capstone project
Next query is a command line tool that searches on mainstream search engines for the keywords passed in as arguments and shows in them in the command line.
Supported search engines are: google, bing.
- cmake >= 3.7
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
- sudo apt install libcurl3
- sudo apt install libpoco-dev
- sudo apt-get install openssl libssl-dev
- Clone this repo
- cd in to the root folder and clone googletest : git clone https://github.com/google/googletest.git
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it for search:
./NextQuery <keywords to search space separated>
- Run it with search history:
./NextQuery -h
.
├── bin
├── CMakeLists.txt
├── config
├── curlpp
├── googletest
├── README.md
├── src
└── test
- bin : where the binary of the application will be built [has to be created]
- CMakeLists.txt : root cmake file that defines project build requirements
- config: header configuration files used by CMakeLists.txt for major and minor application version
- curlpp : curlpp source code for project build dependencies
- googletest : googletest source code for project test requirements
- READE.md : this file
- src: folder containing source header and associated implementation files for the binary
- test: folder containing the unit test for testing different classes written for the project
Once the application is built and called, for example like this:
./NextQuery android
The out should be a list of results coming from Google and Bing showing the first results of each search engine for the keyword android.
Example:
bing :: Applications Android gratuites - commentcamarche.net https://www.commentcamarche.net/download/android/
bing :: Smartphones Android - Achetez un téléphone Android pas cher https://www.meilleurmobile.com/mobiles/search.do?osName=android
google :: Android - FrAndroid https://fr.wikipedia.org/wiki/Android
- create a bin directory in project source
- cd in to bin directory
- run cmake .. & make
###The project demonstrates an understanding of C++ functions and control structures
- HtmlParser.cpp : line 22, use of while loop
- HtmlParser.cpp : line 59, use of for loop
- UrlBuilder.cpp : line 27-37, use of if/else structure
- GoogleHtmlParser.cpp | BingHtmlParser.cpp : code organized in functions
- NextQuery.cpp : line 57 and 74, read and writing
- NextQuery.cpp : line 13 - 52, read and process user input params
- see source code in src directory
- HtmlParser.h : line 18 & line 29 public and private access specifiers
- QueryRunner.h : abstracts away the execution of a web search and hides multi-threading
- UrlBuilder.h and HtmlParser.h extends AbstractBase.h for common functionality
- BingHtmlParser.h and GoogleHtmlParser.h implement virtual methods from HtmlParser.h
- QueryRunner.cpp uses unique_ptr, line 18 for parser strategy
- QueryRunner.h uses shared_ptr, line 25 for grouping results from 2 threads
- QueryRunner.cpp : line 43, use of multi-threading
- QueryRunner.cpp : line 31, lock gard is used