Documentation ¶
Overview ¶
Package hashtags implements a simple #hashtag/@mentions handler.
Copyright © 2019, 2022 M.Watermann, 10247 Berlin, Germany All rights reserved EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Index ¶
- Variables
- type TCountItem
- type THashList
- func (hl *THashList) Checksum() uint32
- func (hl *THashList) Clear() *THashList
- func (hl *THashList) CountedList() (rList []TCountItem)
- func (hl *THashList) Filename() string
- func (hl *THashList) HashAdd(aHash, aID string) *THashList
- func (hl *THashList) HashCount() int
- func (hl *THashList) HashLen(aHash string) int
- func (hl *THashList) HashList(aHash string) []string
- func (hl *THashList) HashRemove(aHash, aID string) *THashList
- func (hl *THashList) IDlist(aID string) (rList []string)
- func (hl *THashList) IDparse(aID string, aText []byte) *THashList
- func (hl *THashList) IDremove(aID string) *THashList
- func (hl *THashList) IDrename(aOldID, aNewID string) *THashList
- func (hl *THashList) IDupdate(aID string, aText []byte) *THashList
- func (hl *THashList) Len() int
- func (hl *THashList) LenTotal() (rLen int)
- func (hl *THashList) Load() (*THashList, error)
- func (hl *THashList) MentionAdd(aMention, aID string) *THashList
- func (hl *THashList) MentionCount() int
- func (hl *THashList) MentionLen(aMention string) int
- func (hl *THashList) MentionList(aMention string) []string
- func (hl *THashList) MentionRemove(aMention, aID string) *THashList
- func (hl *THashList) SetFilename(aFilename string) *THashList
- func (hl *THashList) Store() (int, error)
- func (hl *THashList) String() string
- func (hl *THashList) Walk(aFunc TWalkFunc)
- func (hl *THashList) Walker(aWalker THashWalker)
- type THashWalker
- type TWalkFunc
Constants ¶
This section is empty.
Variables ¶
var ( // UseBinaryStorage determines whether to use binary storage // or not (i.e. plain text). // // Loading/storing binary data is about three times as fast with // the `THashList` data than reading and parsing plain text data. UseBinaryStorage = true )
Functions ¶
This section is empty.
Types ¶
type TCountItem ¶
type TCountItem = struct { Count int // number of IDs for this #hashtag/@mention Tag string // name of #hashtag/@mention }
TCountItem holds a #hashtag/@mention and its number of occurrences.
@see CountedList()
type THashList ¶
type THashList struct {
// contains filtered or unexported fields
}
THashList is a list of `#hashtags` and `@mentions` pointing to sources (i.e. IDs).
func New ¶
New returns a new `THashList` instance after reading the given file.
If the hash file doesn't exist that is not considered an error. If there is an error, it will be of type *PathError.
`aFilename` is the name of the file to use for reading and storing.
func (*THashList) Checksum ¶
Checksum returns the list's CRC32 checksum.
This method can be used to get a kind of 'footprint'.
func (*THashList) Clear ¶
Clear empties the internal data structures: all `#hashtags` and `@mentions` are deleted.
func (*THashList) CountedList ¶
func (hl *THashList) CountedList() (rList []TCountItem)
CountedList returns a list of #hashtags/@mentions with their respective count of associated IDs.
func (*THashList) Filename ¶
Filename returns the configured filename for reading/storing this list.
func (*THashList) HashAdd ¶
HashAdd appends `aID` to the list of `aHash`.
If either `aHash` or `aID` are empty strings they are silently ignored (i.e. this method does nothing).
`aHash` is the list index to lookup. `aID` is to be added to the hash list.
func (*THashList) HashLen ¶
HashLen returns the number of IDs stored for `aHash`.
`aHash` identifies the ID list to lookup.
func (*THashList) HashList ¶
HashList returns a list of IDs associated with `aHash`.
`aHash` identifies the ID list to lookup.
func (*THashList) HashRemove ¶
HashRemove deletes `aID` from the list of `aHash`.
`aHash` identifies the ID list to lookup. `aID` is the source to remove from the list.
func (*THashList) IDparse ¶
IDparse checks whether `aText` contains strings starting with `[@|#]` and – if found – adds them to the respective list.
`aID` is the ID to add to the list. `aText` is the text to search.
func (*THashList) IDremove ¶
IDremove deletes all @hashtags/@mentions associated with `aID`.
`aID` is to be deleted from all lists.
func (*THashList) IDrename ¶
IDrename replaces all occurrences of `aOldID` by `aNewID`.
This method is intended for rare cases when the ID of a document needs to get changed.
`aOldID` is to be replaced in all lists. `aNewID` is the replacement in all lists.
func (*THashList) IDupdate ¶
IDupdate checks `aText` removing all #hashtags/@mentions no longer present and adding #hashtags/@mentions new in `aText`.
`aID` is the ID to update. `aText` is the text to use.
func (*THashList) Len ¶
Len returns the current length of the list i.e. how many #hashtags and @mentions are currently stored in the list.
func (*THashList) Load ¶
Load reads the configured file returning the data structure read from the file and a possible error condition.
If the hash file doesn't exist that is not considered an error. If there is an error, it will be of type `*PathError`.
func (*THashList) MentionAdd ¶
MentionAdd appends `aID` to the list of `aMention`.
If either `aMention` or `aID` are empty strings they are silently ignored (i.e. this method does nothing).
`aMention` is the list index to lookup. `aID` is to be added to the hash list.
func (*THashList) MentionCount ¶ added in v0.5.0
MentionCount returns the number of mentions in the list.
func (*THashList) MentionLen ¶
MentionLen returns the number of IDs stored for `aMention`.
`aMention` identifies the ID list to lookup.
func (*THashList) MentionList ¶
MentionList returns a list of IDs associated with `aMention`.
`aMention` identifies the ID list to lookup.
func (*THashList) MentionRemove ¶
MentionRemove deletes `aID` from the list of `aMention`.
`aMention` identifies the ID list to lookup. `aID` is the source to remove from the list.
func (*THashList) SetFilename ¶
SetFilename sets `aFilename` to use by this list.
func (*THashList) Store ¶
Store writes the whole list to the configured file returning the number of bytes written and a possible error.
If there is an error, it will be of type `*PathError`.
func (*THashList) Walk ¶
Walk traverses through all entries in the #hashtag/@mention lists calling `aFunc` for each entry.
If `aFunc` returns `false` when called the respective ID will be removed from the associated #hashtag/@mention.
`aFunc` is the function called for each ID in all lists.
func (*THashList) Walker ¶
func (hl *THashList) Walker(aWalker THashWalker)
Walker traverses through all entries in the INI list sections calling `aWalker` for each entry.
`aWalker` is an object implementing the `TIniWalker` interface.
type THashWalker ¶
THashWalker is used by `Walker()` when visiting an entry in the #hashtag/@mentions lists.
`aHash` is the list index to lookup. `aID` is to be added to the hash list.