1 /*===========================================================================
2 *
3 *                            PUBLIC DOMAIN NOTICE
4 *               National Center for Biotechnology Information
5 *
6 *  This software/database is a "United States Government Work" under the
7 *  terms of the United States Copyright Act.  It was written as part of
8 *  the author's official duties as a United States Government employee and
9 *  thus cannot be copyrighted.  This software/database is freely available
10 *  to the public for use. The National Library of Medicine and the U.S.
11 *  Government have not placed any restriction on its use or reproduction.
12 *
13 *  Although all reasonable efforts have been taken to ensure the accuracy
14 *  and reliability of the software and data, the NLM and the U.S.
15 *  Government do not and cannot warrant the performance or results that
16 *  may be obtained by using this software or data. The NLM and the U.S.
17 *  Government disclaim all warranties, express or implied, including
18 *  warranties of performance, merchantability or fitness for any particular
19 *  purpose.
20 *
21 *  Please cite the author in any work or product based on this material.
22 *
23 * ===========================================================================
24 *
25 */
26 
27 #include <kfc/vers.hpp>
28 #include <kfc/callstk.hpp>
29 #include <kfc/except.hpp>
30 
31 namespace vdb3
32 {
33 
34     /*------------------------------------------------------------------
35      * vers_t
36      */
vers_t()37     vers_t :: vers_t ()
38         : val ( 0 )
39     {
40     }
41 
vers_t(U32 maj)42     vers_t :: vers_t ( U32 maj )
43         : val ( maj << 24 )
44     {
45         FUNC_ENTRY ();
46         if ( maj > 255 )
47             THROW ( xc_bounds_err, "major version = %u", maj );
48     }
49 
vers_t(U32 maj,U32 min)50     vers_t :: vers_t ( U32 maj, U32 min )
51         : val ( ( maj << 24 ) | ( min << 16 ) )
52     {
53         FUNC_ENTRY ();
54         if ( maj > 255 )
55             THROW ( xc_bounds_err, "major version = %u", maj );
56         if ( min > 255 )
57             THROW ( xc_bounds_err, "minor version = %u", min );
58     }
59 
vers_t(U32 maj,U32 min,U32 rel)60     vers_t :: vers_t ( U32 maj, U32 min, U32 rel )
61         : val ( ( maj << 24 ) | ( min << 16 ) | ( rel << 8 ) )
62     {
63         FUNC_ENTRY ();
64         if ( maj > 255 )
65             THROW ( xc_bounds_err, "major version = %u", maj );
66         if ( min > 255 )
67             THROW ( xc_bounds_err, "minor version = %u", min );
68         if ( rel > 255 )
69             THROW ( xc_bounds_err, "release component = %u", rel );
70     }
71 
vers_t(U32 maj,U32 min,U32 rel,U32 post)72     vers_t :: vers_t ( U32 maj, U32 min, U32 rel, U32 post )
73         : val ( ( maj << 24 ) | ( min << 16 ) | ( rel << 8 ) | post )
74     {
75         FUNC_ENTRY ();
76         if ( maj > 255 )
77             THROW ( xc_bounds_err, "major version = %u", maj );
78         if ( min > 255 )
79             THROW ( xc_bounds_err, "minor version = %u", min );
80         if ( rel > 255 )
81             THROW ( xc_bounds_err, "release component = %u", rel );
82         if ( post > 255 )
83             THROW ( xc_bounds_err, "post-release component = %u", post );
84     }
85 }
86