Skip to content

A lightweight C++ string handling class with built-in Undo and Redo functionality using stacks. Ideal for text-based tools, editors, and educational projects. Implements clean property-style access and efficient history tracking.

Notifications You must be signed in to change notification settings

AmrTamerTech/clsString_With_Undo_Redo_Feature-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

📌 clsMyString – Custom Stack with REDO & UNDO Feature ⚡

A C++ class for managing strings with built-in undo/redo functionality using stacks. 🚀


🌟 Project Overview

The clsMyString class provides a powerful string management system with the ability to undo and redo changes. It uses two internal stacks to track modifications, allowing users to revert or reapply changes efficiently—perfect for command-based interfaces, mini text editors, and learning projects.


🔹 Core Functionalities

  • ✏️ Set and Get String Values
  • Undo Last Change
  • Redo Last Undone Change

This class makes it easy to maintain a history of string changes while offering a clean interface using property-style accessors in C++.


✨ Features

🔹 Basic String Operations

  • SetValue(string): Updates the string and saves the old value for undo.
  • GetValue(): Retrieves the current string value.
  • Value property: Provides clean access using __declspec(property).

🔹 Undo/Redo Functionality

  • Undo(): Restores the previous string state.
  • Redo(): Reapplies the last undone change.

🚀 How It Works

🔹 Managing String Changes

  • When SetValue() is called, the current value is pushed onto the undo stack.
  • Undo() pushes the current value to the redo stack and restores the top of the undo stack.
  • Redo() pushes the current value to the undo stack and restores the top of the redo stack.

🔹 Memory Management

  • Stack-based operations are fast and efficient.
  • Only necessary values are stored, avoiding memory bloat.

📚 Potential Enhancements

  • 🏗 History Limit: Add a configurable limit to undo/redo history.
  • 🔍 Change Tracking: Store diffs instead of full strings.
  • 📂 Persistence: Save and load history from files.
  • 🚀 Thread Safety: Add support for multithreaded environments.

⚙️ Technologies Used

  • Language: C++
  • Stacks: std::stack for undo/redo history
  • Strings: std::string for value storage
  • Property Access: __declspec(property) for clean getter/setter usage

🎯 Learning Outcomes

This project demonstrates:

✅ Stack-based undo/redo implementation
✅ Property-style encapsulation in C++
✅ Efficient and reversible state management
✅ Clean, modular class design


📜 License

This project is open-source. Feel free to modify and enhance it! 🚀


🤝 Contributing

Pull requests and improvements are welcome. If you have ideas, feel free to fork the repo and submit a PR!


🏁 Ready to Explore?

🚀 How to Run

  1. Clone or download the repository.
  2. Include clsMyString.h in your project.
  3. Create a simple main.cpp and compile:
    g++ main.cpp -o run
    ./run

About

A lightweight C++ string handling class with built-in Undo and Redo functionality using stacks. Ideal for text-based tools, editors, and educational projects. Implements clean property-style access and efficient history tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages