Skip to content

Commit

Permalink
split project by libs & refactoring cmake files
Browse files Browse the repository at this point in the history
Dev/v1.1.1
  • Loading branch information
IgorKilipenko committed May 16, 2024
2 parents 3c0616c + ba8834f commit 09e5a11
Show file tree
Hide file tree
Showing 31 changed files with 722 additions and 254 deletions.
8 changes: 8 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CompileFlags:
CompilationDatabase: "build"

Diagnostics:
ClangTidy:
Add: modernize*
Remove: modernize-use-trailing-return-type
UnusedIncludes: Strict
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
trim_trailing_whitespace = true
insert_final_newline = true
17 changes: 0 additions & 17 deletions .vscode/c_cpp_properties.json

This file was deleted.

5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"llvm-vs-code-extensions.vscode-clangd",
"streetsidesoftware.code-spell-checker",
"donjayamanne.githistory",
"jeff-hykin.better-cpp-syntax"
"jeff-hykin.better-cpp-syntax",
"ms-vscode.cmake-tools"
]
}
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@
"ignoreFailures": true
}
]
},
{
"name": "Debug App",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/spreadsheet",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "cmake: build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
81 changes: 81 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "cmake: configure",
"type": "shell",
"command": "cmake",
"args": [
"-S", "${workspaceFolder}",
"-B", "${workspaceFolder}/build",
"-DCMAKE_BUILD_TYPE=${input:buildType}"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"],
"detail": "Generated task to configure CMake project"
},
{
"label": "cmake: build",
"type": "shell",
"command": "cmake",
"args": [
"--build", "${workspaceFolder}/build",
"--config", "${input:buildType}",
"--target", "all",
"--",
"-j8"
],
"dependsOn": "cmake: configure",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"],
"detail": "Generated task to build CMake project"
},
{
"label": "cleanup",
"type": "shell",
"command": "rm",
"args": [
"-rf",
"${workspaceFolder}/build/*"
],
"group": "none"
},
{
"label": "install libspreadsheet",
"type": "shell",
"command": "cmake",
"args": [
"--build", "${workspaceFolder}/build",
"--config", "${input:buildType}",
"--target", "install"
],
"dependsOn": "cmake: build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"],
"detail": "Install libspreadsheet"
}
],
"inputs": [
{
"id": "buildType",
"type": "pickString",
"description": "Select the build type",
"options": [
"Debug",
"Release",
"MinSizeRel",
"RelWithDebInfo"
],
"default": "Debug"
}
]
}
50 changes: 43 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
cmake_minimum_required(VERSION 3.24)
set(CMAKE_VERBOSE_MAKEFILE ON)
project(spreadsheet
VERSION 1.1.0
DESCRIPTION "spreadsheet"
HOMEPAGE_URL "https://github.com/IgorKilipenko/cpp-spreadsheet"
LANGUAGES CXX
)

project(cpp-spreadsheet-app VERSION 1.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough")

# Add subdirectory with the library
add_subdirectory(spreadsheet)
# Source directiory
set(PROJECT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")

# Public include directiory
set(PROJECT_PUBLIC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")

# Installation directiory
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/bin")

# Add threads library for all lib targets
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)

# Find Java
find_package(Java REQUIRED)

# Include the ANTLR setup
include(cmake/install_antlr.cmake)

# Include the source files and create targets
include(cmake/install.cmake)

if(CMAKE_PROJECT_NAME STREQUAL "spreadsheet") # if spreadsheet is top-level project
# add include path
include_directories(include)
include_directories(src/include)
include_directories(src)

include(cmake/utils.cmake)
include(cmake/develop.cmake)
endif()

set_directory_properties(PROPERTIES VS_STARTUP_PROJECT spreadsheet)
83 changes: 80 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
# Cpp-Spreadsheet

## Дипломный проект: Электронная таблица
# Cpp-Spreadsheet (Электронная таблица)

## Содержание

- [Описание проекта](#project-description)
- [Функциональность](#main-features)
- [Пример использования](#use-examples)
- [Технологии](#project-technology)
- [Установка](#project-installation)

## Описание проекта {#project-description}

Этот проект представляет собой упрощённый аналог электронных таблиц. В ячейках таблицы могут содержаться как текст, так и формулы, включающие индексы (ссылки) других ячеек.

## Функциональность {#main-features}

- Поддержка чисел и строк в ячейках
- Возможность использования формул с числами, строками и ссылками на другие ячейки
- Автоматическое обновление значений ячеек при изменении зависимых ячеек
- Обработка циклических зависимостей и ошибок в формулах

## Пример использования {#use-examples}

```cpp
#include "spreadsheet.h"
#include <iostream>

int main() {
// Создаем новую таблицу
auto sheet = CreateSheet();

// Задаем значения ячеек
sheet->SetCell("A1"_pos, "Hello, world!");
sheet->SetCell("B1"_pos, "=2+2");

// Получаем значения ячеек и выводим на экран
std::cout << "A1: " << sheet->GetCell("A1"_pos)->GetValue() << std::endl;
std::cout << "B1: " << sheet->GetCell("B1"_pos)->GetValue() << std::endl;

// Очищаем ячейку
sheet->ClearCell("B1"_pos);

// Получаем значение очищенной ячейки (должно быть пусто)
std::cout << "B1 after clearing: " << sheet->GetCell("B1"_pos)->GetValue() << std::endl;

return 0;
}
```

## Технологии {#project-technology}

- Стандарт языка: C++17
- Парсинг формул: [ANTLR4](https://www.antlr.org/)
- Основная логика приложения: библиотека `libspreadsheet`
- Пример использования: консольное приложение `spreadsheet`

## Установка {#project-installation}

<details>

<summary>Для установки проекта выполните следующие шаги:</summary>

```bash
# Клонировать репозиторий
git clone https://github.com/IgorKilipenko/cpp-spreadsheet.git

# Перейти в каталог проекта
cd cpp-spreadsheet

# Собрать проект с помощью CMake
mkdir build
cd build
cmake ..
make

# Установить
make install
```

</details>
36 changes: 36 additions & 0 deletions cmake/develop.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
message(STATUS "-------------DEVELOP SETTING------------")

# Enable address sanitizer
option(ENABLE_SANITIZER "Enable sanitizer(Debug+Gcc/Clang/AppleClang)" ON)

if(ENABLE_SANITIZER AND NOT MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_asan(HAS_ASAN)
if(HAS_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
else()
message(WARNING "sanitizer is no supported with current tool-chains")
endif()
endif()
endif()

# warning
option(ENABLE_WARNING "Enable warning for all project " OFF)
if(ENABLE_WARNING)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
list(APPEND MSVC_OPTIONS "/W3")
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
list(APPEND MSVC_OPTIONS "/WX")
endif()
add_compile_options(MSVC_OPTIONS)
else()
add_compile_options(-Wall
-Wextra
-Wconversion
-pedantic
-Werror
-Wfatal-errors)
endif()
endif()

message(STATUS "--------------------------------------------")
Loading

0 comments on commit 09e5a11

Please sign in to comment.