Exemplo n.º 1
0
 public Request(String realm, indexType indexType, String IndexName)
     : this()
 {
     this.realm     = realm;
     this.indexType = indexType;
     this.IndexName = IndexName;
 }
Exemplo n.º 2
0
        public static Session login(String realm, indexType indexType, String IndexName, Callback[] callbacks)
        {
            Request request = new Request(Auth.Get(new auth.Request(realm, indexType, IndexName)));

            request.callbacks.Clear();
            request.callbacks.AddRange(callbacks);

            Response response = Auth.Get(request);

            if (response.exception != null)
            {
                throw response.exception;
            }
            return(new Session(response));
        }
Exemplo n.º 3
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field      = index.ReferenceField;
            var fieldType  = FieldType(field);
            var sortByType = FieldType(index.SortingField);

            if (index.SortingField.type == typeType.@string)
            {
                sortByType = "const " + sortByType + "&";
            }

            IncludeWriter.WriteLine(
                @"        // Note: indexes are built during the build process, and aren't available before
        std::vector<{2}*> {0}List();
        {2}& get{1}(int index);
        int {0}Count() const;
        {2}* search{1}({3} item);
        {2}* search{1}({3} item, int min, int max);
"
                , index.name, index.name.Capitalize(), fieldType, sortByType);

            CppWriter.WriteLine(
                @"        std::vector<{3}*> Abstract{4}::{0}List()
        {{
            assert((""Index is not built yet!"", isBuilt()));

            auto count = {0}Count();
            auto list = std::vector<{3}*>();
            list.reserve(count);
            for (auto i = 0; i < count; ++i)
            {{
                list.push_back(&get{1}(i));
            }}
            return list;
        }}

        {3}& Abstract{4}::get{1}(int index)
        {{
            assert((""Index is not built yet!"", isBuilt()));
            return *dynamic_cast<{3}*>(getRoot()->decode(m_header.{2}(index)));
        }}

        int Abstract{4}::{0}Count() const
        {{
            assert((""Index is not built yet!"", isBuilt()));
            return m_header.{2}_size();
        }}

        {3}* Abstract{4}::search{1}({5} item)
        {{
            assert((""Index is not built yet!"", isBuilt()));

            // note: we don't use std::find so that 
            // we decode a minimum number of items
            return search{1}(item, 0, {0}Count() - 1);
        }}

        {3}* Abstract{4}::search{1}({5} item, int min, int max)
        {{
            assert((""Index is not built yet!"", isBuilt()));

            if (max < min)
                return nullptr;

            int avg = (min + max) >> 1;

            auto& candidate = get{1}(avg);
            {5} candidateKey = candidate.{6}();
            if (candidateKey == item)
                return &candidate;

            if (candidateKey < item)
                return search{1}(item, avg + 1, max);

            return search{1}(item, min, avg - 1);
        }}
"
                , index.name, index.name.Capitalize(), index.name.ToLowerInvariant(), fieldType, message.name, sortByType, index.sortBy);
        }
Exemplo n.º 4
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field = index.ReferenceField;
            var fieldType = FieldType(field);
            var sortByType = FieldType(index.SortingField);
            if (index.SortingField.type == typeType.@string)
                sortByType = "const " + sortByType + "&";

            IncludeWriter.WriteLine(
@"        // Note: indexes are built during the build process, and aren't available before
        std::vector<{2}*> {0}List();
        {2}& get{1}(int index);
        int {0}Count() const;
        {2}* search{1}({3} item);
        {2}* search{1}({3} item, int min, int max);
"
                , index.name, index.name.Capitalize(), fieldType, sortByType);

            CppWriter.WriteLine(
@"        std::vector<{3}*> Abstract{4}::{0}List()
        {{
            assert((""Index is not built yet!"", isBuilt()));

            auto count = {0}Count();
            auto list = std::vector<{3}*>();
            list.reserve(count);
            for (auto i = 0; i < count; ++i)
            {{
                list.push_back(&get{1}(i));
            }}
            return list;
        }}

        {3}& Abstract{4}::get{1}(int index)
        {{
            assert((""Index is not built yet!"", isBuilt()));
            return *dynamic_cast<{3}*>(getRoot()->decode(m_header.{2}(index)));
        }}

        int Abstract{4}::{0}Count() const
        {{
            assert((""Index is not built yet!"", isBuilt()));
            return m_header.{2}_size();
        }}

        {3}* Abstract{4}::search{1}({5} item)
        {{
            assert((""Index is not built yet!"", isBuilt()));

            // note: we don't use std::find so that 
            // we decode a minimum number of items
            return search{1}(item, 0, {0}Count() - 1);
        }}

        {3}* Abstract{4}::search{1}({5} item, int min, int max)
        {{
            assert((""Index is not built yet!"", isBuilt()));

            if (max < min)
                return nullptr;

            int avg = (min + max) >> 1;

            auto& candidate = get{1}(avg);
            {5} candidateKey = candidate.{6}();
            if (candidateKey == item)
                return &candidate;

            if (candidateKey < item)
                return search{1}(item, avg + 1, max);

            return search{1}(item, min, avg - 1);
        }}
"
                , index.name, index.name.Capitalize(), index.name.ToLowerInvariant(), fieldType, message.name, sortByType, index.sortBy);
        }
Exemplo n.º 5
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field      = index.ReferenceField;
            var fieldType  = FieldType(field);
            var sortByType = FieldType(index.SortingField);

            Writer.WriteLine(
                @"        /// <summary>
        /// {4}
        /// </summary>
        public IEnumerable<{1}> {0}List
        {{
            get
            {{
                Debug.Assert(IsBuilt, ""Index is not built yet!"");
                return Enumerable.Range(0, {0}Count).Select(Get{0});
            }}
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public {1} Get{0}(int index)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");
            return ({1})Root.Decode(_header.Get{0}(index));
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public int {0}Count
        {{
            get
            {{
                Debug.Assert(IsBuilt, ""Index is not built yet!"");
                return _header.{0}Count;
            }}
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public {1} Search{0}({2} item)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");
            return Search{0}(item, 0, {0}Count - 1);
        }}

        /// <summary>
        /// {4}
        /// </summary>
        protected {1} Search{0}({2} item, int min, int max)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");

            if (max < min)
                return null;

            int avg = (min + max) >> 1;

            var candidate = Get{0}(avg);
            var candidateKey = candidate.{3};
            if (candidateKey == item)
                return candidate;

            if (candidateKey < item)
                return Search{0}(item, avg + 1, max);

            return Search{0}(item, min, avg - 1);
        }}
", index.name.Capitalize(), fieldType, sortByType, index.sortBy.Capitalize(), index.description.Safe());
        }
Exemplo n.º 6
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field = index.ReferenceField;
            var fieldType = FieldType(field);
            var sortByType = FieldType(index.SortingField);

            Writer.WriteLine(
@"        /// <summary>
        /// {4}
        /// </summary>
        public IEnumerable<{1}> {0}List
        {{
            get
            {{
                Debug.Assert(IsBuilt, ""Index is not built yet!"");
                return Enumerable.Range(0, {0}Count).Select(Get{0});
            }}
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public {1} Get{0}(int index)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");
            return ({1})Root.Decode(_header.Get{0}(index));
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public int {0}Count
        {{
            get
            {{
                Debug.Assert(IsBuilt, ""Index is not built yet!"");
                return _header.{0}Count;
            }}
        }}

        /// <summary>
        /// {4}
        /// </summary>
        public {1} Search{0}({2} item)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");
            return Search{0}(item, 0, {0}Count - 1);
        }}

        /// <summary>
        /// {4}
        /// </summary>
        protected {1} Search{0}({2} item, int min, int max)
        {{
            Debug.Assert(IsBuilt, ""Index is not built yet!"");

            if (max < min)
                return null;

            int avg = (min + max) >> 1;

            var candidate = Get{0}(avg);
            var candidateKey = candidate.{3};
            if (candidateKey == item)
                return candidate;

            if (candidateKey < item)
                return Search{0}(item, avg + 1, max);

            return Search{0}(item, min, avg - 1);
        }}
", index.name.Capitalize(), fieldType, sortByType, index.sortBy.Capitalize(), index.description.Safe());
        }
 protected abstract void GenerateClassIndex(messageType message, indexType index);
Exemplo n.º 8
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field = index.ReferenceField;
            var fieldType = FieldType(field);
            var sortByType = FieldType(index.SortingField);

            Writer.WriteLine(
@"        // Note: indexes are built during the build process, and aren't available before
        /**
        * {4}
        **/
        public List<{1}> get{0}List()
        {{
            assert isBuilt() : ""Index is not built yet!"";

            List<{1}> list = new ArrayList<{1}>();
            int count = get{0}Count();
            for(int i = 0; i < count; i++)
            {{
                list.add(get{0}(i));
            }}
            return list;
        }}

        /**
        * {4}
        **/
        public {1} get{0}(int index)
        {{
            assert isBuilt() : ""Index is not built yet!"";
            return ({1})getRoot().decode(_header.get{0}(index));
        }}

        /**
        * {4}
        **/
        public int get{0}Count()
        {{
            assert isBuilt() : ""Index is not built yet!"";
            return _header.get{0}Count();
        }}

        /**
        * {4}
        **/
        public {1} search{0}({2} item)
        {{
            assert isBuilt() : ""Index is not built yet!"";

            // note: we don't use std::find so that 
            // we decode a minimum number of items
            return search{0}(item, 0, get{0}Count() - 1);
        }}

        /**
        * {4}
        **/
        protected {1} search{0}({2} item, int min, int max)
        {{
            assert isBuilt() : ""Index is not built yet!"";

            if (max < min)
                return null;

            int avg = (min + max) >> 1;

            {1} candidate = get{0}(avg);
            {2} candidateKey = candidate.get{3}();
            if (candidateKey == item)
                return candidate;

            if (candidateKey < item)
                return search{0}(item, avg + 1, max);

            return search{0}(item, min, avg - 1);
        }}
"
                , index.name.Capitalize()
                , fieldType
                , sortByType
                , index.sortBy.Capitalize()
                , index.description.Safe()
                );
        }
Exemplo n.º 9
0
        protected override void GenerateClassIndex(messageType message, indexType index)
        {
            // indexes are build at build time
            var field      = index.ReferenceField;
            var fieldType  = FieldType(field);
            var sortByType = FieldType(index.SortingField);

            Writer.WriteLine(
                @"        // Note: indexes are built during the build process, and aren't available before
        /**
        * {4}
        **/
        public List<{1}> get{0}List()
        {{
            assert isBuilt() : ""Index is not built yet!"";

            List<{1}> list = new ArrayList<{1}>();
            int count = get{0}Count();
            for(int i = 0; i < count; i++)
            {{
                list.add(get{0}(i));
            }}
            return list;
        }}

        /**
        * {4}
        **/
        public {1} get{0}(int index)
        {{
            assert isBuilt() : ""Index is not built yet!"";
            return ({1})getRoot().decode(_header.get{0}(index));
        }}

        /**
        * {4}
        **/
        public int get{0}Count()
        {{
            assert isBuilt() : ""Index is not built yet!"";
            return _header.get{0}Count();
        }}

        /**
        * {4}
        **/
        public {1} search{0}({2} item)
        {{
            assert isBuilt() : ""Index is not built yet!"";

            // note: we don't use std::find so that 
            // we decode a minimum number of items
            return search{0}(item, 0, get{0}Count() - 1);
        }}

        /**
        * {4}
        **/
        protected {1} search{0}({2} item, int min, int max)
        {{
            assert isBuilt() : ""Index is not built yet!"";

            if (max < min)
                return null;

            int avg = (min + max) >> 1;

            {1} candidate = get{0}(avg);
            {2} candidateKey = candidate.get{3}();
            if (candidateKey == item)
                return candidate;

            if (candidateKey < item)
                return search{0}(item, avg + 1, max);

            return search{0}(item, min, avg - 1);
        }}
"
                , index.name.Capitalize()
                , fieldType
                , sortByType
                , index.sortBy.Capitalize()
                , index.description.Safe()
                );
        }
Exemplo n.º 10
0
 protected abstract void GenerateClassIndex(messageType message, indexType index);