~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/metadata_ms.h

  • Committer: Mark Atwood
  • Date: 2011-12-20 02:32:53 UTC
  • mfrom: (2469.1.1 drizzle-build)
  • Revision ID: me@mark.atwood.name-20111220023253-bvu0kr14kwsdvz7g
mergeĀ lp:~brianaker/drizzle/deprecate-pbms

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase Media Stream for MySQL
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * Barry Leslie
20
 
 *
21
 
 * 2009-01-09
22
 
 *
23
 
 * H&G2JCtL
24
 
 *
25
 
 * PBMS Meta Data utilities.
26
 
 *
27
 
 */
28
 
#pragma once
29
 
#ifndef __METADATA_MS_H__
30
 
#define __METADATA_MS_H__
31
 
 
32
 
#ifdef DRIZZLED
33
 
#include <drizzled/internal/m_string.h>
34
 
#include <drizzled/charset.h>
35
 
#else
36
 
#include "m_ctype.h"
37
 
#endif
38
 
 
39
 
#include "pbmslib.h"
40
 
 
41
 
class MetaData
42
 
{
43
 
private:
44
 
        char *data;
45
 
        char *eod;
46
 
        char *position;
47
 
        
48
 
public:
49
 
        MetaData(): data(NULL), eod(NULL), position(NULL){}
50
 
        MetaData(char *meta_data, size_t meta_data_size): data(meta_data), eod(meta_data + meta_data_size), position(meta_data){}
51
 
        
52
 
        char *getBuffer() { return data;}
53
 
                
54
 
        void use_data(char *meta_data, size_t meta_data_size) 
55
 
        {
56
 
                data = meta_data;
57
 
                position = data;
58
 
                eod = data + meta_data_size;
59
 
        }
60
 
        
61
 
        void reset() 
62
 
        {
63
 
                position = data;
64
 
        }
65
 
        
66
 
        char *findNext(char **value)
67
 
        {
68
 
                char *name = position;
69
 
                if (position >= eod)
70
 
                        return NULL;
71
 
                        
72
 
                position += strlen(position) +1;
73
 
                if (position >= eod)
74
 
                        return NULL;
75
 
                        
76
 
                *value = position;
77
 
                position += strlen(position) +1;
78
 
                
79
 
                return name;
80
 
        }
81
 
        
82
 
        char *findName(const char *name)
83
 
        {
84
 
                char  *metadata = data;
85
 
                
86
 
                while (metadata < eod && my_charset_utf8_general_ci.strcasecmp(metadata, name)) {
87
 
                        metadata += strlen(metadata) +1;
88
 
                        metadata += strlen(metadata) +1;
89
 
                }
90
 
                
91
 
                if (metadata < eod)
92
 
                        return metadata + strlen(metadata) +1;
93
 
                        
94
 
                return NULL;
95
 
        }
96
 
        
97
 
        char *findNamePosition(const char *name)
98
 
        {
99
 
                char  *metadata = data;
100
 
                
101
 
                while (metadata < eod && my_charset_utf8_general_ci.strcasecmp(metadata, name)) {
102
 
                        metadata += strlen(metadata) +1;
103
 
                        metadata += strlen(metadata) +1;
104
 
                }
105
 
                
106
 
                if (metadata < eod)
107
 
                        return metadata;
108
 
                        
109
 
                return NULL;
110
 
        }
111
 
        
112
 
#ifdef HAVE_ALIAS_SUPPORT
113
 
        char *findAlias() {return findName(MS_ALIAS_TAG);}
114
 
#endif
115
 
        
116
 
        static uint32_t recSize(const char *rec) 
117
 
        { 
118
 
                uint32_t len = strlen(rec) + 1;
119
 
                
120
 
                rec += len;
121
 
                return (len + strlen(rec) + 1);
122
 
        }
123
 
        
124
 
};
125
 
#endif //__METADATA_MS_H__