ZNC  trunk
Query.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2024 ZNC, see the NOTICE file for details.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZNC_QUERY_H
18 #define ZNC_QUERY_H
19 
20 #include <znc/zncconfig.h>
21 #include <znc/ZNCString.h>
22 #include <znc/Buffer.h>
23 
24 // Forward Declarations
25 class CClient;
26 class CIRCNetwork;
27 // !Forward Declarations
28 
29 class CQuery {
30  public:
31  CQuery(const CString& sName, CIRCNetwork* pNetwork);
33 
34  CQuery(const CQuery&) = delete;
35  CQuery& operator=(const CQuery&) = delete;
36 
37  // Buffer
38  const CBuffer& GetBuffer() const { return m_Buffer; }
39  unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
40  bool SetBufferCount(unsigned int u, bool bForce = false) {
41  return m_Buffer.SetLineCount(u, bForce);
42  }
43  size_t AddBuffer(const CMessage& Format, const CString& sText = "") {
44  return m_Buffer.AddLine(Format, sText);
45  }
47  size_t AddBuffer(const CString& sFormat, const CString& sText = "",
48  const timeval* ts = nullptr,
49  const MCString& mssTags = MCString::EmptyMap) {
50  return m_Buffer.AddLine(sFormat, sText, ts, mssTags);
51  }
52  void ClearBuffer() { m_Buffer.Clear(); }
53  void SendBuffer(CClient* pClient);
54  void SendBuffer(CClient* pClient, const CBuffer& Buffer);
55  // !Buffer
56 
57  // Getters
58  const CString& GetName() const { return m_sName; }
59  // !Getters
60 
61  private:
62  CString m_sName;
63  CIRCNetwork* m_pNetwork;
64  CBuffer m_Buffer;
65 };
66 
67 #endif // !ZNC_QUERY_H
Definition: Buffer.h:74
bool SetLineCount(unsigned int u, bool bForce=false)
size_type AddLine(const CMessage &Format, const CString &sText="")
unsigned int GetLineCount() const
Definition: Buffer.h:107
void Clear()
Definition: Buffer.h:100
Definition: Client.h:99
Definition: IRCNetwork.h:40
Here is a small explanation of how messages on IRC work, and how you can use this class to get useful...
Definition: Message.h:57
Definition: Query.h:29
bool SetBufferCount(unsigned int u, bool bForce=false)
Definition: Query.h:40
size_t AddBuffer(const CString &sFormat, const CString &sText="", const timeval *ts=nullptr, const MCString &mssTags=MCString::EmptyMap)
Definition: Query.h:47
CQuery & operator=(const CQuery &)=delete
void SendBuffer(CClient *pClient, const CBuffer &Buffer)
void SendBuffer(CClient *pClient)
void ClearBuffer()
Definition: Query.h:52
CQuery(const CString &sName, CIRCNetwork *pNetwork)
unsigned int GetBufferCount() const
Definition: Query.h:39
size_t AddBuffer(const CMessage &Format, const CString &sText="")
Definition: Query.h:43
const CBuffer & GetBuffer() const
Definition: Query.h:38
CQuery(const CQuery &)=delete
const CString & GetName() const
Definition: Query.h:58
String class that is used inside ZNC.
Definition: ZNCString.h:68
A dictionary for strings.
Definition: ZNCString.h:595
static const MCString EmptyMap
A static instance of an empty map.
Definition: ZNCString.h:606