File: ByteOrder.cs

package info (click to toggle)
db5.3 5.3.28-12%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 163,332 kB
  • ctags: 82,990
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,326; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,106; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (55 lines) | stat: -rw-r--r-- 1,747 bytes parent folder | download | duplicates (8)
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
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2009, 2013 Oracle and/or its affiliates.  All rights reserved.
 *
 */
using System;
using System.Collections.Generic;
using System.Text;
using BerkeleyDB.Internal;

namespace BerkeleyDB {
    /// <summary>
    /// A class to represent the database byte order.
    /// </summary>
    public class ByteOrder {
        private int _lorder;
        internal int lorder { get { return _lorder; } }

        /// <summary>
        /// The host byte order of the machine where the Berkeley DB library was
        /// compiled.
        /// </summary>
        public static ByteOrder MACHINE = new ByteOrder(0);
        /// <summary>
        /// Little endian byte order
        /// </summary>
        public static ByteOrder LITTLE_ENDIAN = new ByteOrder(1234);
        /// <summary>
        /// Big endian byte order
        /// </summary>
        public static ByteOrder BIG_ENDIAN = new ByteOrder(4321);

        /// <summary>
        /// Convert from the integer constant used to represent byte order in 
        /// the C library to its corresponding ByteOrder object.
        /// </summary>
        /// <param name="order">The C library constant</param>
        /// <returns>
        /// The ByteOrder object corresponding to the given constant
        /// </returns>
        public static ByteOrder FromConst(int order) {
            switch (order) {
                case 0: return MACHINE;
                case 1234: return LITTLE_ENDIAN;
                case 4321: return BIG_ENDIAN;
            }
            throw new ArgumentException("Invalid byte order constant.");
        }

        private ByteOrder(int order) {
            _lorder = order;
        }
    }
}