Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cNetAddrList.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cNetAddrList_H
7 #define _INC_cNetAddrList_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
14 
15 namespace GrayLib
16 {
18 
20  {
24 
25  typedef cArrayStringA SUPER_t;
26 
27  protected:
29 
30  public:
31  cNetAddrList() noexcept
32  : m_nAddrCur(0)
33  {
34  }
35  cNetAddrList(const char* pszAddresses)
36  : m_nAddrCur(0)
37  {
38  put_AddrListStr(pszAddresses);
39  }
41  {
42  }
43 
44  ITERATE_t get_AddrQty() const noexcept
45  {
46  return SUPER_t::GetSize();
47  }
48  ITERATE_t get_AddrCurIndex() const noexcept
49  {
50  return m_nAddrCur;
51  }
53  {
55  return SUPER_t::GetAtCheck(i);
56  }
58  {
60  return GetAddrEnum(m_nAddrCur);
61  }
62 
64  {
65  if (IS_INDEX_BAD(i, get_AddrQty()))
66  return false;
67  m_nAddrCur = i;
68  return true;
69  }
71  {
73  return SelectAddrEnum(i % get_AddrQty());
74  }
76  {
77  return SelectAddrEnum(m_nAddrCur + 1);
78  }
79 
80  ITERATE_t AddAddress(const char* pszAddr);
81 
82  void RemoveAll()
83  {
84  m_nAddrCur = 0;
85  SUPER_t::RemoveAll();
86  }
87 
88  cStringA get_AddrListStr() const;
89  ITERATE_t put_AddrListStr(const char* pszAddrList);
90 
92  };
93 };
94 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IS_INDEX_BAD(i, q)
cast the (likely) int to unsigned to check for negatives.
Definition: Index.h:34
Definition: cNetAddrList.h:20
cStringA get_AddrCurStr() const
Definition: cNetAddrList.h:57
ITERATE_t m_nAddrCur
The current selected address. Use this one and ignore the others until needed.
Definition: cNetAddrList.h:28
cNetAddrList() noexcept
Definition: cNetAddrList.h:31
bool SelectAddrNext()
Definition: cNetAddrList.h:75
UNITTEST_FRIEND(cNetAddrList)
void RemoveAll()
Definition: cNetAddrList.h:82
bool SelectAddrEnum(ITERATE_t i)
Definition: cNetAddrList.h:63
bool SelectAddrMod(ITERATE_t i)
Definition: cNetAddrList.h:70
~cNetAddrList()
Definition: cNetAddrList.h:40
cNetAddrList(const char *pszAddresses)
Definition: cNetAddrList.h:35
ITERATE_t get_AddrCurIndex() const noexcept
Definition: cNetAddrList.h:48
cStringA GetAddrEnum(ITERATE_t i) const
Definition: cNetAddrList.h:52
ITERATE_t get_AddrQty() const noexcept
Definition: cNetAddrList.h:44
Definition: cArray.h:99
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
int ITERATE_t
like size_t but signed
Definition: Index.h:28