MSDN에 Serializable클래스를 만드는 방법을 단계로 소개 하고 있다(클릭하면 사이트이동)
주요부분을 간단히 요약하면…..
1. Cobject에서 파생된 클래스를 만든다
2. Serialize 멤버 함수를 재정의 한다.
3. 클래스에 DECLARE_SERIAL 매크로를 선언 한다(“.h”파일).
4. 구현 파일에(.cpp)에 IMPLEMENT_SERIAL 매크로를 지정한다.
class CPerson : public CObject { public: DECLARE_SERIAL( CPerson ) // empty constructor is necessary CPerson(); virtual ~CPerson(); CString m_name; WORD m_number; void Serialize( CArchive& archive ); };
Serialize 멤버 함수를 재정의 하려면
- 기본 클래스 버전을 호출 합니다. Serialize 개체의 상속 된 부분이 serialize 될 수 있도록 합니다.
- 삽입 또는 클래스에 특정 멤버 변수에서 추출 합니다.삽입 및 추출 연산자는 데이터 읽기 및 쓰기에 보관 클래스와 상호 작용 합니다.
다음 예제에서는 구현 하는 방법을 보여 줍니다. Serialize에 CPerson 클래스 선언 위에서:CPP File의 Serialize멤버 함수 재정의void CPerson::Serialize( CArchive& archive ) { // call base class function first // base class is CObject in this case CObject::Serialize( archive ); // now do the stuff for our specific class if( archive.IsStoring() ) archive << m_name << m_number; else archive >> m_name >> m_number; }
DECLARE_SERIAL 매크로 serialization을 지 원하는 클래스의 선언에 필요한 다음과 같은:
head Fileclass CPerson : public CObject { public: DECLARE_SERIAL( CPerson )
Cpp 파일에 IMPLEMENT_SERIAL 매크로 지정처음 두 개의 인수에 매크로 해당 직접 기본 클래스의 이름과 클래스의 이름입니다.
이 매크로 세 번째 인수는 스키마 번호입니다. 스키마 개체 클래스에 대 한 버전 번호입니다.
스키마 번호는 0 보다 크거나 같은 정수를 사용 합니다. (이 스키마 번호 데이터베이스 용어와 혼동 하지 마십시오.)
MFC serialization 코드는 메모리에 개체를 읽을 때 스키마 번호를 확인 합니다.
스키마 번호 디스크 개체의 메모리에 있는 클래스 스키마 수가 일치 하지 않으면, 라이브러리 throw 합니다
CArchiveException, 프로그램이 잘못 된 버전의 개체를 읽는 것을 방지 합니다.
원하는 경우에 Serialize 멤버 함수의 여러 버전을 읽을 수 있도록 — 응용 프로그램의 다른 버전으로 작성 된 파일-값을 사용할 수 있습니다VERSIONABLE_SCHEMA 인수로 IMPLEMENT_SERIAL 매크로. 사용 정보 및 예제에 대 한 참조를 GetObjectSchema 클래스의 멤버 함수 CArchive.
다음 예제에서는 사용 하는 방법을 보여 줍니다. IMPLEMENT_SERIAL 클래스인 CPerson, 즉 파생 CObject:Cpp 파일 상단IMPLEMENT_SERIAL( CPerson, CObject, 1 )
Serializable 클래스를 이용한 가변배열 저장하고 불러오기
일반적으로 정형화되어 있는 Docuemt의 경우 또는 크기자 적은 파일의 경우 Serializable 클래스를 사용하지 않고서 작업하는 경우가 있다.
예를 들어 DB를 사용하는 경우라면 Serialize를 사용하지 않는 경우도 있다.
그러나 동적 배열을 사용하는 경우는 Serialize를 구현하지 않으면 거의 작업이 불가능하다.
CListCtrl,CTreeCtrl의 경우를 생각해보자, 이들은 저장해야 하는 Item이 가변적이므로 Item의 수 모두를 저장하고 불러올 수 있어야 한다.
다행하게도 이들 클래스는 Serializable이 구현되어 있으므로 그대로 사용하면 된다.
다음의 예를 살펴보자 Serialization을 수행할 때 문제가 될 부분이 있다
head 파일 예)class SaveFile :public CObject { DECLARE_SERIAL(SaveFile) public: SaveFile(void); public: SaveFile(SaveFile &Sv) { *this=Sv; } public: ~SaveFile(void); public : CString FName; public: char *FData; public : ULONGLONG MySize; public: virtual void Serialize(CArchive &pArchive); public: SaveFile& operator=(SaveFile & SvFi); };
CPP 파일(잘못된 경우)
void SaveFile::Serialize(CArchive & pArchive) { CObject::Serialize(pArchive); if(pArchive.IsStoring()) { pArchive<<FName<<MySize<<FData; } else { pArchive>>FName>>MySize>>FData; } }
위의 경우에서 FData의 처리부분에서 문제가 발생한다.
자세히 살펴보면 FData는 문자열 Point로 선언되어 있으므로 메모리의 주소만 저장하고 실제 Data는 저장되지 않는다.
이와 유사하게 직접 만든 클래스,혹은 Struct의 경우 CArray<SaveFile*, SaveFile*> SF; 와 같은 형태로 동적으로 조작할 목적으로 설계 되었다면
심각한 문제를 일으킨다. 어플리케이션이 종료되면 메모리가 해제 되기 때문에 파일을 읽어서 메모리 주소는 아무 쓸모가 없어진다.
정상적으로 동작하려면 아래와 같이 코딩 되어야 한다.
void SaveFile::Serialize(CArchive & pArchive) { CObject::Serialize(pArchive); if(pArchive.IsStoring()) { pArchive<<FName<<MySize; for(int i=0;i<MySize;i++) { pArchive<<FData[i]; } } else { pArchive>>FName>>MySize; FData=new char[MySize]; for(int i=0;i<MySize;i++) { pArchive>>FData[i]; } } }
g could
g https://tinyurl.com/rsacwgxy
http://tinyurl.com/cbd-oil-that-works-2020
tinyurl.com
cbd oil that works 2020
cbd oil that works 2020
Raina Muldrow
viagra buy singapore
cbd for anxiety
John Deere Service Manuals
how much do security screens cost
imp source
cbd. 0.3 thc hemp flowers for sale in calloway county ky
test pot for content thc ,cbd ect for sale
will smoking cbd give my dog a seizure
dog tags with cbd tags
benefits of cooking with cbd oil
potions one 1:1 cbd capsules
visit our website
have a peek at this website
Google
Google
webhosting
situs judi online bwinbet365
situs judi resmi
musafirdigital
dewajudiqq
pokerpelangi
mandiriqq
dingdongtogel
daftar dingdong togel casino
microgaming slot
judi deposit pulsa
deposit poker pulsa
dingdongtogel
wap togel
dingdong togel daftar
joker123 pulsa
togel wap hk
dingdong togel
dingdong 42d
dingdong casino togel
Dorotha Dehan
66.42.58.199
Download PUBG Mobile 2020
139.180.185.166
Sbobet999 Slot
Sbobet777 Indonesia
Firmanrahman
sgp totobet
totobet hk
totobet login
togel
Sertifikat SMK3
bali private car charter
Kriteria Audit SMK3
SMK3 Perusahaan
one punch man manga online
Reza Lukmana Youtube
resep pasta spaghetti
sbobet777 login
sbobet777
kaldu sapi bubuk
lo de online 188 loto
trang soi cau 188 loto
trang lo de k8loto
lo de online the thao bet
trang soi cau thethaobet
danh de online uy tin k8loto
trang du doan xsmb 188xoso
soi cau thethaobet
soi cau xsmb k8loto
joker123 login
cara daftar joker123
Slot Pulsa Online
Daftar Slot Online Terpercaya
Daftar Situs Judi Slot Online Terpercaya
Slot Online Deposit Pulsa
poker88
download joker123 apk
joker slot apk
idn poker asia 88
download poker88
pop over to these guys
joker123 download
joker apk
login joker123
Situs Domino99 Online
Bandar Dominoqq Online
QQ Online
cara menghilangkan energi negatif dalam tubuh
aplikasi joker123
cara membuat blog
paragonpoker
Judi Slot
mybestpoker
poker88 download
idn poker 88
poker 88 idn
situs judi bola
import barang dari china
Aplikasi kesehatan Android
rumus lightroom
cara membuat blog di blogger
jagad poker
cover lagu dangdut terbaru
dominoqq terbaik
Kayak Storage Ideas
dingdong casino online
dingdong 34d
agen bola
kelasjudi.net
daftar di bwinbet365
s1288
s128apk
download sabung ayam s128
bwinbet365
s128 live
s128
kings128
s128
s1288
Juara Liga Champion
Domino99 Online
ituPoker
daftar pokerqq
Idn Poker Play
Sbobet365 Bola
you could check here
sbobet88 bola
Sbobet88 Slot
jago s128
s1288
sabung ayam s128
agen bet88
Bet88 Online
s128
jago s128
sabung ayam online s128
s128
s12888
s128h.com
cheap face masks
Situs Bandarq
Agen Casino Online
Situs Judi Online
Judi Poker Online
Agen Aduq Online
situs Judi Online
Casino Online
Prediksi Togel Agogo4D
judi bola terpercaya
Agen Poker
Prediksi Togel China
http://senangdominopkv.com/
http://senangdomino.in/
http://180.215.15.98
http://99bandarqiuqiu.com/
http://69.16.212.126
s128 sabung ayam
s1288
sabung ayam s128
s128.apk
download s1288
link alternatif s128
game slot online
king4d
cara daftar sv388
judi slot online
alternatif login totobet
slot deposit pulsa
login totobet
slot deposit pulsa 10rb
daftar totobet online
daftar totobet online
segarqq
Pkv Games
situs dominobet online
Situs Judi Online
situs bandarq online
www.doktercash.com
Mega Bandar
csn
webdewaqq
https://solusiponsel.com/
Ulatmovie.com
https://asikdewapoker.com/
qbesar
dominobetqq
https://sosbobet.cc/
kamera4d
elevenconsignment.com
download free epub books online
Kursus Bahasa Inggris Batam
visit here
rezgamer
togel online indonesia
link totobet
totobet hk
m11hkb.com
ding dong togel
togel dingdong
http://www.kamera4d.org/
s12888
s1281
susupoker
pokerace99
resep masakanku
indodewa99
mystargarden
Judi Bola Joinpoker.com
QQ77Bet
dingdong togel online
vivo slot
joker888
joker388
joker 128
joker 123
joker188.net
s1288
view it now
sbobet88.com
idnplay
judionline
idnpoker
pragmaticplay
judionline
idn poker 88
osg777
joker123
fafa slot
Kertas puyer berlogo
joker123.net
slotjoker
joker123
joker123 slot
joker123 net
joker123 slot
slot joker123 online
joker 123 slot
slot joker123 online
joker slot
slot joker123
try this out
solveclimbing.com
http://69.197.149.68/
ebolafc.net
best printer
Samsung Printer
Canon Printer
khazanahpromosi
Furniture Jepara
Sofa Sudut L
website ini
baca selengkapnya
Lemari Pajangan
Sallyponchak.com
https://ponseloka.com
Aplikasidewasa.com
https://sahabatqq.mobi/
damandiri.com
https://pokerpelangi1.link/
situs qbesar
levidio.musafirdigital.com
https://thompson2009.com/
https://charlesforboston.com/
https://ardusat.org/
https://dominoqqmu.com/
agen joker388 online
jokerwin 123
joker888
agen joker123
my response
sbobet
install joker123 apk
joker 123 apk
link joker123
jokerwin123 login
sbobet daftar
sbobet bola
sbobet88 daftar
안전토토
Google
http://103.194.171.205/
http://107.152.32.187/
https://hermes21.net/
www.masterhoki.com
sneak a peek at this site
american airlines
https://hermes21.net/
http://103.194.171.205/
http://107.152.32.187/
안전토토
안전놀이터
best phone sex
view website
Jadiel Rivas
Google
BhataraMedia.com
SSH SSL
https://mpocasino.com
Free Softether
https://157.245.145.0
https://165.22.245.200
contoh surat
Printable Worksheets
Pkv Games QQ
daftar situs judi slot online terpercaya
Panduan Menanam Hidroponik
dewa99
agen poker online
situs judi online
poker online
live sabung ayam
daftar akun s128
s128 login
sabung ayam s1288
s128 deposit pulsa
s1288 sabung ayam
judi sabung ayam online
link alternatif joker123
daftar sabung ayam online
joker123 daftar
bandar ceme
download joker123
agen bandar togel terpercaya
idn casino
affordable rental homes near me
privately owned homes for rent
sears credit card login
houses to rent by private landlords
wshh mobile
Amira Burkart
http://202.182.119.182/
http://66.42.50.255/
qqgalaxyus
sistem pemerintahan orde lama dan orde baru
waheedbaly
http://45.76.157.60/
pulau tidung dino
aduq online
idn poker
https://www.oregonwave.org/
Cecil Playl
situs togel terpercaya
situs poker online
situs poker online
situs poker online
situs judi online
judi online terpercaya
PULSA ONLINE
mesin mati xiaomi
jual webbing sling
electric chain hoist
daftar agen pulsa
daftar agen pulsa resmi
service lcd iphone
Ping Schroth
Learnerships 2021
daftar agen pulsa
electric chain hoist
judi bandarq
situs judi online
login langitqq
judi online
bandarq
situs dominoqq
bandarq
situs poker online
langitqq login
istanaqq
Elsa Schnepel
login joker123
pkv games
judi online
bandarqq
situs poker online
situs judi qq
situs judi online
Judi Slot Online
Wedesini
motorcycle accident law firm
Slot Online
Slot Online
rfp consultant
judisbo
doatogel
langitqq
wiki 4d
doacasino
qbesar
paten99.cc
langitqq
qkecil
qbesar
qbesar
Paket Aqiqah Murah Bekasi
qkecil
qbesar
agen judi pulsa
deposit poker pulsa
permainan microgaming slot
deposit pulsa
joker123
judi poker pulsa
judi pulsa
situs judi bola terpercaya
download sv388 apk
jokerslot
sv388 apk
joker123
slot online terpercaya
idnplay poker
aqiqah jakarta timur
idn poker com
idn poker 88
judi slot online terbaru
download sv388 apk
s128 online
sv388 sabung ayam
cara daftar sv388
s128 daftar
cara download sv388
aplikasi s128
s1288
situs s128
s128 daftar
joker slot 123
s128
mod apk
download s128 apk
Bandarqq
taruhan bola online
Situs Judi Bandarqq
situs bola
situs bola
Situs Judi Bandarqq
gtekno
Judi Bandarqq
situs judi online
suzuki ertiga
umi marfa
Bandarqq
Situs Judi Bandarqq
slot deposit pulsa
idn poker 88
slot deposit pulsa terpercaya
login idn poker
netflix gratisan
sbobet88
sabung ayam online terbaik
sbobet88 daftar
sbobet indonesia
agen sabung ayam online
sbobet indonesia
login sbobet 88
judi slot pulsa
situs slot online terbaru
slot online indonesia
slot online
daftar slot online pragmatic
agen poker idn poker online
agen slot online terpercaya
idnplay poker
idn poker
daftar agen slot online
idn poker terbaru
poker idn play
poker online idn
idn poker login idnplay
login pkv games
BukuMasakan.com
klik website kristalpkv
Arespedia.com
white charcoal
idn play login
phonesable.com
zadulqq
http://195.154.113.104
tukangkatakata.com
signal forex
gomunime
Judi Bola online terpercaya
Login terimaqq
judi online24 jam terpercaya 2020
Maxbet Falmouthheritagewalks
Terimaqq
Terimaqq
judi online24 jam terpercaya 2020
Judi Bola online terpercaya
simpatiqq
Bandar Bola Online
togel singapore
film online
situs judi poker
bigosport
dewatogel
togel singapore
judi poker domino online
parenting blogs
agen dominoqq terpercaya
judi poker online
Bunda.co
domino poker online
judi online terpercaya
judi domino online
MakmurQQ
parenting website
judi poker online
domino poker online
Bunda.co
situs judi online
klinik kelamin
anak senja
penyakit kelamin
klinik
kumpulan syair togel
https://www.macauslot188.com
situs qq online terbaru
slot online
pkv
poker224pkv.com
poker online
www.webrajapoker88.com
judi casino online
judi poker
situs judi online terpercaya
situs casino online
situs judi online
judi poker bandarq
dominoqq bandarq online
agen sbobet
situs pkv games
situs judi bola terpercaya
judi bola
agen bola
sbobet
joker888.net
joker388.net
joker123.net
joker 388
sv 388
sv 388
Judi Poker Online
Terimaqq
Situs QQ Online
Pkv Games
sbobet
idnpoker
idn play
does rimadyl work with cbd oil for dogs?
joker123 apk
download idn poker
daftar joker123
mobile sbobet
slot pulsa
login sbobet
deposit slot pulsa
judi depsoit pulsa
win money today free
Judi Bandarqq
poker idn
garden parasol
Bandarqq
Bandarqq
fafaslot.net
Matthewobliz
cbd oil for pain relief
idnplay download
download apk idn poker
link alternatif poker88
poker 88 online
idn poker apk
apk poker88
agen sv288
daftar akun sv288
sv388 daftar
sv388 agent
cara download joker123
slot vivo
konveksi seragam kerja
https://www.88agen.net
deposit pulsa slot tanpa potongan
harga tanah surabaya
judi depsoit pulsa
jual rumah sukodono sidoarjo
jual gudang surabaya
https://www.88agen.net
daftar harga tanah surabaya
Situs Judi Bola Online
slot online pragmatic
judi bola online
Bandar Bola Online
Belajar forex
casino online terbaik
situs qq online
pkv games
babapoker
cek resi
agen poker online
download vivoslot
vivo slot
link altenatif vivo slot
agen vivo slot
download vivoslot apk
vivoslot net
mpo slot online terbaru
cara daftar idn poker
daftar idn poker
Rumah Syariah Malang
cara daftar joker123
Jual Bumbu Mie Majelismie
joker123
joker123 slot
win money now online
idn poker
joker slot
joker 123
poker88
slot online
joker 123
jokerslot
joker123.net
joker123
joker123
joker123 slot
vivoslot online
vivo slot
sbobet888