Building a web site using C++!

Building web site using c++

Hello there! This post is about the C++ application that I developed yesterday. This application can be used to build a Website! I had this idea in my mind for quite some time. I took the time and developed it at last :). The main purpose of the application is to build a simple customizable website using C++ to write HTML pages(more about it later).Some of the features of the application are:

  • You can have as many pages as you want.
  • A link is provided to each and every page in every page
  • You can add content as much as you want in each page
  • You can set the background colour, text colour and font style of each and every page 

Here's a video of it:



If you are wondering how I might've developed this application, then here's a little information. I created a class called WebSite and another class called WebPage. WebPage holds information about each individual page's colour, font style, text colour, content etc. The WebSite class is used to hold the value of the number of pages in the website, a collection of WebPage(Which when put together form the website) objects and their common details such as the name of the website and the name and directory of the folder where generated HTML pages are to be stored.

Here are the definitions and methods of WebSite class followed by WebPage class:

NOTE: only inline methods are mentioned below, to see all the methods, see the link provided at the end of this post.

WebSite class:

WebPage class:

Now coming to how this application uses above classes to create the website. if you could see the WebPage class definition above, there's a method called buildPage(). This method is useful to convert all the details of the page and website details into HTML file. here's the implementation of  buildPage() method:

So what actually happens in the above method is that HTML syntax is being written into a .html file that I create using the page_path data member of the WebPage class. So this is the main mechanism for this application. It just provides required details at appropriate places using the details stored in each individual object. I hope you get the idea :)

Apart from this, I've learned something new! I've known how to create a directory and get the current path using the system() and _getcwd() functions. I've used them in the setDirectoryPath() method of WebSite class. Here's the implementation:

You can know more about them by seeing the MSDN pages :) So that's it for now. Here's the link for the text file and also project file if you'd like to go through each and every method(There's much more to the application)

text file: CLICK
project file: CLICK

Comments

Popular posts from this blog

Beginner's guide to Solving the N-Queens problem using backtracking method

PvP Chain reaction game using Python

Guide to Solving Maximal Subarray Problem using Kadane's Algorithm