-
Notifications
You must be signed in to change notification settings - Fork 0
/
endereco.h
61 lines (53 loc) · 1.79 KB
/
endereco.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef ENDERECO_H
#define ENDERECO_H
#include "QList"
#include "utilitarios.h"
#include "math.h"
#include <QRegExpValidator>
namespace dnn {
class Endereco
{
private:
QString mascara;
QChar classe;
QList<int> octetosEndereco;
QList<Endereco*> subRedes;
int qtdSubRedes;
int qtdHosts;
Endereco* primeiroHost;
Endereco* ultimoHost;
Endereco* subRedeAtual;
Endereco* subRedeBroadcast;
bool validaEndereco(QString endereco, QList<int> &listaOctetos) const;
void validaMascara(QString &mascara);
void validaClasse();
void setSubRedeAtual();
void setSubRedePrimeiroHost();
void setSubRedeUltimoHost();
void setSubRedeBroadcast();
void setQtdeHosts();
void setqtdeSubRedes();
void setSubRede(Endereco *subRede){subRedes.push_back(subRede);}
public:
Endereco(QString endereco, QString mascara);
~Endereco();
QString getEndereco() const;
QString getEnderecoBin() const;
QString getMascara() const{return mascara;}
QString getMascaraBin()const;
QChar getClasse() const{return classe;}
Endereco* getSubRedeAtual();
Endereco* getSubRedePrimeiroHost();
Endereco* getSubRedeUltimoHost();
Endereco* getSubRedeBroadcast();
int getQuantidadeHosts()const{return qtdHosts;}
QList<Endereco*>* getSubredes()const;
QString maskConvertCIDRToDottedDecimal() const;
QString maskConvertDottedDecimalToCIDR() const;
bool ehCIDR(QString mascara)const;
int getQtdeSubRedes(){return qtdSubRedes;}
void preencherSubRedes(int n);
bool possuiSubRedes()const{return (qtdSubRedes == 1) ? false : true;}
};
}
#endif // ENDERECO_H