Chinaunix首页 | 论坛 | 博客
  • 博客访问: 139571
  • 博文数量: 16
  • 博客积分: 770
  • 博客等级: 上士
  • 技术积分: 212
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-31 12:25
文章分类
文章存档

2011年(1)

2010年(10)

2009年(5)

分类: C/C++

2009-05-15 17:14:31

create_vector(int);
create_vector(signed long);
create_vector(unsigned short int);
create_vector(abc_t);
create_vector(struct _tagabc);
create_vector(list_t);
create_vector(pair_t);
create_vector(map_t>);
create_vector(hash_multimap_t>,list_t>>);
create_vector(vector_iterator_t);
create_vector(iterator_t);
create_vector(stack_t);
==========================================================================
letter : [a~zA~Z]
digit : [0~9]
identifier :
           letter | _          +---+
---->(0) -------------------> [1]<-+ letter | digit | _ | *

sign
           < | , | >
---->(0) -------------------> [1]

space : ' ' | '\t' | '\v' | '\f' | '\r' | '\n'

keyword:
char, int, short, long, float, double, signed, unsigned, char*, bool_t,
struct, enum, union,
vector_t, list_t, slist_t, deque_t, stack_t, queue_t, priority_queue_t,
set_t, map_t, multiset_t, multimap_t,
hash_set_t, hash_map_t, hash_multiset_t, hash_multimap_t,
pair_t, string_t,
iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
string_iterator_t,
input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t, random_access_iterator_t,
=============================================================================
                                    letter|digit|_
                                   +---------+
                    letter|_       |         V
                  +------------->(IN_IDENTIFIER)--------------+ [other]
                  |                                           |
------>(START)----+-------------------------------------------+---->[ACCEPT]
        |   ^                         <|,|>
        +---+
         space
=============================================================================
TYPE_DESCRIPT -> C_BUILTIN | USER_DEFINE | CSTL_BUILTIN
C_BUILTIN -> char | signed char |
             unsigned char |
             short | signed short | short int | signed short int |
             unsigned short | unsigned short int |
             int | signed | signed int |
             unsigned | unsigned int |
             long | signed long | long int | signed long int |
             unsigned long | unsigned long int |
             float |
             double |
             long double |
             char* |
             bool_t
USER_DEFINE -> USER_DEFINE_TYPE identifier | identifier
USER_DEFINE_TYPE -> struct | enum | union
CSTL_BUILTIN -> SEQUENCE | RELATION | string_t | ITERATOR
ITERATOR -> iterator_t | vector_iterator_t | list_iterator_t | slist_iterator_t | deque_iterator_t |
            set_iterator_t | map_iterator_t | multiset_iterator_t | multimap_iterator_t |
            hash_set_iterator_t | hash_map_iterator_t | hash_multiset_iterator_t | hash_multimap_iterator_t |
            string_iterator_t |
            input_iterator_t | output_iterator_t | forward_iterator_t | bidirectional_iterator_t | random_access_iterator_t
SEQUENCE -> SEQUENCE_NAME < TYPE_DESCRIPT >
SEQUENCE_NAME -> vector_t | list_t | slist_t | deque_t | queue_t | stack_t | priority_queue_t |
                 set_t | multiset_t | hash_set_t | hash_multiset_t
RELATION -> RELATION_NAME < TYPE_DESCRIPT , TYPE_DESCRIPT >
RELATION_NAME -> map_t | multimap_t | hash_map_t | hash_multimap_t | pair_t
========================================================================
C_BUILTIN -> SIMPLE_BUILTIN | SIGNED_BUILTIN | UNSIGNED_BUILTIN
SIMPLE_BUILTIN -> char | short | short int | int | long | long int |
                  float | double | long double | char*
SIGNED_BUILTIN -> signed char |
                  signed short | signed short int |
                  signed | signed int |
                  signed long | signed long int |
UNSIGNED_BUILTIN -> unsigned char |
                    unsigned short | unsigned short int |
                    unsigned | unsigned int |
                    unsigned long | unaigned long int

--------------------------------------------------------------------------------
TYPE_DESCRIPT -> C_BUILTIN | USER_DEFINE | CSTL_BUILTIN

C_BUILTIN -> SIMPLE_BUILTIN | SIGNED_BUILTIN | UNSIGNED_BUILTIN
SIMPLE_BUILTIN -> char | short COMMON_SUFFIX | int | long SIMPLE_LONG_SUFFIX | float | double | char* | bool_t
SIGNED_BUILTIN -> signed COMPLEX_SUFFIX
UNSIGNED_BUILTIN -> unsigned COMPLEX_SUFFIX
COMPLEX_SUFFIX -> {+' '}char | {+' '}short COMMON_SUFFIX | {+' '}int | {+' '}long COMMON_SUFFIX | $
COMMON_SUFFIX -> {+' '}int | $
SIMPLE_LONG_SUFFIX -> {+' '}double | COMMON_SUFFIX

USER_DEFINE -> USER_DEFINE_TYPE {+' '}identifier | identifier
USER_DEFINE_TYPE -> struct | enum | union

CSTL_BUILTIN -> SEQUENCE | RELATION | string_t | ITERATOR
ITERATOR -> iterator_t | vector_iterator_t | list_iterator_t | slist_iterator_t | deque_iterator_t |
            set_iterator_t | map_iterator_t | multiset_iterator_t | multimap_iterator_t |
            hash_set_iterator_t | hash_map_iterator_t | hash_multiset_iterator_t | hash_multimap_iterator_t |
            string_iterator_t |
            input_iterator_t | output_iterator_t | forward_iterator_t | bidirectional_iterator_t | random_access_iterator_t
SEQUENCE -> SEQUENCE_NAME < TYPE_DESCRIPT >
SEQUENCE_NAME -> vector_t | list_t | slist_t | deque_t | queue_t | stack_t | priority_queue_t |
                 set_t | multiset_t | hash_set_t | hash_multiset_t
RELATION -> RELATION_NAME < TYPE_DESCRIPT , TYPE_DESCRIPT >
RELATION_NAME -> map_t | multimap_t | hash_map_t | hash_multimap_t | pair_t
---------------------------------------------------------------------------
follow(TYPE_DESCRIPT) = {#, >, ,}

follow(C_BUILTIN) = {#, >, ,}
follow(USER_DEFINE) = {#, >, ,}
follow(CSTL_BUILTIN) = {#, >, ,}

follow(SIMPLE_BUILTIN) = {#, >, ,}
follow(SIGNED_BUILTIN) = {#, >, ,}
follow(UNSIGNED_BUILTIN) = {#, >, ,}

follow(COMPLEX_SUFFIX) = {#, >, ,}
follow(COMMON_SUFFIX) = {#, >, ,}
follow(SIMPLE_LONG_SUFFIX) = {#, >, ,}

follow(USER_DEFINE_TYPE) = {identifier}

follow(SEQUENCE) = {#, >, ,}
follow(SEQUENCE_NAME) = {<}
follow(RELATION) = {#, >, ,}
follow(RELATION_NAME) = {<}
follow(ITERATOR) = {#, >, ,}
---------------------------------------------------------------------------
first(TYPE_DESCRIPT) = {char, short, int, long, float, double, char*, bool_t, signed, unsigned,
                        struct, enum, union, identifier,
                        vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                        set_t, map_t, multiset_t, multimap_t, hash_set_t, hash_map_t, hash_multiset_t,
                        hash_multimap_t, pair_t, string_t,
                        iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
                        set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
                        hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
                        string_iterator_t,
                        input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t,
                        random_access_iterator_t}
first(C_BUILTIN) = {char, short, int, long, float, double, char*, bool_t, signed, unsigned}
first(SIMPLE_BUILTIN) = {char, short, int, long, float, double, char*, bool_t}
first(SIGNED_BUILTIN) = {signed}
first(UNSIGNED_BUILTIN) = {unsigned}
first(COMPLEX_SUFFIX) = {char, short, int, long, $}
first(COMMON_SUFFIX) = {int, $}
first(SIMPLE_LONG_SUFFIX) = {double, int, $}

first(USER_DEFINE) = {struct, enum, union, identifier}
first(USER_DEFINE_TYPE) = {struct, enum, union}

first(CSTL_BUILTIN) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                       set_t, map_t, multiset_t, multimap_t, hash_set_t, hash_map_t, hash_multiset_t,
                       hash_multimap_t, pair_t, string_t,
                       iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
                       set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
                       hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
                       string_iterator_t,
                       input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t,
                       random_access_iterator_t}
first(SEQUENCE) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                   set_t, multiset_t, hash_set_t, hash_multiset_t}
first(SEQUENCE_NAME) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                        set_t, multiset_t, hash_set_t, hash_multiset_t}
first(RELATION) = {map_t, multimap_t, hash_map_t, hash_multimap_t, pair_t}
first(RELATION_NAME) = {map_t, multimap_t, hash_map_t, hash_multimap_t, pair_t}
first(ITERATOR) = {iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
                   set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
                   hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
                   string_iterator_t,
                   input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t,
                   random_access_iterator_t}
---------------------------------------------------------------------------
select(TYPE_DESCRIPT -> C_BUILTIN) = {char, short, int, long, float, double, char*, bool_t, signed, unsigned}
select(TYPE_DESCRIPT -> USER_DEFINE) = {struct, enum, union, identifier}
select(TYPE_DESCRIPT -> CSTL_BUILTIN) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                                         set_t, map_t, multiset_t, multimap_t, hash_set_t, hash_map_t,
                                         hash_multiset_t, hash_multimap_t, pair_t, string_t,
                                         iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
                                         set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
                                         hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
                                         string_iterator_t,
                                         input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t,
                                         random_access_iterator_t}

select(C_BUILTIN -> SIMPLE_BUILTIN) = {char, short, int, long, float, double, char*, bool_t}
select(C_BUILTIN -> SIGNED_BUILTIN) = {signed}
select(C_BUILTIN -> UNSIGNED_BUILTIN) = {unsigned}

select(SIMPLE_BUILTIN -> char) = {char}
select(SIMPLE_BUILTIN -> short COMMON_SUFFIX) = {short}
select(SIMPLE_BUILTIN -> int) = {int}
select(SIMPLE_BUILTIN -> long SIMPLE_LONG_SUFFIX) = {long}
select(SIMPLE_BUILTIN -> float) = {float}
select(SIMPLE_BUILTIN -> double) = {double}
select(SIMPLE_BUILTIN -> char*) = {char*}
select(SIMPLE_BUTLIIN -> bool_t) = {bool_t}

selcet(SIGNED_BUILTIN -> signed COMPLEX_SUFFIX) = {signed}
select(UNSIGNED_BUILTIN -> unsigned COMPLEX_SUFFIX) = {unsigned}

select(COMPLEX_SUFFIX -> char) = {char}
select(COMPLEX_SUFFIX -> short COMMON_SUFFIX) = {short}
select(COMPLEX_SUFFIX -> int) = {int}
select(COMPLEX_SUFFIX -> long COMMON_SUFFIX) = {long}
select(COMPLEX_SUFFIX -> $) = {#, >, ,}

select(COMMON_SUFFIX -> int) = {int}
select(COMMON_SUFFIX -> $) = {#, >, ,}

select(SIMPLE_LONG_SUFFIX -> double) = {double}
select(SIMPLE_LONG_SUFFIX -> COMMON_SUFFIX) = {int, #, >, ,}

select(USER_DEFINE -> USER_DEFINE_TYPE identifier) = {struct, enum, union}
select(USER_DEFINE -> identifier) = {identifier}

select(USER_DEFINE_TYPE -> struct) = {struct}
select(USER_DEFINE_TYPE -> enum) = {enum}
select(USER_DEFINE_TYPE -> union) = {union}

select(CSTL_BUILTIN -> SEQUENCE) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t,
                                    set_t, multiset_t, hash_set_t, hash_multiset_t}
select(CSTL_BUILTIN -> RELATION) = {map_t, multimap_t, hash_map_t, hash_multimap_t, pair_t}
select(CSTL_BUILTIN -> ITERATOR) = {iterator_t, vector_iterator_t, list_iterator_t, slist_iterator_t, deque_iterator_t,
                                    set_iterator_t, map_iterator_t, multiset_iterator_t, multimap_iterator_t,
                                    hash_set_iterator_t, hash_map_iterator_t, hash_multiset_iterator_t, hash_multimap_iterator_t,
                                    string_iterator_t,
                                    input_iterator_t, output_iterator_t, forward_iterator_t, bidirectional_iterator_t,
                                    random_access_iterator_t}
select(CSTL_BUILTIN -> string_t) = {string_t}

select(SEQUENCE -> SEQUENCE_NAME < TYPE_DESCRIPT >) = {vector_t, list_t, slist_t, deque_t, queue_t, stack_t, priority_queue_t, set_t, multiset_t, hash_set_t, hash_multiset_t}

select(SEQUENCE_NAME -> vector_t) = {vector_t}
select(SEQUENCE_NAME -> list_t) = {list_t}
select(SEQUENCE_NAME -> slist_t) = {slist_t}
select(SEQUENCE_NAME -> deque_t) = {deque_t}
select(SEQUENCE_NAME -> queue_t) = {queue_t}
select(SEQUENCE_NAME -> stack_t) = {stack_t}
select(SEQUENCE_NAME -> priority_queue_t) = {priority_queue_t}
select(SEQUENCE_NAME -> set_t) = {set_t}
select(SEQUENCE_NAME -> multiset_t) = {multiset_t}
select(SEQUENCE_NAME -> hash_set_t) = {hash_set_t}
select(SEQUENCE_NAME -> hash_multiset_t) = {hash_multiset_t}

select(RELATION -> RELATION_NAME < TYPE_DESCRIPT , TYPE_DESCRIPT >) = {map_t, multimap_t, hash_map_t,
                                                                       hash_multimap_t, pair_t}
select(RELATION_NAME -> map_t) = {map_t}
select(RELATION_NAME -> multimap_t) = {multimap_t}
select(RELATION_NAME -> hash_map_t) = {hash_map_t}
select(RELATION_NAME -> hash_multimap_t) = {hash_multimap_t}
select(RELATION_NAME -> pair_t) = {pair_t}

select(ITERATOR -> iterator_t) = {iterator_t}
select(ITERATOR -> vector_iterator_t) = {vector_iterator_t}
select(ITERATOR -> list_iterator_t) = {list_iterator_t}
select(ITERATOR -> slist_iterator_t) = {slist_iterator_t}
select(ITERATOR -> deque_iterator_t) = {deque_iterator_t}
select(ITERATOR -> set_iterator_t) = {set_iterator_t}
select(ITERATOR -> map_iterator_t) = {map_iterator_t}
select(ITERATOR -> multiset_iterator_t) = {multiset_iterator_t}
select(ITERATOR -> multimap_iterator_t) = {multimap_iterator_t}
select(ITERATOR -> hash_set_iterator_t) = {hash_set_iterator_t}
select(ITERATOR -> hash_map_iterator_t) = {hash_map_iterator_t}
select(ITERATOR -> hash_multiset_iterator_t) = {hash_multiset_iterator_t}
select(ITERATOR -> hash_multimap_iterator_t) = {hash_multimap_iterator_t}
select(ITERATOR -> string_iterator_t) = {string_iterator_t}
select(ITERATOR -> input_iterator_t) = {input_iterator_t}
select(ITERATOR -> output_iterator_t) = {output_iterator_t}
select(ITERATOR -> forward_iterator_t) = {forward_iterator_t}
select(ITERATOR -> bidirectional_iterator_t) = {bidirectional_iterator_t}
select(ITERATOR -> random_access_iterator_t) = {random_access_iterator_t}

===============================================================================
use case

three types
c_builtin, user_define, cstl_builtin

-- register
 - register c_builtin
   type_register(c_builtin)                          X  -- c_builtin type is initialized.
 - register user_define
   type_register(struct _tagabc)                     X  -- struct _tagabc is not defined by user.
                                                     O  -- struct _tagabc is defined by user.
   type_register(abc_t)                              X  -- typedef struct _tagabc abc_t is not defined by user
                                                     O  -- typedef struct _tagabc abc_t is defined.
   *NOTE* type_register(struct _tagabc) and type_register(abc_t) is two registered type.
          please use type_register(struct _tagabc) then type_duplicated(struct _tagabc, abc_t);
 - register cstl_builtin
   type_register(vector_t)                           X -- cstl_builtin type is initialized.
   type_register(vector_t)                      X -- this type is invalid registered type.
   type_register(forward_iterator_t)                 X -- iterator type is initialized.

-- duplicate
 - duplicate c_builtin
   type_duplicate(int, myint_t) or type_duplicate(myint_t, int)  X -- typedef int myint_t is not defined or myint_t is registered as another type.
                                                                 O -- typedef int myint_t is defined and myint_t is unregisterde.
 - duplicate user_defined
   type_duplicate(struct _tagabc, abc_t)or
   type_duplicate(abc_t, struct _tagabc)                         X -- struct _tagabc and abc_t are unregistered
                                                                   -- typedef struct _tagabc abc_t is undefined
                                                                   -- struct _tagabc is registered, and abc_t is registered an other type.
                                                                 O -- typedef struct _tagabc abc_t is defined and one is registered.
                                                                   -- struct _tagabc and abc_t are registered as same type(or duplicated).
 - duplicate cstl_builtin
   type_duplicate(vector_t, myv_t) or
   type_duplicate(myv_t, vector_t)                               X -- typedef vector_t myv_t is undefined
                                                                   -- myv_t is registered as other type.
                                                                 X -- typedef vector_t myv_t is defined and myv_t is unregistered.
   *NOTE* 不允许对cstl容器类型进行重命名, except iterator_t.

-- unregistered
 - unregistered c_builtin
   type_unregistered(int)                                        X -- can't unregistered c butiltin type.
 - unregistered user_define
   type_unregistered(struct _tagabc) or
   type_unregistered(abc_t)                                      O -- unregistered type and all duplicated types.
 - unregistered cstl_builtin
   type_unregistered(vector_t) or
   type_unregistered(iterator_t)                                 X -- can't unregistered cstl builtin type.
 

-- 容器使用注册类型以vector_t为例
 - 创建容器使用用户提供的字符串来创建容器,用户提供的字符串是用来描述
   容器中保存的数据类型的:
   c_builtin
   create_vector(int);
   create_vector(unsigned long int);
   user_define
   create_vector(struct _tagabc);
   create_vector(abc_t);
   cstl_builtin
   create_vector(list_t);
   create_vector(map_t, deque_t>);
   create_vector(slist_t);
 - 字符串格式校验
   create_vector(struct                              _tagabc);
   create_vector(map_t         <         
                stack_t <    long
          double >
          ,                          deque_t<          struct _tagabc
          >>);
 - 判断容器类型相同
 - c_builtin
   vector_t == vector_t
   vector_t == vector_t    -- type_duplicate(int, myint_t)
 - user_define
   vector_t == vector_t -- type_duplicate(struct _tagabc, abc_t)
 - cstl_builtin
   vector_t> == vector_t> -- type_duplicate(struct _tagabc, abc_t)
 
e.g.
vector_t>    vector_t>
vector_t                            vector_t
list_t              list_t
list_t                              list_t
struct _tagabc                      abc_t

bool_t _type_is_same(const char* s_typename1, const char* s_typename2)
{
    char s_elemname1[_TYPE_NAME_SIZE+1];
    char s_prefix1[_TYPE_NAME_SIZE+1];
    char s_elemname2[_TYPE_NAME_SIZE+1];
    char s_prefix2[_TYPE_NAME_SIZE+1];
    char* pc_index1 = NULL;
    char* pc_leftbracket1 = NULL;
    char* pc_rightbracket1 = NULL;
    char* pc_comma1 = NULL;
    char* pc_index2 = NULL;
    char* pc_leftbracket2 = NULL;
    char* pc_rightbracket2 = NULL;
    char* pc_comma2 = NULL;

    memset(s_elemname1, '\0', _TYPE_NAME_SIZE+1);
    memset(s_elemname2, '\0', _TYPE_NAME_SIZE+1);
    memset(s_prefix1, '\0', _TYPE_NAME_SIZE+1);
    memset(s_prefix2, '\0', _TYPE_NAME_SIZE+1);
    strncpy(s_elemname1, "vector_t", _TYPE_NAME_SIZE);
    strncpy(s_elemname2, "vector_t", _TYPE_NAME_SIZE);

    do{
        pc_leftbracket1 = strchr(s_elemname1, '<');
        pc_comma1 = strchr(s_elemname1, ',');
        pc_rightbracket1 = strchr(s_elemname1, '>');
        pc_leftbracket2 = strchr(s_elemname2, '<');
        pc_comma2 = strchr(s_elemname2, ',');
        pc_rightbracket2 = strchr(s_elemname2, '>');

        if(pc_leftbracket1 != NULL)
        {
            if(pc_comma1 != NULL)
            {
                if(pc_rightbracket1 != NULL)
                {
                    pc_index1 = pc_leftbracket1 - s_elemname1 < pc_comma1 - s_elemname1 ?
                                pc_leftbracket1 - s_elemname1 < pc_rightbracket1 - s_elemname1 ?
                                pc_leftbracket1 : pc_rightbracket1 :
                                pc_comma1 - s_elemname1 < pc_rightbracket1 - s_elemname1 ?
                                pc_comma1 : pc_rightbracket1;
                }
                else
                {
                    pc_index1 = pc_leftbracket1 - s_elemname1 < pc_comma1 - s_elemname1 ?
                                pc_leftbracket1 : pc_comma1;
                }
            }
            else
            {
                if(pc_rightbracket1 != NULL)
                {
                    pc_index1 = pc_leftbracket1 - s_elemname1 < pc_rightbracket1 - s_elemname1 ?
                                pc_leftbracket1 : pc_rightbracket1;
                }
                else
                {
                    pc_index1 = pc_leftbracket1;
                }
            }
        }
        else
        {
            if(pc_comma1 != NULL)
            {
                if(pc_rightbracket1 != NULL)
                {
                    pc_index1 = pc_comma1 - s_elemname1 < pc_rightbracket1 - s_elemname1 ?
                                pc_comma1 : pc_rightbracket1;
                }
                else
                {
                    pc_index1 = pc_comma1;
                }
            }
            else
            {
                pc_index1 = pc_rightbracket1;
            }
        }

        if(pc_leftbracket2 != NULL)
        {
            if(pc_comma2 != NULL)
            {
                if(pc_rightbracket2 != NULL)
                {
                    pc_index2 = pc_leftbracket2 - s_elemname2 < pc_comma2 - s_elemname2 ?
                                pc_leftbracket2 - s_elemname2 < pc_rightbracket2 - s_elemname2 ?
                                pc_leftbracket2 : pc_rightbracket2 :
                                pc_comma2 - s_elemname2 < pc_rightbracket2 - s_elemname2 ?
                                pc_comma2 : pc_rightbracket2;
                }
                else
                {
                    pc_index2 = pc_leftbracket2 - s_elemname2 < pc_comma2 - s_elemname2 ?
                                pc_leftbracket2 : pc_comma2;
                }
            }
            else
            {
                if(pc_rightbracket2 != NULL)
                {
                    pc_index2 = pc_leftbracket2 - s_elemname2 < pc_rightbracket2 - s_elemname2 ?
                                pc_leftbracket2 : pc_rightbracket2;
                }
                else
                {
                    pc_index2 = pc_leftbracket2;
                }
            }
        }
        else
        {
            if(pc_comma2 != NULL)
            {
                if(pc_rightbracket2 != NULL)
                {
                    pc_index2 = pc_comma2 - s_elemname2 < pc_rightbracket2 - s_elemname2 ?
                                pc_comma2 : pc_rightbracket2;
                }
                else
                {
                    pc_index2 = pc_comma2;
                }
            }
            else
            {
                pc_index2 = pc_rightbracket2;
            }
        }

        if(pc_index1 != NULL && pc_index2 != NULL)
        {
            memset(s_prefix1, '\0', _TYPE_NAME_SIZE+1);
            memset(s_prefix2, '\0', _TYPE_NAME_SIZE+1);
            strncpy(s_prefix1, s_elemname1, pc_index1 - s_elemname1);
            strncpy(s_prefix2, s_elemname2, pc_index2 - s_elemname2);

            if(strncmp(s_prefix1, s_prefix2, _TYPE_NAME_SIZE) != 0)
            {
                std::cout << s_prefix1 << std::endl << s_prefix2 << std::endl;
            }

            memset(s_prefix1, '\0', _TYPE_NAME_SIZE+1);
            memset(s_prefix2, '\0', _TYPE_NAME_SIZE+1);
            strncpy(s_prefix1, pc_index1+1, _TYPE_NAME_SIZE);
            strncpy(s_prefix2, pc_index2+1, _TYPE_NAME_SIZE);
            memset(s_elemname1, '\0', _TYPE_NAME_SIZE+1);
            memset(s_elemname2, '\0', _TYPE_NAME_SIZE+1);
            strncpy(s_elemname1, s_prefix1, _TYPE_NAME_SIZE);
            strncpy(s_elemname2, s_prefix2, _TYPE_NAME_SIZE);
        }
        else
        {
            assert(pc_index1 == NULL && pc_index2 == NULL);
            if(strncmp(s_elemname1, s_elemname2, _TYPE_NAME_SIZE) != 0)
            {
                std::cout << s_elemname1 << std::endl << s_elemname2 << std::endl;
            }
        }
    }while((pc_leftbracket1 != NULL || pc_comma1 != NULL || pc_rightbracket1 != NULL) &&
           (pc_leftbracket2 != NULL || pc_comma2 != NULL || pc_rightbracket2 != NULL));

    assert(pc_leftbracket1 == NULL && pc_comma1 == NULL && pc_rightbracket1 == NULL &&
           pc_leftbracket2 == NULL && pc_comma2 == NULL && pc_rightbracket2 == NULL);
}

map_t,deque_t>        map_t,deque_t>
阅读(1442) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~