} \
catch (CoreException& modexcept) \
{ \
- ServerInstance->Logs->Log("MODULE",LOG_DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+ ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s",modexcept.GetReason()); \
} \
_i = safei; \
} \
} \
catch (CoreException& except_ ## n) \
{ \
- ServerInstance->Logs->Log("MODULE",LOG_DEFAULT,"Exception caught: %s", (except_ ## n).GetReason()); \
+ ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s", (except_ ## n).GetReason()); \
(void) mod_ ## n; /* catch mismatched pairs */ \
} \
} \
I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois,
I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick,
I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser,
- I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, I_OnAcceptConnection, I_OnUserInit,
+ I_OnSyncChannel, I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit,
I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule,
I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
*/
virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
- /** Called after every WALLOPS command.
- * @param user The user sending the WALLOPS
- * @param text The content of the WALLOPS message
- */
- virtual void OnWallops(User* user, const std::string &text);
-
/** Called whenever a user's hostname is changed.
* This event triggers after the host has been set.
* @param user The user whos host is being changed
virtual void OnSetUserIP(LocalUser* user);
};
-/** Caches a text file into memory and can be used to retrieve lines from it.
- * This class contains methods for read-only manipulation of a text file in memory.
- * Either use the constructor type with one parameter to load a file into memory
- * at construction, or use the LoadFile method to load a file.
- */
+/** Provides an easy method of reading a text file into memory. */
class CoreExport FileReader : public classbase
{
- /** The file contents
+ /** The lines of text in the file.
*/
- std::vector<std::string> fc;
+ std::vector<std::string> lines;
/** Content size in bytes
*/
- unsigned long contentsize;
-
- /** Calculate content size in bytes
- */
- void CalcSize();
+ unsigned long totalSize;
public:
- /** Default constructor.
- * This method does not load any file into memory, you must use the LoadFile method
- * after constructing the class this way.
- */
- FileReader();
-
- /** Secondary constructor.
- * This method initialises the class with a file loaded into it ready for GetLine and
- * and other methods to be called. If the file could not be loaded, FileReader::FileSize
- * returns 0.
- */
- FileReader(const std::string &filename);
-
- /** Default destructor.
- * This deletes the memory allocated to the file.
+ /** Initializes a new file reader.
*/
- ~FileReader();
+ FileReader() : totalSize(0) { }
- /** Used to load a file.
- * This method loads a file into the class ready for GetLine and
- * and other methods to be called. If the file could not be loaded, FileReader::FileSize
- * returns 0.
+ /** Initializes a new file reader and reads the specified file.
+ * @param file The file to read into memory.
*/
- void LoadFile(const std::string &filename);
+ FileReader(const std::string& filename);
- /** Returns the whole content of the file as std::string
+ /** Loads a text file from disk.
+ * @param filename The file to read into memory.
+ * @throw CoreException The file can not be loaded.
*/
- std::string Contents();
+ void Load(const std::string& filename);
- /** Returns the entire size of the file as std::string
+ /** Retrieves the entire contents of the file cache as a single string.
*/
- unsigned long ContentSize();
+ std::string GetString();
- /** Returns true if the file exists
- * This function will return false if the file could not be opened.
+ /** Retrieves the entire contents of the file cache as a vector of strings.
*/
- bool Exists();
+ const std::vector<std::string>& GetVector() { return lines; }
- /** Retrieve one line from the file.
- * This method retrieves one line from the text file. If an empty non-NULL string is returned,
- * the index was out of bounds, or the line had no data on it.
- */
- std::string GetLine(int x);
-
- /** Returns the size of the file in lines.
- * This method returns the number of lines in the read file. If it is 0, no lines have been
- * read into memory, either because the file is empty or it does not exist, or cannot be
- * opened due to permission problems.
- */
- int FileSize();
+ unsigned long TotalSize() { return totalSize; }
};
/** A list of modules