pwsafe — Core Layer

See parent: pwsafe

The core layer lives in src/core/ and is platform-independent C++. It is shared by all UI frontends.

PWScore — Application Controller

PWScore (src/core/PWScore.h/.cpp) is the central class. It owns the in-memory database (a map of UUID → CItemData), manages open/save/close lifecycle, mediates between the UI and the file layer, and drives the undo/redo stack. It implements the CommandInterface abstract class.

CItem / CItemData — Password Entries

CItem (src/core/Item.h) is the base for all database objects. It stores fields in a map keyed by FieldType, each field encrypted with BlowFish in memory (see crypto).

CItemData (src/core/ItemData.h) extends CItem for password entries. It provides typed Get*()/Set*() accessors (GetTitle, GetPassword, GetURL, etc.), handles entry type (Normal/Alias/Shortcut), and owns per-entry password policy and history.

CItemAtt (src/core/ItemAtt.h) extends CItem for binary attachments (V4 only).

PWSfile — File I/O Hierarchy

PWSfile (src/core/PWSfile.h) is an abstract base providing a factory method and the Open/Close/ReadRecord/WriteRecord interface. Concrete subclasses: PWSfileV1V2, PWSfileV3, PWSfileV4. See fileformat for the on-disk layout.

Command Pattern — Undo/Redo

All user-initiated mutations are encapsulated in Command subclasses (src/core/Command.h/.cpp). Every command implements Execute(), Redo(), and Undo(). MultiCommands composes several commands atomically. PWScore maintains the undo/redo stacks.

Observer — Core→UI Interface

UIinterface.h defines the Observer mixin (classic Observer/Listener pattern). The UI main class inherits Observer and overrides callbacks such as DatabaseModified(), UpdateGUI(). PWScore holds a pointer to the Observer and calls it without knowing the concrete UI type.

Other Notable Core Classes

PWSprefs — persistent preferences (XML-backed on all platforms) • PWPolicy / PolicyManager — password generation policies • PWHistory — per-entry password change history • PWSFilters — saved search/filter definitions • TotpCore — TOTP/HOTP two-factor auth support • CustomFields — user-defined entry fields • RUEList — recently-used entries list • StringX — custom string type wrapping std::wstring, used everywhere

version1
created2026-02-24