Zero-based implementation of one of the simplest database _step2:schema

Source: Internet
Author: User

When the property is done, it is in the schema. In fact, the pattern is just the encapsulation of attributes, and the robustness of the property write, the pattern will be much easier to do.

Because I am a little bit of writing code, write before also did not do too many architectural aspects (after all, small program), so there are often changes. Basically changed from Monday to today, the interface changes are not particularly much, but the implementation of the aspects of the actual setbacks.

When I write the mode, I think about the most, 2 things: 1, at the design level, what the pattern should contain (mainly attributes), what classes need to use the pattern (and how to use it), and 2, how the pattern is stored in memory, hard disk. At the earliest, I was thinking of the list in memory to maintain the properties of the pattern, that is, dynamic size, but this is obviously not necessary, after all, a pattern is basically not allowed to modify the number of properties. So it was then simply maintained in an array.

The other is how to set properties. The final version should still be in the traditional way of database instructions, such as "Create Schema ..." way, but now if you want to implement a command parser is obviously not displayed, so a temporary solution, namely setproperty (int Nprptyindex, Lzjproperty *pprpty), to a manual designation.

That's almost all, look at the code.

//mode, metadata, that is, metadata/* the structure of a meta-data on the hard disk: Part1:m_strschemanamepart2: The number of bytes in this metadata (for Part1, Part2, Part3 Plus), the number of attributes in this schema Part3:m_propertylist*/class Lzjschema{private://voidinit (DWORD Dwnumprpty);p ublic:lstringm_strschemaname;//The name of this mode//llist<lzjproperty*>m_propertylist;//the properties of the pattern. M_propertylist still save the pointer, at least not the "copy constructor, operator=" problem. Temporarily in this way, or later to change the Parsecmd dwordm_dwnumprpty;//the number of attributes in this mode ptr_lzjproperty*m_propertyarr;//[each element in this array] All point to a lzjpropertypublic:lzjschema (); Lzjschema (lstring strschemaname); ~lzjschema ();//Delete all properties in this mode Voidparsecmd (lstring *pstrcmd);//later to change to this form, That is, the schema//voidaddproperty (Lzjproperty *pprpty) is defined by the command line, and//The attribute is added to the object Voidsetnumprpty (DWORD dwnumptpy);// Sets the number of properties for this object Voidsetproperty (int nprptyindex, lzjproperty *pprpty);//Set properties of this object Lzjproperty::lp_valuetypegetprptytype ( int nprptyindex);D wordgetnumprpty ();D wordserialize (lfile *pfile);//serialization, that is: Save this object in a file Dwordunserialize (lfile *pfile) ;//deserialization, that is: Restore this object from a file Voidconsoleout (Std::ostream *pcout);}; 

  

Zero-based implementation of one of the simplest database _step2:schema

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.