From 0724ba05b38726b165d594a20055dcf72c8bb297 Mon Sep 17 00:00:00 2001 From: Preston Date: Wed, 15 Oct 2025 21:47:48 -0700 Subject: [PATCH] Implemented WatchDog file watcher; verifies file changes and prints last modified time. All functions tested and working. --- .vscode/settings.json | 64 ++++++++++++++++++++++++++++++++++++++++++- lib/inlindeNode.h | 53 +++++++++++++++++++++++++++-------- src/main.cpp | 27 +++++++++++++++++- test/input.md | 2 +- 4 files changed, 132 insertions(+), 14 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1eaa062..0e113dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,65 @@ { - "C_Cpp.errorSquiggles": "disabled" + "C_Cpp.errorSquiggles": "disabled", + "files.associations": { + "filesystem": "cpp", + "algorithm": "cpp", + "atomic": "cpp", + "bit": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "deque": "cpp", + "exception": "cpp", + "format": "cpp", + "forward_list": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "locale": "cpp", + "memory": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "utility": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xutility": "cpp" + } } \ No newline at end of file diff --git a/lib/inlindeNode.h b/lib/inlindeNode.h index 09e5d13..956efbb 100644 --- a/lib/inlindeNode.h +++ b/lib/inlindeNode.h @@ -1,17 +1,48 @@ #ifndef INLINENODE_H #define INLINENODE_H -#include "node.h" -class InlineNode : public Node{ - public: - InlineNode(std::string content) : content(content); - protected: - std::string content; +#include "node.h" +#include + +/** + * @brief InlineNode class. + * + * Inherits from Node. Represents an inline object that is used + * by the DOM tree to convert inline tags from a markup file + * to an HTML file. + * + * @author Preston Shultz + */ +class InlineNode : public Node { +public: + InlineNode(const std::string& content) : content(content) {} + + // Optional: allow access to the content + std::string getContent() const { return content; } + +protected: + std::string content; }; -class TextNode : public InlineNode{}; -class BoldNode : public InlineNode{}; -class Italic : public InlineNode{}; -class BoldItalic : public InlineNode{}; +// These classes inherit the InlineNode constructor using `using` +class TextNode : public InlineNode { +public: + using InlineNode::InlineNode; +}; -#endif +class BoldNode : public InlineNode { +public: + using InlineNode::InlineNode; +}; + +class ItalicNode : public InlineNode { +public: + using InlineNode::InlineNode; +}; + +class BoldItalicNode : public InlineNode { +public: + using InlineNode::InlineNode; +}; + +#endif // INLINENODE_H diff --git a/src/main.cpp b/src/main.cpp index 2cfd5eb..63885a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "../lib/parser.h" +/*#include "../lib/parser.h" #include int main(int argc, char **argv) { @@ -25,3 +25,28 @@ int main(int argc, char **argv) { return 0; } +*/ + +/** + *Preston: Test to see if watchdog works :) + */ + +#include "watchDog.h" +#include + +int main() { + WatchDog wd("test/input.md"); + wd.start(); + + std::cout << "Initial check (should do nothing if file unchanged):\n"; + wd.checkFile(); + + std::cout << "Now, modify or create the file 'example.txt' manually and press Enter:\n"; + std::cin.get(); //Wait for user to press Enter + + //Check again after manual change + wd.checkFile(); + + std::cout << "Done testing.\n"; + return 0; +} \ No newline at end of file diff --git a/test/input.md b/test/input.md index 54ed126..b37a30c 100644 --- a/test/input.md +++ b/test/input.md @@ -1,6 +1,6 @@ -# Hello world in an h1 tag +# Hello world in a h1 tag ## This is a h2 tag