XBase::Base(3pm)

πŸ“¦
version 1.08 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

XBase::Base β€” the base input/output module for the XBase suite, and it's literally the backbone bestie πŸ’…

Okay so real talk, this page is from the User Contributed Perl Documentation collection, and it's giving very much "infrastructure module, not a vibe for casual users." Let's get into it.


🌸 SYNOPSIS 🌸

You don't call this one directly, no cap β€” it comes in sideways:

Used indirectly, via XBase or XBase::Memo.

πŸ¦‹ DESCRIPTION πŸ¦‹

So XBase::Base is the catch-all I/O girlie for all the other XBase classes. It handles all the file-reading and file-writing drama so the other classes don't have to. This module is for people who are out here building extra XBase classes and methods β€” the devs, the extenders, the main characters of subclassing.

If you're just a regular user of the XBase(3) module, there is genuinely nothing interesting in here for you. Not a single crumb. Go home bestie. πŸ™ˆ

One thing you do need to know: methods in XBase::Base return nothing (undef) when they hit an error, and you can go grab the actual error message with the errstr method. That's your receipts. 🧾

Methods are:

  • new β€” the constructor, the origin story. It creates the object, and if you hand it a file name, it opens that file too. ✨
  • open β€” opens the file, then uses the method read_header to read the header and set up the object's data structure. Heads up: read_header should be defined in the derived class β€” there is no default, so if you didn't write it, that's on you. πŸ’€
  • close β€” closes the file. It does not destroy the object. The object lives on. Iconic, honestly. πŸ‘‘
  • drop β€” unlinks the file. Bye bye file. 🫢
  • create_file β€” creates a file with the given name. The second parameter is optional, and it's the permission specification for the file. πŸ”

Now, the reading/writing methods have some expectations, and here's the tea: they assume the file has a header of length header_len bytes (which is possibly 0), and after that, records of length record_len. Both of these values should be set by the read_header method. So like, set them. Don't be weird about it. πŸ’–

  • seek_to, seek_to_record β€” seeks to an absolute position, or to the start of the record. Pick your destination, babe. πŸ“
  • read_record, read_from β€” reads data from a specified position (that's the offset) or from a given record. The second parameter is the length to read β€” it's optional for read_record. And get this: that length can be negative, and in that case the read will not complain if the file is shorter than requested. Lowkey forgiving, highkey useful. 😌
  • write_to, write_record β€” writes data to an absolute position, or to a specified record position. Important: the data is not padded to record_len, it's just written out as-is. No padding, no filler, no extra fluff. Periodt. ✍️

General locking methods are locksh, lockex and unlock. These call _locksh, _lockex and _unlock, which can be redefined to allow any way of locking β€” not just the default flock. So you've got options, diva. πŸ”’

And the responsibility tea: the user is responsible for calling the lock if he needs it. Nobody's gonna do it for you. 🫑

No more description β€” check the source code if you need to know more. That's the whole vibe. Go read the source. πŸ“–


πŸ’œ VERSION πŸ’œ

1.02


🌈 AVAILABLE FROM 🌈

http://www.adelton.com/perl/DBD-XBase/

πŸŽ€ AUTHOR πŸŽ€

(c) 1997--2011 Jan Pazdziora.


⭐ SEE ALSO ⭐

perl(1), XBase(3)


And that's the whole page, bestie! 🫢 This one's running on perl v5.34.0, dated 2022-06-13, and it's the XBase::Base(3pm) manual page from the User Contributed Perl Documentation. Now go forth and subclass responsibly. Mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from