Skip to content

Commit

Permalink
Update README and GUI functionality; Fixed bug in validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ASolimanA committed Jan 1, 2025
1 parent 0c2d517 commit 16b5116
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 deletions.
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ This project provides both a Command-Line Interface (CLI) application and a Grap
## Features
- Validate XML files and detect parsing or formatting errors.
- Convert XML to JSON for easier data handling and storage.
- Compress and decompress XML files (CLI future feature).
- Compress and decompress XML files.
- Pretty-print XML files for better readability.
- Minify XML files to reduce storage space.
- Simple GUI to load, format, and convert XML files.
- CLI flags for quick batch processing of XML files.
- Analyze social media XML files and visualize the relationships between users and posts using graph analysis.

## Requirements
- The [Mingw-w64](https://www.mingw-w64.org/) compiler (for Windows) or GCC (for Linux).
- [CMake](https://cmake.org/) (version ≥ 3.19).
- [Qt6](https://www.qt.io/) if you want to build the GUI application.
- A build system (e.g., Ninja, Make, Visual Studio).
- [Graphviz](https://graphviz.org/) must be installed for generating and drawing the graphs.
- **Download and use the prebuilt Qt application from the GitHub Releases** instead of building from source for a quicker setup.
- **Building from source** requires the following:
- CMake 3.19 or later.
- Qt6.
- A C++17-compatible compiler.
- Ninja (optional but recommended for faster builds).

## Quick Setup
1. Clone this repository locally.
2. Ensure CMake and Qt6 are installed and available in your PATH.
Expand All @@ -41,27 +48,28 @@ This project provides both a Command-Line Interface (CLI) application and a Grap
```bash
./CLI/cli_app <command> -option <optionValue>
```
5. Run the GUI app (Qt required):
- Windows:
```shell
GUI\gui_app.exe
```
- Other systems:
```shell
./GUI/gui_app
```
5. Run the GUI app:
- Prebuilt Qt application:
- Download the latest release
- Run the executable file (bin/gui_app.exe).
- Building from source:
- Run the GUI app from the build directory:
```shell
./GUI/gui_app
```
6. Enjoy the XML Manipulation software!
## Usage
### CLI
Use the CLI for automated or script-based workflows:
```shell
cli_app <command> -option <optionValue>
cli_app <command> --option <optionValue>
```
- `<command>`: The operation to perform (validate, convert, etc.).
- `-option <optionValue>`: The option to pass to the command (e.g., file path, output format).

### GUI
Use the GUI to explore XML files, format them, and convert to JSON interactively.
Use the GUI to explore XML files, format them, and convert to JSON interactively as well as analyze the social media XML files using the graph analysis and visualization feature.

## Authors
| Name | GitHub |
Expand Down
4 changes: 2 additions & 2 deletions XML-to-JSON/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ add_subdirectory(GUI)


# Enable testing and include tests
enable_testing()
add_subdirectory(tests)
# enable_testing()
# add_subdirectory(tests)
1 change: 1 addition & 0 deletions XML-to-JSON/GUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ qt_generate_deploy_app_script(
install(SCRIPT ${deploy_script})

set(CMAKE_BUILD_TYPE "Release")
set(CPACK_PACKAGE_VERSION "0.1.2")

include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "GUIApp-Release")
Expand Down
17 changes: 16 additions & 1 deletion XML-to-JSON/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void MainWindow::get_file_path() {
}

void MainWindow::Read_File() {
ui->input_XML->clear();
clearOutput();
fix_enable_buttons();
QString filePath = ui->lineEdit->text();
if (!filePath.isEmpty()) {
QFile file(filePath);
Expand Down Expand Up @@ -93,6 +93,7 @@ void MainWindow::on_fix_clicked()
outputType = xml;
ui->Message->setText("Fixed Successfully.");
ui->Message->setStyleSheet("QLabel { color: green; }");
fix_disable_buttons();
}
}

Expand Down Expand Up @@ -278,6 +279,20 @@ void MainWindow::clearOutput() {
ui->Message->clear();
}

void MainWindow::fix_disable_buttons() {
ui->pretty->setEnabled(false);
ui->convert->setEnabled(false);
ui->graph_analysis->setEnabled(false);
ui->minify->setEnabled(false);
}

void MainWindow::fix_enable_buttons() {
ui->pretty->setEnabled(true);
ui->convert->setEnabled(true);
ui->graph_analysis->setEnabled(true);
ui->minify->setEnabled(true);
}

MainWindow::~MainWindow()
{
delete ui;
Expand Down
3 changes: 3 additions & 0 deletions XML-to-JSON/GUI/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ class MainWindow : public QMainWindow
void compress_XML();
void decompress_XML();
void on_minify_clicked();

void fix_disable_buttons();
void fix_enable_buttons();
};
#endif // MAINWINDOW_H
7 changes: 6 additions & 1 deletion XML-to-JSON/common/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ bool Validator::validate (){
tag.clear(); // Clear the tag variable before storing a new tag
} else if (line[i] == '>') {
if (!tag.empty()) {
if (tag[0] == '?' || tag[0] == '!' || tag[0] == '-') { // If it's a declaration tag
insideTag = false;
tag.clear();
continue; // Skip the XML declaration tag
}
if (tag[0] == '/') { // If it's a closing tag
insideTag = false;
tag = tag.substr(1); // Remove the "/" at the beginning of the tag
Expand Down Expand Up @@ -94,7 +99,7 @@ bool Validator::validate (){
else if (insideTag) {
tag += line[i]; // Append characters to the tag while inside the tag
}
else if (phase == aotag && line[i] != ' ') {
else if (phase == aotag && line[i] > ' ') {
phase = leaf;
}
}
Expand Down
Empty file.

0 comments on commit 16b5116

Please sign in to comment.