~vbursian/research-assistant/intervers

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
////////////////////////////////////////////////////////////////////////////////
/*! @file Version.h   Source code version identification.
- Part of RANet - Research Assistant Net Library.
- Copyright(C) 2010-2015, Viktor E. Bursian, St.Petersburg, Russia.
                          Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef Version_H
#define Version_H
#include "Strings.h"
namespace RA {
//------------------------------------------------------------------------------

ANNOUNCE_CLASS(sVersion)

//------------------------------------------------------------------------------

namespace RANet {

  RANet_EXPORT extern sVersion const              Version;

}

//----------------------------------------------------------------- sVersion ---
/*! Source code version identification.

@todo{version} додумать и причесать, сейчас удобно, но странно:
sVerion("") != sVersion();
sVerion(1,5) == sVersion(1,5,-9,0);
sVerion(1,5,"0-alpha") > sVersion(1,5);
sVerion(1,5,"0-alpha") < sVersion(1,5,0).

*/
class RANet_EXPORT  sVersion
{
  public:
                              sVersion (sString  text);
                              sVersion (int        major_part
                                       ,int        minor_part
                                       ,rcsString  patch_and_stage
                                       ,rcsString  build_date);
                              sVersion ();
                              sVersion (int  major_part
                                       ,int  minor_part);
                              sVersion (int  major_part
                                       ,int  minor_part
                                       ,int  patch_part
                                       ,int  stage_part = 0);

  public:
                              sVersion (rcsVersion  other);
    rsVersion                 operator = (rcsVersion  other);
    sVersion                  Principal () const
                                { return sVersion(Major,Minor); }
    sVersion                  Valuable () const
                                { return sVersion(Major,Minor,Patch,Stage); }
    sString                   Text () const;
    bool                      IsValid () const;
    bool                      IsValidAndNumeric () const;

  public:
    bool                      operator == (rcsVersion) const;
    bool                      operator < (rcsVersion) const;
    bool                      operator <= (rcsVersion) const;
    bool                      operator > (rcsVersion) const;
    bool                      operator >= (rcsVersion) const;

  public://fields
    int                       Major;
    int                       Minor;
    int                       Patch;
    int                       Stage;//!< development stage
                                    //!< -9 - undefined,
                                    //!< -2 - alpha,
                                    //!< -1 - beta,
                                    //!<  0 - release.
    sString                   BuildDate;

  private:
    void                      ParsePatchAndStage (rcsString  patch_and_stage);
};

//------------------------------------------------------------------------------
} //namespace RA
#endif