2010년 9월 24일 금요일

현재 블로그는

현재 블로그는 설치형 블로그에 의존하고 있습니다.
http://nambaxa.wo.tc/tc/ 로 오면 똑같은 블로그가 있습니다.

요즘은 위키를 더 선호합니다.
http://wiki.nambaxa.wo.tc 입니다.

2010년 8월 5일 목요일

클래스 크기에 멤버 함수가 영항을 줄까?

일단 VS2008에서의 답은 NO 입니다.


좀 생각해 보면 그럴 만도 하지..
컴파일 된 이후 오브젝트 코드에서 무슨 클래스와 멤버 변수, 함수 개념이 있나..
그냥 언어 단계에서 사람들이 작성할 때 필요한 규칙일 뿐인 것을.

2010년 6월 1일 화요일

getPath

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

std::string getPath(std::string & fullpath);

int main(int argc, char **argv)
{
    std::vector<std::string> arglist;

    for(char ** v = argv+1; *v != NULL; ++v) {
        std::cout << *v << std::endl;
        arglist.push_back( getPath(std::string(*v)) );
    }

    std::copy(arglist.begin(), arglist.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
    return EXIT_SUCCESS;
}


std::string getPath(std::string & fullpath)
{
    for(std::string::iterator it = fullpath.begin();
        it != fullpath.end();
        ++it)
    {
        if( *it == '\\' )
            *it = '/';
    }

    std::string::size_type pos_beg =  fullpath.at(0)    == '\"' ? 1 : 0;
    std::string::size_type pos_end = *fullpath.rbegin() == '/'  ? std::string::npos : fullpath.rfind('/')+1;
    
    return fullpath.substr(pos_beg, pos_end);    
}