Thread: Enumeration of enums. Is there a way to attain something like this.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    13

    Enumeration of enums. Is there a way to attain something like this.

    I am working on a client server based communication protocol stack.
    I have a list of errors that could occur during the course of communication
    Like,


    Code:
    Errortype        [1]
        Type1        [0]
        Type2        [1]
    
    
    Type1
        Subtype1    [0]
        Subtype2    [1]
    
    
    Type2
        Subtype3    [0]
    
    
    Subtype1
        cause1        [0]
        cause2        [1]
        cause3        [2]
    
    
    Subtype2
        cause4        [0]
    
    
    Subtype3
        cause5        [0]
        cause6        [1]
        cause7        [2]
        cause8        [3]
    So, if the server finds an error in connection due to cause7 of subtype3
    and type2, it has to send the error report as:
    Code:
    errortype          : 0x01
    Type       : 0x01
    Subtype            : 0x00
    Cause    : 0x02

    So the data transferes is 01 01 00 02


    I found that i can't have enum of enums in c++. And other suggestion I got
    was to used a 4 byte integer for the whole error structure, so that the most significant 8 bit will show errortype, the next 8bit shows type, the next shows subtype and the least significant 8 bit shows cause. Is there any better way to do it, so that the types and subtypes and cause don't get mixed up, like type2 an't have subtype1 cause1.?
    Last edited by Sajas K K; 03-18-2013 at 05:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. enums this time
    By sahilpatel_13 in forum C Programming
    Replies: 3
    Last Post: 03-11-2013, 12:14 PM
  2. Using enums in classes
    By eaane74 in forum C++ Programming
    Replies: 5
    Last Post: 12-10-2007, 03:00 PM
  3. Enums and Templates
    By einarp in forum C++ Programming
    Replies: 5
    Last Post: 07-19-2006, 05:07 AM
  4. Tricking enums
    By Ganoosh in forum C++ Programming
    Replies: 3
    Last Post: 01-07-2006, 02:46 PM
  5. enums!
    By newjamie in forum C Programming
    Replies: 1
    Last Post: 03-13-2002, 12:25 PM

Tags for this Thread