Esempio n. 1
0
	void File::ParseTypes(InputStream& s, CAtlList<CStringW>& types)
	{
		types.RemoveAll();

		CStringW str;

		for(int c = s.SkipWhiteSpace(); iswcsym(c) || c == '.' || c == '@'; c = s.PeekChar())
		{
			c = s.GetChar();

			if(c == '.') 
			{
				if(str.IsEmpty()) s.ThrowError(_T("'type' cannot be an empty string"));
				if(!iswcsym(s.PeekChar())) s.ThrowError(_T("unexpected dot after type '%s'"), CString(str));

				types.AddTail(str);
				str.Empty();
			}
			else
			{
				if(str.IsEmpty() && iswdigit(c)) s.ThrowError(_T("'type' cannot start with a number"));
				if((!str.IsEmpty() || !types.IsEmpty()) && c == '@') s.ThrowError(_T("unexpected @ in 'type'"));

				str += (WCHAR)c;
			}
		}

		if(!str.IsEmpty())
		{
			types.AddTail(str);
		}
	}
Esempio n. 2
0
Definition& Definition::operator[](LPCWSTR type)
{
    Definition* pRetDef = NULL;
    if(m_type2def.Lookup(type, pRetDef))
        return *pRetDef;

    pRetDef = DNew Definition(m_pnf, L"");
    pRetDef->m_priority = PLow;
    pRetDef->m_type = type;
    m_type2def[type] = pRetDef;

    CAtlList<Definition*> l;
    GetChildDefs(l, type);

    while(!l.IsEmpty())
    {
        Definition* pDef = l.RemoveHead();

        pRetDef->m_priority = pDef->m_priority;
        pRetDef->m_parent = pDef->m_parent;

        if(pDef->IsValue())
        {
            pRetDef->SetAsValue(pDef->m_status, pDef->m_value, pDef->m_unit);
        }
        else
        {
            pRetDef->m_status = node;
            pRetDef->m_nodes.AddTailList(&pDef->m_nodes);
        }
    }

    return *pRetDef;
}
Esempio n. 3
0
bool CFileAssoc::GetAssociatedExtensionsFromRegistry(CAtlList<CString>& exts) const
{
    exts.RemoveAll();

    CRegKey rkHKCR(HKEY_CLASSES_ROOT);
    LONG ret;
    DWORD i = 0;
    CString keyName, ext;
    DWORD len = MAX_PATH;

    while ((ret = rkHKCR.EnumKey(i, keyName.GetBuffer(len), &len)) != ERROR_NO_MORE_ITEMS) {
        if (ret == ERROR_SUCCESS) {
            keyName.ReleaseBuffer(len);

            if (keyName.Find(PROGID) == 0) {
                ext = keyName.Mid(_countof(PROGID) - 1);

                if (IsRegistered(ext)) {
                    exts.AddTail(ext);
                }
            }

            i++;
            len = MAX_PATH;
        }
    }

    return !exts.IsEmpty();
}
Esempio n. 4
0
	void File::ParseDefs(InputStream& s, Reference* pParentRef)
	{
		while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS)
		{
			NodePriority priority = PNormal;
			CAtlList<CStringW> types;
			CStringW name;

			int c = s.SkipWhiteSpace();

			if(c == '*') {s.GetChar(); priority = PLow;}
			else if(c == '!') {s.GetChar(); priority = PHigh;}

			ParseTypes(s, types);

			if(s.SkipWhiteSpace() == '#')
			{
				s.GetChar();
				ParseName(s, name);
			}

			if(types.IsEmpty())
			{
				if(name.IsEmpty()) s.ThrowError(_T("syntax error"));
				types.AddTail(L"?");
			}

			Reference* pRef = pParentRef;

			while(types.GetCount() > 1)
				pRef = CreateRef(CreateDef(pRef, types.RemoveHead()));

			Definition* pDef = NULL;

			if(!types.IsEmpty())
				pDef = CreateDef(pRef, types.RemoveHead(), name, priority);

			c = s.SkipWhiteSpace(L":=");

			if(c == '"' || c == '\'') ParseQuotedString(s, pDef);
			else if(iswdigit(c) || c == '+' || c == '-') ParseNumber(s, pDef);
			else if(pDef->IsType(L"@")) ParseBlock(s, pDef);
			else ParseRefs(s, pDef);
		}

		s.GetChar();
	}
Esempio n. 5
0
void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
    if (fns.IsEmpty()) {
        return;
    }

    const CAppSettings& s = AfxGetAppSettings();

    ResolveLinkFiles(fns);

    CAtlList<CString> sl;
    if (SearchFiles(fns.GetHead(), sl)) {
        if (sl.GetCount() > 1) {
            subs = NULL;
        }
        POSITION pos = sl.GetHeadPosition();
        while (pos) {
            ParsePlayList(sl.GetNext(pos), subs);
        }
        return;
    }

    CAtlList<CString> redir;
    CStringA ct = GetContentType(fns.GetHead(), &redir);
    if (!redir.IsEmpty()) {
        POSITION pos = redir.GetHeadPosition();
        while (pos) {
            ParsePlayList(sl.GetNext(pos), subs);
        }
        return;
    }

    if (ct == "application/x-mpc-playlist") {
        ParseMPCPlayList(fns.GetHead());
        return;
    } else {
#if INTERNAL_SOURCEFILTER_MPEG
        if (ct == "application/x-bdmv-playlist" && s.SrcFilters[SRC_MPEG]) {
            ParseBDMVPlayList(fns.GetHead());
            return;
        }
#endif
    }

    AddItem(fns, subs);
}
Esempio n. 6
0
void CFavoriteOrganizeDlg::SetupList(bool fSave)
{
    int i = m_tab.GetCurSel();

    if (fSave) {
        CAtlList<CString> sl;

        for (int j = 0; j < m_list.GetItemCount(); j++) {
            CAtlList<CString> args;
            ExplodeEsc(m_sl[i].GetAt((POSITION)m_list.GetItemData(j)), args, _T(';'));
            args.RemoveHead();
            args.AddHead(m_list.GetItemText(j, 0));
            sl.AddTail(ImplodeEsc(args, _T(';')));
        }

        m_sl[i].RemoveAll();
        m_sl[i].AddTailList(&sl);
    } else {
        m_list.DeleteAllItems();

        POSITION pos = m_sl[i].GetHeadPosition(), tmp;
        while (pos) {
            tmp = pos;

            CAtlList<CString> sl;
            ExplodeEsc(m_sl[i].GetNext(pos), sl, _T(';'), 3);

            int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead());
            m_list.SetItemData(n, (DWORD_PTR)tmp);

            if (!sl.IsEmpty()) {
                REFERENCE_TIME rt = 0;
                if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
                    DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt);

                    CString str;
                    str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
                    m_list.SetItemText(n, 1, str);
                }
            }
        }

        UpdateColumnsSizes();
    }
}
Esempio n. 7
0
bool CFileAssoc::GetAssociatedExtensions(const CMediaFormats& mf, CAtlList<CString>& exts)
{
    exts.RemoveAll();

    CAtlList<CString> mfcExts;
    for (size_t i = 0, cnt = mf.GetCount(); i < cnt; i++) {
        ExplodeMin(mf[i].GetExtsWithPeriod(), mfcExts, _T(' '));

        POSITION pos = mfcExts.GetHeadPosition();
        while (pos) {
            const CString ext = mfcExts.GetNext(pos);
            if (CFileAssoc::IsRegistered(ext)) {
                exts.AddTail(ext);
            }
        }
    }

    return !exts.IsEmpty();
}
Esempio n. 8
0
    void ParseDirs(CAtlList<CString>& paths)
    {
        POSITION pos = paths.GetHeadPosition();
        while (pos) {
            POSITION prevPos = pos;
            CString fn = paths.GetNext(pos);
            // Try to follow link files that point to a directory
            if (IsLinkFile(fn)) {
                fn = ResolveLinkFile(fn);
            }

            if (IsDir(fn)) {
                CAtlList<CString> subDirs;
                RecurseAddDir(fn, subDirs);
                // Add the subdirectories just after their parent
                // so that the tree is not parsed multiple times
                while (!subDirs.IsEmpty()) {
                    paths.InsertAfter(prevPos, subDirs.RemoveTail());
                }
            }
        }
    }
   // Define the integer list
   CAtlList<int> myList;

   // Populate the list
   myList.AddTail(1);
   myList.AddTail(2);
   myList.AddTail(3);
   myList.AddTail(4);

   // Confirm not empty
   ATLASSERT(myList.IsEmpty() == false);

   // Remove the tail element
   myList.RemoveTailNoReturn();

   // Confirm not empty
   ATLASSERT(myList.IsEmpty() == false);

   // Remove the head element
   myList.RemoveHeadNoReturn();

   // Confirm not empty
   ATLASSERT(myList.IsEmpty() == false);

   // Remove all remaining elements
   myList.RemoveAll();

   // Confirm empty
   ATLASSERT(myList.IsEmpty() == true);   
CString CBaseSplitterOutputPin::GetMediaTypeDesc(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter)
{
	if (mts.IsEmpty()) {
		return pName;
	}

	CLSID clSID;
	HRESULT hr = pFilter->GetClassID(&clSID);
	if ((clSID == __uuidof(CMpegSourceFilter)) || (clSID == __uuidof(CMpegSplitterFilter))) {
		return pName;
	}

	CAtlList<CString> Infos;
	const CMediaType* pmt = &mts[0];

	if (pmt->majortype == MEDIATYPE_Video) {
		const VIDEOINFOHEADER *pVideoInfo	= NULL;
		const VIDEOINFOHEADER2 *pVideoInfo2	= NULL;

		BOOL bAdd = FALSE;

		if (pmt->formattype == FORMAT_VideoInfo) {
			pVideoInfo = GetFormatHelper(pVideoInfo, pmt);

		} else if (pmt->formattype == FORMAT_MPEGVideo) {
			Infos.AddTail(L"MPEG");

			const MPEG1VIDEOINFO *pInfo = GetFormatHelper(pInfo, pmt);
			pVideoInfo = &pInfo->hdr;

			bAdd = TRUE;
		} else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
			const MPEG2VIDEOINFO *pInfo = GetFormatHelper(pInfo, pmt);
			pVideoInfo2 = &pInfo->hdr;

			bool bIsAVC = false;
			bool bIsMPEG2 = false;

			if (pInfo->hdr.bmiHeader.biCompression == FCC('AVC1') || pInfo->hdr.bmiHeader.biCompression == FCC('H264')) {
				bIsAVC = true;
				Infos.AddTail(L"AVC (H.264)");
				bAdd = TRUE;
			} else if (pInfo->hdr.bmiHeader.biCompression == FCC('AMVC')) {
				bIsAVC = true;
				Infos.AddTail(L"MVC (Full)");
				bAdd = TRUE;
			} else if (pInfo->hdr.bmiHeader.biCompression == FCC('EMVC')) {
				bIsAVC = true;
				Infos.AddTail(L"MVC (Subset)");
				bAdd = TRUE;
			} else if (pInfo->hdr.bmiHeader.biCompression == 0) {
				Infos.AddTail(L"MPEG2");
				bIsMPEG2 = true;
				bAdd = TRUE;
			}

			if (bIsMPEG2) {
				Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
			} else if (pInfo->dwProfile) {
				if (bIsAVC) {
					switch (pInfo->dwProfile) {
						case 44:
							Infos.AddTail(L"CAVLC Profile");
							break;
						case 66:
							Infos.AddTail(L"Baseline Profile");
							break;
						case 77:
							Infos.AddTail(L"Main Profile");
							break;
						case 88:
							Infos.AddTail(L"Extended Profile");
							break;
						case 100:
							Infos.AddTail(L"High Profile");
							break;
						case 110:
							Infos.AddTail(L"High 10 Profile");
							break;
						case 118:
							Infos.AddTail(L"Multiview High Profile");
							break;
						case 122:
							Infos.AddTail(L"High 4:2:2 Profile");
							break;
						case 244:
							Infos.AddTail(L"High 4:4:4 Profile");
							break;
						case 128:
							Infos.AddTail(L"Stereo High Profile");
							break;
						default:
							Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
							break;
					}
				} else {
					Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
				}
			}

			if (bIsMPEG2) {
				Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
			} else if (pInfo->dwLevel) {
				if (bIsAVC) {
					Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel)/10.0));
				} else {
					Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel));
				}
			}
		} else if (pmt->formattype == FORMAT_VIDEOINFO2) {
			const VIDEOINFOHEADER2 *pInfo = GetFormatHelper(pInfo, pmt);
			pVideoInfo2 = pInfo;
		}

		if (!bAdd) {
			BITMAPINFOHEADER bih;
			bool fBIH = ExtractBIH(pmt, &bih);
			if (fBIH) {
				CString codecName = CMediaTypeEx::GetVideoCodecName(pmt->subtype, bih.biCompression);
				if (codecName.GetLength() > 0) {
					Infos.AddTail(codecName);
				}
			}
		}

		if (pVideoInfo2) {
			if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
				Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
			}
			if (pVideoInfo2->AvgTimePerFrame) {
				Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo2->AvgTimePerFrame)));
			}
			if (pVideoInfo2->dwBitRate) {
				Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
			}
		} else if (pVideoInfo) {
			if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) {
				Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight));
			}
			if (pVideoInfo->AvgTimePerFrame) {
				Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo->AvgTimePerFrame)));
			}
			if (pVideoInfo->dwBitRate) {
				Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
			}
		}
	} else if (pmt->majortype == MEDIATYPE_Audio) {
		if (pmt->formattype == FORMAT_WaveFormatEx) {
			const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, pmt);

			if (pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
				Infos.AddTail(L"DVD LPCM");
			} else if (pmt->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
				const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, pmt);
				UNREFERENCED_PARAMETER(pInfoHDMV);
				Infos.AddTail(L"HDMV LPCM");
			}
			if (pmt->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
				Infos.AddTail(L"Dolby Digital Plus");
			} else {
				switch (pInfo->wFormatTag) {
					case WAVE_FORMAT_MPEG: {
						const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, pmt);

						int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
						Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
					}
					break;
					default: {
						CString codecName = CMediaTypeEx::GetAudioCodecName(pmt->subtype, pInfo->wFormatTag);
						if (codecName.GetLength() > 0) {
							Infos.AddTail(codecName);
						}
					}
					break;
				}
			}

			if (pInfo->nSamplesPerSec) {
				Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
			}
			if (pInfo->nChannels) {
				Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
			}
			if (pInfo->wBitsPerSample) {
				Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
			}
			if (pInfo->nAvgBytesPerSec) {
				Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
			}
		} else if (pmt->formattype == FORMAT_VorbisFormat) {
			const VORBISFORMAT *pInfo = GetFormatHelper(pInfo, pmt);

			Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0));

			if (pInfo->nSamplesPerSec) {
				Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
			}
			if (pInfo->nChannels) {
				Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
			}

			if (pInfo->nAvgBitsPerSec) {
				Infos.AddTail(FormatString(L"%d bit", pInfo->nAvgBitsPerSec));
			}
			if (pInfo->nAvgBitsPerSec) {
				Infos.AddTail(FormatBitrate(pInfo->nAvgBitsPerSec * 8));
			}
		} else if (pmt->formattype == FORMAT_VorbisFormat2) {
			const VORBISFORMAT2 *pInfo = GetFormatHelper(pInfo, pmt);

			Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0));

			if (pInfo->SamplesPerSec) {
				Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->SamplesPerSec)/1000.0));
			}
			if (pInfo->Channels) {
				Infos.AddTail(FormatString(L"%d chn", pInfo->Channels));
			}
		}
	}

	if (!Infos.IsEmpty()) {
		CString Ret = pName;
		Ret += " (";

		bool bFirst = true;

		for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
			const CString& String = Infos.GetAt(pos);

			if (bFirst) {
				Ret += String;
			} else {
				Ret += L", " + String;
			}

			bFirst = false;
		}

		Ret += ')';

		return Ret;
	}

	return pName;
}
Esempio n. 11
0
void SZYamlDocument::Dump(CString& strText, int nDumpIndent/* = SZYAML_DUMP_INDENT*/)
{
    POSITION pos = m_YamlItemList.GetHeadPosition();
    struct _KeyStackNode 
    {
        _KeyStackNode()
            : nIndent(0)
            , nChildIndent(0)
            , bIsList(FALSE)
        {
        }
        int nIndent;
        int nChildIndent;
        CString strKey;
        BOOL bIsList;
    };
    CAtlList<_KeyStackNode> listKeyStack;
    int nLastIndent = -1;
    BOOL bListItem = FALSE, bPrintThisLine = TRUE;
    CString strLine;

    strText = _T("");

    while (pos)
    {
        _YamlItem &item = m_YamlItemList.GetAt(pos);

        if (listKeyStack.IsEmpty())
            bListItem = FALSE;
        else
            bListItem = listKeyStack.GetTail().bIsList;

        if (item.nIndent == nLastIndent + 1)
        {
            _KeyStackNode &newkey = listKeyStack.GetAt(listKeyStack.AddTail());
            POSITION posNext = _GetNextPos(pos, TRUE);

            newkey.nIndent = item.nIndent;
            newkey.strKey = item.node.Key();
            newkey.bIsList = (posNext != NULL);
        }
        else if (item.nIndent == nLastIndent)
        {
            _KeyStackNode &newkey = listKeyStack.GetTail();
            POSITION posNext = _GetNextPos(pos, TRUE);

            newkey.nIndent = item.nIndent;
            newkey.strKey = item.node.Key();
            newkey.bIsList = (posNext != NULL);
        }
        else if (item.nIndent < nLastIndent)
        {
            for (nLastIndent -= item.nIndent; nLastIndent > 0; -- nLastIndent)
                listKeyStack.RemoveTail();

            if (listKeyStack.IsEmpty())
                bPrintThisLine = TRUE;
            else
            {
                _KeyStackNode &newkey = listKeyStack.GetTail();

                newkey.nIndent = item.nIndent;
                if (newkey.strKey != item.node.Key())
                {
                    newkey.strKey = item.node.Key();
                    POSITION posNext = _GetNextPos(pos, TRUE);
                    newkey.bIsList = (posNext != NULL);
                }
                else
                    bPrintThisLine = !newkey.bIsList;
            }
        }

#ifdef _SZYAML_DEBUG_TRACE
        { // Trace Key Stack
            kconsole::printf(_T("  "));

            for (POSITION pos = listKeyStack.GetHeadPosition(); pos != NULL; listKeyStack.GetNext(pos))
            {
                _KeyStackNode key = listKeyStack.GetAt(pos);
                kconsole::settextcolor(TRUE, TRUE, TRUE, FALSE);
                kconsole::printf(_T("(%d, '%s', %d)"), key.nIndent, key.strKey, key.bIsList);
                kconsole::settextcolor(TRUE, TRUE, TRUE, TRUE);
            }

            kconsole::printf(_T("\r\n"));
        }
#endif

        // 这里对不确定长度的%s不使用Format,是因为MIN_CRT的格式化输出限制长度为1024,见atlstr.h
        // by bbcallen 2009-07-02
        if (bPrintThisLine)
        {
            if (bListItem)
            {
                strLine.Format(
                    _T("%s-%s"),  
                    CString(_T(' '), (item.nIndent - 1) * nDumpIndent),  
                    CString(_T(' '), nDumpIndent - 1)
                    );
                strLine.Append(item.node.Key());
                strLine.Append(_T(": "));
                strLine.Append(item.node.String());
                strLine.Append(_T("\r\n"));
            }
            else
            {
                strLine.Format(
                    _T("%s"),  
                    CString(_T(' '), item.nIndent * nDumpIndent)
                    );

                strLine.Append(item.node.Key());
                strLine.Append(_T(": "));
                strLine.Append(item.node.String());
                strLine.Append(_T("\r\n"));
            }
#ifdef _SZYAML_DEBUG_TRACE
            kconsole::printf(strLine);
#endif
            strText += strLine;
        }
        else
            bPrintThisLine = TRUE;

        nLastIndent = item.nIndent;

        m_YamlItemList.GetNext(pos);
    }
}
Esempio n. 12
0
BOOL SZYamlDocument::Load(LPCTSTR lpszText)
{
    BOOL bResult = FALSE;
    BOOL bNotFinish = TRUE;
    CString strText = lpszText, strLine, strKey, strValue;
    int nThisLinePos = 0, nNextLinePos = 0, nColonPos = 0;
    int nIndent = 0, nLineNum = 1;
    struct _KeyStackNode 
    {
        _KeyStackNode()
            : nIndent(0)
            , nChildIndent(0)
            , bIsList(FALSE)
        {
        }
        int nIndent;
        int nChildIndent;
        CString strKey;
        BOOL bIsList;
    };
    CAtlList<_KeyStackNode> listKeyStack;
    BOOL bNewChild = FALSE, bIsListItem = FALSE;

    m_YamlItemList.RemoveAll();

    if (!lpszText)
        goto Exit0;

    while (bNotFinish)
    {
        nNextLinePos = strText.Find(_T('\n'), nThisLinePos);
        if (-1 == nNextLinePos)
        {
            bNotFinish = FALSE;
            strLine = strText.Mid(nThisLinePos);
        }
        else
            strLine = strText.Mid(nThisLinePos, nNextLinePos - nThisLinePos);

        nIndent = 0;

        // Get indent
        while (_T(' ') == strLine[nIndent])
            nIndent ++;

        nColonPos = strLine.Find(_T(':'));

        strKey = strLine.Left(nColonPos).Trim();
        strValue = strLine.Mid(nColonPos + 1).Trim();

        if (_T('-') == strKey[0])
        {
            int nIndentMore = 1;

            while (_T(' ') == strKey[nIndentMore])
                nIndentMore ++;

            nIndent += nIndentMore;

            strKey = strKey.Mid(nIndentMore);

            bIsListItem = TRUE;
        }
        else
            bIsListItem = FALSE;

        if (bNewChild)
        {
            _KeyStackNode &LastKey = listKeyStack.GetTail();
            LastKey.nChildIndent = nIndent;

            if (bIsListItem)
                LastKey.bIsList = TRUE;

#ifdef _SZYAML_DEBUG_TRACE
            { // Trace Key Stack
                kconsole::printf(_T("  "));

                for (POSITION pos = listKeyStack.GetHeadPosition(); pos != NULL; listKeyStack.GetNext(pos))
                {
                    _KeyStackNode key = listKeyStack.GetAt(pos);
                    kconsole::printf(_T("(%d, '%s', %d)"), key.nChildIndent, key.strKey, key.bIsList);
                }

                kconsole::printf(_T("\r\n"));
            }
#endif
        }

        strLine = strLine.Mid(nIndent);

        if (strLine.IsEmpty())
            continue;

        while (!listKeyStack.IsEmpty())
        {
            _KeyStackNode &LastKey = listKeyStack.GetTail();
            if (LastKey.nChildIndent == nIndent)
                break;

#ifdef _SZYAML_DEBUG_TRACE
            kconsole::printf(_T(" ### (%d, %d)\r\n"), LastKey.nChildIndent, nIndent);
#endif

            if (LastKey.nChildIndent < nIndent)
            {
#ifdef _SZYAML_DEBUG_TRACE
                kconsole::printf(_T(" * ERROR: Line %d, Indent Error\r\n"), nLineNum);
#endif
                goto Exit0;
            }

            listKeyStack.RemoveTail();

#ifdef _SZYAML_DEBUG_TRACE
            { // Trace Key Stack
                kconsole::printf(_T("  "));

                for (POSITION pos = listKeyStack.GetHeadPosition(); pos != NULL; listKeyStack.GetNext(pos))
                {
                    _KeyStackNode key = listKeyStack.GetAt(pos);
                    kconsole::printf(_T("(%d, '%s', %d)"), key.nChildIndent, key.strKey, key.bIsList);
                }

                kconsole::printf(_T("\r\n"));
            }
#endif
        }

        if (bIsListItem && !bNewChild)
        {
            _KeyStackNode &LastKey = listKeyStack.GetTail();
            SZYamlNode newNode;

            newNode.SetKey(LastKey.strKey);
            _AppendNode((int)listKeyStack.GetCount() - 1, newNode);
        }

        if (1 < strValue.GetLength() && strValue[0] == strValue[strValue.GetLength() - 1]
            && (_T('\'') == strValue[0] || _T('\"') == strValue[0]))
            strValue = strValue.Mid(1, strValue.GetLength() - 2);

        if (strValue.IsEmpty())
        {
            _KeyStackNode &NewKey = listKeyStack.GetAt(listKeyStack.AddTail());

            NewKey.nIndent = nIndent;
            NewKey.strKey = strKey;

            bNewChild = TRUE;
        }
        else
            bNewChild = FALSE;

        {
            SZYamlNode newNode;

            newNode.SetKey(strKey);
            newNode.SetValue(strValue);
            _AppendNode((int)listKeyStack.GetCount() - (bNewChild ? 1 : 0), newNode);
        }

        nThisLinePos = nNextLinePos + 1;
        ++ nLineNum;
    }

    SZYamlHandle::_SetPosition(this, m_YamlItemList.GetHeadPosition());

    bResult = TRUE;

Exit0:

    return bResult;
}