星海's Blog

老头初学编程

Qt源代码初探(一)——qglobal.h

/*
  Qt中qRound的实现,在负数的情况下不同于一般的四舍五入。
  如果负数尾数 <=.5的情况下,则舍弃尾数。(注意,=的情况下也舍弃o)
  如果负数尾数 > 0.5的情况下,则负小数整数部分-1
**/
Q_DECL_CONSTEXPR inline int qRound(double d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }

/**
 * Qt中通过模板获取qptrdiff的类型
 * TODO: 知识点:我能力有限,暂时不清楚模板应用底层原理。
 * 通过模板参数直接获取相关类型
 * 似乎与工厂设计模式有些相近(只是个人理解,如有误请留言指正)
 */

template <int> struct QIntegerForSize;
template <>    struct QIntegerForSize<1> { typedef quint8  Unsigned; typedef qint8  Signed; };
template <>    struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
template <>    struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
template <>    struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
typedef qptrdiff qintptr;

/* unused参数的非warnning */
#  define Q_UNUSED(x) (void)x;

/*
 * QGlobalStatic在非线程情况下为一般static实现
 * 在线程情况下使用了QAtomicPointer自动指针,然后用QGlobalStaticDeleter注册其智能指针,在QGlobalStaticDeleter析构后,自动delete掉QGlobalStatic对象。
 * TODO: 具体原因暂时不清
 */

/*
 * 因浮点数不适宜用 == 好直接比较,所以采用了浮点数精度模糊的方法
 */
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
{  return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));}

/**
 * Q_FOREACH宏末尾
 * 主要是兼顾Q_FOREACH之后的内容(用{}括起来)
 */
for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
{ ;}


/* 使用模板返回相关的指针,用于private class当中,避免void然后强制类型转换
 */
  template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }

/*
 * Q_DECLARE_PRIVATE(Class)等宏通过类中的d_ptr和q_ptr实现private class,以实现二进制兼容
 */

/*
 * TODO: QPrivate 中的enable_if还需要了解,可借助 std::enable_if的说明
 */

Qt = Cute Great LoveIt 之Json TreeWidget的生成 与QHttpMultiPart

一切都很简单清爽,甚至感觉超过了Python(我不会用PYTHON,但看过相关Python实现)。。。。太爽了。。。呵呵。。。

 

示例1:Json数据解析并在QTreeWidget中直接显示JSON解析后的树

#include "JsonTree.h"
#include <QtCore>

JsonTree::JsonTree(QTreeWidget *widget, const QJsonObject &object)
{
  treeWidget = widget;
  responseObject = object;
  parseObject(responseObject);
}

void JsonTree::parseObject(const QJsonObject &object, QTreeWidgetItem *parent)
{
  QStringList objectKeys = object.keys();
  QTreeWidgetItem *child;
  for (int i = 0; i < objectKeys.size(); i++) {

    if (parent == NULL)
      child = new QTreeWidgetItem(treeWidget);
    else
      child = new QTreeWidgetItem(parent);

    child->setText(0, objectKeys[i]);
    QJsonValue value = object[objectKeys.at(i)];
    parseJsonValue(value, 1, child);
  }
}

void JsonTree::parseJsonValue(const QJsonValue &jsonValue, int column, QTreeWidgetItem *node)
{
  QString valueStr;

  QJsonArray  array;
  switch (jsonValue.type()) {
  case QJsonValue::Bool:
    valueStr = jsonValue.toBool() ? "True" : "False";
    node->setText(column, valueStr);
    break;
  case QJsonValue::String:
    valueStr = jsonValue.toString();
    node->setText(column, valueStr);
    break;
  case QJsonValue::Double:
    valueStr = QString::number(jsonValue.toDouble());
    node->setText(column, valueStr);
    break;
  case QJsonValue::Null:
    valueStr = "NULL";
    node->setText(column, valueStr);
    break;
  case QJsonValue::Undefined:
    qDebug() << "Undefined Json Value, check your request";
    break;
  case QJsonValue::Array:
    // Array used Key(array.at(i)) :null
    array = jsonValue.toArray();
    for (int i = 0; i < array.size(); i++) {
      parseJsonValue(array[i], 0, new QTreeWidgetItem(node));
    }
    break;
  case QJsonValue::Object:
    parseObject(jsonValue.toObject(), node);
    break;
  default:
    qDebug() << "what's the fucking in parseJsonValue default";
    break;
  }
}

 

示例2:当前各种WebService横行,从B2C/B2B到社交网络,普遍要用到POST方法组装参数更新当前数据,Qt提供了强大但方便可操作的QHttpMultiPart。一切都很简单爽快,没有歧义和乱七八糟的Boundary和各种\r\n让你头晕。

  QHttpMultiPart picPost;

  QHttpPart statusPart;
  statusPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
  statusPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"status\""));
  statusPart.setBody("测试QT5-SINA-WEIBO-API, json Formatter");

  QHttpPart imagePart;
  imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
  imagePart.setHeader(QNetworkRequest::ContentDispositionHeader,
                      QVariant("form-data; name=\"pic\"; filename=\"test.jpg\""));
  QFile *file = new QFile("/home/sd44/test.jpg");
  file->open(QIODevice::ReadOnly);
  imagePart.setBodyDevice(file);

  picPost.append(statusPart);
  picPost.append(imagePart);


  networkAccessManager->post(sinaUploadApiUrl, picPost);


gsoap 2.8.x 的中文第一字节乱码问题。

webservice SOAP开发gsoap是首选,但在Ubuntu/Chkra Linux上,soap_dom_element处理中文字符串都会出现问题,翻找了网上所有解决文档,如wchar */ UTFSTRING/MBSTRING均不能解决。
具体表现是多字节UTF-8文字,在字符串存储时,第一个文字乱码。
经DEBUG,发现, 第一个文字前多了一个BYTE,十六进制表示为0XC3,第一个文字的第一个BYTE的前4比特也有错误。
其他均正常。


后来总算找到了解决方法。。。。。升级到2.8.11或之后版本就可以了。。-_______-。。。

是stdsoap2.c中soap_peek_element函数的BUG,由官方修正。
 

C++ Templates FAQ(转)

转自   http://womble.decadent.org.uk/c++/template-faq.html

 

C++ Templates FAQ

This is not an introduction or a reference manual to templates. It deals with some of the more complex yet still common problems with templates.

Other information

Templates are an essential part of modern C++, and any good recent introduction to C++ should cover them. If you lack such an introductory text, I recommend you read either Koenig & Moo, Accelerated C++ (Addison-Wesley, ISBN 020170353X, US sellers, UK sellers) or Stroustrup, The C++ Programming Language 3rd ed. (Addison Wesley, ISBN 0201700735, US sellers, UK sellers), depending on your prior programming experience.

Some basic questions about templates are answered by Marshall Cline's C++ FAQ Lite.

For in-depth reference, see Vandevoorde & Josuttis, C++ Templates: The Complete Guide (Addison-Wesley, ISBN 0201734842, US sellers, UK sellers).

Acknowledgement

Daveed Vandevoorde kindly reviewed this FAQ for correctness.

Contents

  1. Why do I get a syntax error when I use a type that's a member of a template in the definition of another template?
  2. My compiler says that a member of a base class template is not defined in a derived class template. Why is it not inherited?
  3. Is it possible to specialise a member function of a class template without specialising the whole template?
  4. Why doesn't Visual C++ 6 accept my definition of a class template's member function outside of the class definition?
  5. Why does every instance of my function template do the same thing under Visual C++ 6?
  6. Why do I need to add "template" and "typename" in the bodies of template definitions?
  7. What is two-phase name lookup?
  8. What are dependent names?
  9. What are non-dependent names?
  10. Which rules do the various C++ implementations apply for name resolution in templates?
  11. Is there a difference between a function template and a template function, or between a class template and a template class?
  12. What does the error message "specialization of ... in different namespace" mean?
  13. What does the error message "duplicate explicit instanatiation of ..." mean?
  1. Q: Why do I get a syntax error when I use a type that's a member of a class template in the definition of another template?

    template<typename T>
    struct first {
        typedef T * pointer;
    };
    
    template<typename T>
    class second {
        first<T>::pointer p; // syntax error
    };

    A: In a template, the name of a member of another class that depends on its template parameter(s) (first<T>::pointer in this example, dependent on the T parameter) is a dependent name that is not looked-up immediately. To tell the compiler that it is meant to refer to a type and not some other sort of member, you must add the keyword typename before it.

  2. Q: My compiler says that a member of a base class template is not defined in a derived class template. Why is it not inherited?

    template<typename T>
    class base {
    public:
        void base_func();
    };
    
    template<typename T>
    class derived : public base<T> {
    public:
        void derived_func()
        {
            base_func(); // error: base_func not defined
        }
    };

    A: It is inherited. However, the standard says that unqualified names in a template are generally non-dependent and must be looked up when the template is defined. Since the definition of a dependent base class is not known at that time (there may be specialisations of the base class template that have not yet been seen), unqualified names are never resolved to members of the dependent base class. Where names in the template are supposed to refer to base class members or to indirect base classes, they can either be made dependent by qualifying them or brought into the template's scope with a using-declaration. In the example, this could be achieved by replacing the call to base_func() with this->base_func() or base<T>::base_func(), or by adding the declaration using base<T>::base_func;.

  3. Q: Is it possible to specialise a member function of a class template without specialising the whole template?

    A: According to the standard, you can declare a full specialisation of a member function of a class template like this:

    template<typename T>
    class my_class {
    public:
        bool func();
        // other functions
    };
    
    template<>
    bool my_class<int>::func();

    Unfortunately not all compilers support this.

  4. Q: Why doesn't Visual C++ 6 accept my definition of a member function template outside of the class definition?

    class my_class {
    public:
        template<typename T> void func();
    };
    
    template<typename T>
    void my_class::func()
    {
        // implementation
    }

    A: This is a limitation of Visual C++ 6 which was fixed in version 7.

  5. Q: Why does every instance of my function template do the same thing under Visual C++ 6?

    template<typename T>
    std::size_t my_sizeof()
    {
        return sizeof(T);
    }

    A: This is a bug in Visual C++ 6 which was fixed in version 7. It distinguishes function template instances only by their function parameter types, not by their template arguments, so unless all template parameters are used in the declaration of the function parameter types it is possible for some instances of the template to be discarded and other instances used instead. As a workaround, you can use the template parameters to define optional function parameters that are never used:

    template<typename T>
    std::size_t my_sizeof(T * = 0)
    {
        return sizeof(T);
    }
  6. Q: Why do I need to add "template" and "typename" in the bodies of template definitions?

    A: The meaning of a name used in a template definition may depend upon the template parameters, in which case it cannot automatically be determined when the template is defined. Early implementations of templates postponed resolution of all names used in a template to the time of instantiation, but this was found to be error-prone. It made it impossible to parse template definitions completely because many C++ syntax rules depend on distinguishing between names that refer to objects or functions, names that refer to types, and names that refer to templates.

    Later implementations parse templates as soon as they are defined. They require the programmer to specify which dependent names refer to types or templates, so that they can parse the templates without ambiguity. Where a dependent name is intended to refer to a type, it must generally be prefixed by the keyword typename. (This is not necessary when it is used in the list of base classes of a class template, since only type names can be used there.) Where a dependent qualified name or a prefix of such a name is intended to refer to a template, the last component of it must be prefixed by the keyword template. Note that some implementations may consider names to be dependent where the standard says they are non-dependent, and may therefore require additional uses of typename and template.

    template<typename Alloc>
    class container_helper
    {
        typedef Alloc::value_type value_type;
            // ill-formed: Alloc::value_type is assumed to be an object or function
        typedef typename Alloc::value_type value_type;
            // OK: Alloc::pointer is properly disambiguated
        typedef Alloc::typename value_type value_type;
            // ill-formed: "typename" must precede the whole qualified name
        typedef std::pair<value_type, value_type> element_type;
            // OK: value_type is resolved in the immediate scope
        typedef typename Alloc::rebind<element_type>::other element_allocator;
            // ill-formed: Alloc::rebind is assumed to be an object or function
        typedef typename template Alloc::rebind<element_type>::other element_allocator;
            // ill-formed: "template" must precede the last component of the
            // template name
        typedef typename Alloc::template rebind<element_type>::other element_allocator;
            // OK: rebind is properly disambiguated
    };
    
    template<typename T, typename Alloc = std::allocator<T> >
    class my_container : private container_helper<Alloc>::element_allocator
            // OK: container_helper<Alloc>::element_allocator cannot be resolved
            // but base names are assumed to be type names
    {
    };
  7. Q: What is two-phase name lookup?

    A: This is the process specified by the standard for looking up names in templates. It is called "two-phase name lookup" because it divides names used in a template into two categories (dependent and non-dependent) that are resolved at different times. It was introduced into the draft standard some time in 1993 or 1994 but unfortunately has not been implemented by many vendors until quite recently. It makes name resolution more reliable, but is incompatible with a lot of older template code.

    The rules specifying exactly which names are considered dependent and which non-dependent are mostly intuitive, but with some corner cases. They can be found in section 14.6 of the standard.

  8. Q: What are dependent names?

    A: Dependent names are names whose definitions are considered to depend upon the template parameters and for which there is no declaration within the template definition. They are resolved only when the template is instantiated. Those that are intended to refer to types or templates may require disambiguation.

    If the resolution of a dependent function name uses argument-dependent lookup, declarations in the arguments' namespaces that are visible at the point of instantiation will be considered as well as declarations visible at the point of definition. (The former is normally a superset of the latter, but may not be.)

  9. Q: What are non-dependent names?

    A: Non-dependent names are those names that are considered not to depend upon the template parameters, plus the name of the template itself and names declared within it (members, friends and local variables). They are resolved when the template is defined, in the normal way, and do not require disambiguation.

  10. Q: Which rules do the various C++ implementations apply for name resolution in templates?

    A: I have divided implementations into three categories: CFront, those that resolve all names at the point of instantiation, like CFront did; intermediate, those that parse templates more fully, resolving some names at the point of definition and requiring disambiguation of others; and standard, those that use the standard rules. Note that there is a lot of variation among the "intermediate" implementations.

    Implementation Versions and options Name lookup rules
    Comeau C++ 4.x, CFront mode CFront
    4.x, relaxed mode;
    4.0-4.2.43, strict mode
    intermediate
    4.2.44-4.3.3, strict mode standard
    GNU C++ (g++) 2.8-3.3 intermediate
    3.4-4.1 standard
    Metrowerks CodeWarrior 8-9, default intermediate (?)
    8-9, -iso-templates standard
    Microsoft Visual C++ 6.0 CFront
    7.0-8.0 (VS.NET 2002-2005) intermediate

    (This table is acknowledged to be incomplete and possibly incorrect in some details. Let me know if you have more information.)

  11. Q: Is there a difference between a function template and a template function, or between a class template and a template class?

    A: The term "function template" refers to a kind of template. The term "template function" is sometimes used to mean the same thing, and sometimes to mean a function instantiated from a function template. This ambiguity is best avoided by using "function template" for the former and something like "function template instance" or "instance of a function template" for the latter. Note that a function template is not a function. The same distinction applies to "class template" versus "template class".

    Note that the 1998 C++ standard used the terms "template class" and "template function" in some places, but this was corrected in the 2003 version.

  12. Q: What does the error message "specialization of ... in different namespace" mean?

    A: This means that the code appears to be defining a template specialisation, but it names a template that was defined in a different namespace. This is not valid, though some older versions of g++ accept it. Every declaration for a template must be placed in the same namespace, just like repeated declarations of any other named entity.

  13. Q: What does the error message "duplicate explicit instantiation of ..." mean?

    A: An explicit instantiation of a function or class template is a definition of a function or class. It is an error to define either of those more than once in a translation unit, whether or not they are instantiated from a template. It is also an error to define a function more than once in an entire program unless it is defined as inline.


Ben Hutchings

Last modified: Mon Dec 13 13:34:12 GMT 2010

我的doxygenfile

只列出与doxygen -g DoxyFile不一样的地方

EXTRACT_ALL            = YES
EXTRACT_PRIVATE        = YES
EXTRACT_STATIC         = YES
RECURSIVE              = YES
GENERATE_LATEX         = NO

# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT               = YES

# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
UML_LOOK               = YES

# If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command.
CALL_GRAPH             = YES

# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command.
CALLER_GRAPH           = YES

我从大牛身上学什么?

我是个业余小菜,入门偏上级别,并不是小牛小虾之类。。。。只是有几次碰巧和几位大牛结缘,看客不要误解先。。。

 

1, 我碰到一个GNU软件很偶尔的一次崩溃,当时某大牛和我在同一个聊天室,我向其随便一说。

大牛让我详细描述事件发生情况,我说我用的是Ubuntu ALPHA版,出现问题很正常,可能是系统原因,而非软件本身,可能不重要。(其实我心里也觉得 免费开源的东东,为这Alpha系统里出现的软件崩溃大费周章挺费力)

大牛不乐意,硬是坚持,说“重要不重要我说了算……” 后来没有找到具体原因,崩溃环境无法再现,大牛让我以后再有此类问题的话注意下比告知他。

这一点可能是认真

 

2, 我接了某大牛一个微不足道的GUI程序,功能并不复杂,基本都实现后交给了某大牛,让其看还要做什么改进。

乖乖,从UI界面的简单快捷,到按钮文字前加图片,线程化的 各个要求都出来了。。。。。为一个不起眼的软件,所做的一点也不会少。。

 

这一点可能是细致

 

3, 某大项目的牛人,只在网上见过名字,没接触过。我看到一篇非常好的大项目的WIKI译文,把链接发到了IRC上。

此牛以为译文作者是我,立刻问我,为什么不把这译文放到WIKI的中文版面上。。。。。在知道作者不是我后,在译文后留言表达这个想法

其实,这个项目可能被母公司砍出去了。。。。。大牛或者不负责这个项目了,或者他本人已经跳槽,最起码来说,这个项目暂时也是下坡路的,个人收益和开发人员数量都不会很乐观了……

 

我想,这是爱。。。。。

 

CMAKE FINDGRAPHICSMAGICK MODULE

最近在用GM API编程,采用了CMAKE作为构建系统

CMAKE自带ImageMagick的Find module,但是缺少GraphisMagick的

碰巧我在使用GM,所以找了下网上的GM module,最早的也是15个月前的,且稍稍有点问题。

 

于是我结合FINDIMAGEMAGICK MODULE代码,稍稍修改了下GraphisMagick。

以支持WINDOWS和LINUX双系统(只是搜索Magick API和Magick++ API)

内容如下:

 

#-*-cmake-*-
#
# Test for GraphicsMagick libraries, unlike CMake's FindGraphicsMagick.cmake which
# tests for GraphicsMagick's binary utilities
#
# Once loaded this will define
#  MAGICK_FOUND        - system has GraphicsMagick
#  MAGICK_INCLUDE_DIR  - include directory for GraphicsMagick
#  MAGICK_LIBRARY_DIR  - library directory for GraphicsMagick
#  MAGICK_LIBRARIES    - libraries you need to link to
#
#  MAGICK++_FOUND        - system has GraphicsMagick
#  MAGICK++_INCLUDE_DIR  - include directory for GraphicsMagick
#  MAGICK++_LIBRARY_DIR  - library directory for GraphicsMagick
#  MAGICK++_LIBRARIES    - libraries you need to link to
#

SET(MAGICK_FOUND   "NO" )
SET(MAGICK++_FOUND "NO" )

FIND_PATH( MAGICK_INCLUDE_DIR
  NAMES magick.h
  PATHS
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include"
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include/magick"
  /usr/include/GraphicsMagick/magick
  "$ENV{MAGICK_LOCATION}/magick"
  "$ENV{MAGICK_LOCATION}/include"
  "$ENV{MAGICK_LOCATION}/include/GraphicsMagick"
  "$ENV{MAGICK_LOCATION}/include/magick"
  "$ENV{MAGICK_HOME}/include/magick"
  /usr/include/magick
  /usr/include/
  /usr/local/include
  /usr/local/include/GraphicsMagick/magick
  /usr/local/include/GraphicsMagick/
  /opt/local/include/GraphicsMagick/magick
  /opt/local/include/GraphicsMagick
  )

FIND_PATH( MAGICK++_INCLUDE_DIR
  NAMES Magick++.h
  PATHS
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include"
  "$ENV{MAGICK++_LOCATION}/Magick++"
  "$ENV{MAGICK++_LOCATION}/include/"
  "$ENV{MAGICK_LOCATION}/Magick++"
  "$ENV{MAGICK_LOCATION}/include/Magick++"
  "$ENV{MAGICK_LOCATION}/include/GraphicsMagick"
  "$ENV{MAGICK_LOCATION}/include/"
  "$ENV{MAGICK_HOME}/include/"
  /usr/include/GraphicsMagick
  /usr/include/Magick++
  /usr/include/
  /usr/local/include
  /usr/local/include/GraphicsMagick
  /opt/local/include/GraphicsMagick/Magick++
  /opt/local/include/GraphicsMagick
  )

FIND_LIBRARY( Magick
  NAMES GraphicsMagick CORE_RL_magick_
  PATHS 
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/lib"
  "$ENV{MAGICK_LOCATION}/magick/.libs"
  "$ENV{MAGICK_LOCATION}/lib"
  "$ENV{MAGICK_HOME}/lib"
  /usr/lib64
  /usr/local/lib64
  /opt/local/lib64
  /usr/lib
  /usr/local/lib
  /opt/local/lib
  DOC   "GraphicsMagick magic library"
  )


FIND_LIBRARY( Magick++
  NAMES GraphicsMagick++ CORE_RL_Magick++_
  PATHS 
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/lib"
  "$ENV{MAGICK++_LOCATION}/.libs"
  "$ENV{MAGICK_LOCATION}/.libs"
  "$ENV{MAGICK++_LOCATION}/lib"
  "$ENV{MAGICK_LOCATION}/lib"
  "$ENV{MAGICK_HOME}/lib"
  /opt/local/lib64
  /usr/lib64
  /usr/local/lib64
  /opt/local/lib
  /usr/lib
  /usr/local/lib
  DOC   "GraphicsMagick Magick++ library"
  )


SET(MAGICK_LIBRARIES ${Magick} )
SET(MAGICK++_LIBRARIES ${Magick++} )


IF (MAGICK_INCLUDE_DIR)
  IF(MAGICK_LIBRARIES)
    SET(MAGICK_FOUND "YES")
    GET_FILENAME_COMPONENT(MAGICK_LIBRARY_DIR ${Magick}   PATH)
  ENDIF(MAGICK_LIBRARIES)
ENDIF(MAGICK_INCLUDE_DIR)

IF (MAGICK++_INCLUDE_DIR)
  IF(MAGICK++_LIBRARIES)
    SET(MAGICK++_FOUND "YES")
    GET_FILENAME_COMPONENT(MAGICK++_LIBRARY_DIR ${Magick++} PATH)
  ENDIF(MAGICK++_LIBRARIES)
ENDIF(MAGICK++_INCLUDE_DIR)


IF(NOT MAGICK_FOUND)
  # make FIND_PACKAGE friendly
  IF(NOT Magick_FIND_QUIETLY)
    IF(Magick_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR
        "GraphicsMagick required, please specify it's location with MAGICK_HOME, MAGICK_LOCATION or MAGICK++_LOCATION")
    ELSE(Magick_FIND_REQUIRED)
      MESSAGE(STATUS "GraphicsMagick was not found.")
    ENDIF(Magick_FIND_REQUIRED)
  ENDIF(NOT Magick_FIND_QUIETLY)
ENDIF(NOT MAGICK_FOUND)


#####

猎头朋友的面试建议。。。。

开始面试程序员,一个坛子的猎头朋友给了几点建议,很真诚和坦率的建议噢。

1.像邮件通知面试这种东西,就国内的企业来说,大可不必理会,因为它很有可能是系统自动发送的;

2.如果一个公司迫切需要某个职位的人,他们也不会选择仅用邮件通知的方式,因为有很多人只是把简历挂在了网上而已,有时候自己的私人邮箱N久才打开一次,一般来讲HR方面会用电话通知候选人来面试,再发邮件介绍详细情况;

3.不知名的公司可以先百度或者GOOGLE查查,看有没有相关信息,起码要查查他们的官网地址啊什么的,自己可以判断一下这家公司的价值;

4.如果你怕错失机会,想去这家公司,而对方只发了个邮件的话,你可以自己打电话去该公司的HR那,了解职位情况,看看跟自己是否匹配;(虽然 HR很多时候在技术层面可能不够你专业,但他至少知道这个职位最看重哪些技能,至少有几个keyword。PS:有很多HR也是从技术转过来的,HW就有 不少这样的人)

5.要记住,你跟用人单位是平等的,在他们要求了解你的各项综合技能的同时,你也有权知道职位的详细情况。就面试时间来讲,要在你和他们都OK的时间,当然,也不是要你摆谱,只是这个东西可以去协调的;电话确认很重要,省得浪费时间。

 

她之前的另外几点建议:

1、建议大家注册一个中国人才热线的帐号,看了那么多的人才网站,我就觉得CJOL的简历模板是最简洁明了且内容全面的;

2、写简历的时候不要一味的想强调自己的工作经验丰富而多多的列几家公司,其实这个是职场大忌,你的就职公司越多,就越代表你这个人不稳定,特别 是一家集团公司下面的几家子公司,或者一家公司不同阶段的不同职位,你不需要分类列出来,直接放在一个工作经验里汇总就好了。因为筛选简历的初级人员,每 天会看N多份简历,没有人会仔细去研究的,有时候一眼扫过去,看到你的跳槽频率太频繁就直接PASS掉了;

3、作简历工作经验那块,一定要把你的工作职责、工作内容写清楚,特别是有项目经验的,也要把项目大概描述下,并且要把你在项目中所处的位置,所 做的工作,以及这个项目的成就和你在项目中所起的作用写出来。如果你的工作涉及到跟不同部门人打交道,或者用到各种软硬件工具,也请罗列出来。因为按正常 流程来走,是先由初级人员筛选简历——HR——部门主管,而前两者都不是专业技术人员,不能对他们要求太高,他们只能通过部门主管给的要求按key point来找人,如果你的简历没有这些,将又失去一次机会;(建议工作经验这块言简意赅的1、2、3、4。。这样列出来,让别人清楚你是干什么的、会什 么同时也不要太罗嗦)

4、如果你还在职,建议你找工作的时候,在网站上的名字用化名,或者X先生、X小姐代替(因为很有可能你们公司的HR会搜到你的简历),如果公司或者项目内容涉及到竞业禁止协议或者不方便说的,也可以用“XXXXXXX”代替;

5、面试这块,我想说的是,平常心对待。不用紧张,你们是平等的,他们需要你这种人才,你是可以为他们创造价值的人,否则他们不会浪费时间来见 你。沉着冷静对待,原则是,他们问什么你答什么,多说多错,在你不了解这个公司的公司文化和氛围的前提下,表现出稳重总是错不了的。

latex中的moderncv简历模板升级了,与相关问题解决方案

新版本有中文moderncv模板的例子文件。

自己在实际使用中遇到以下几个问题:

1,最新版本是2月6号的,如果安装了完整的texlive2011,直接升级所有包即可

sudo tlmgr update --self

sudo tlmgr update --all
 

2,左边框过窄,导致中文日期自动折行。

解决方法:修改简历文件 xx.tex中的内容,
\setlength{\hintscolumnwidth}{3cm}           % 如果你希望改变日期栏的宽度
 

将hintscolumnwidth后面的数字,改成适合你的宽度。

 

3,\xelatex \latex等特殊字符无法显示,提示 underfull \hbox等内容。

解决方法:是因为设置的默认字体为DejaVu Sans Mono,不支持tex logo。

\usefont{OT1}{cmr}{b}{n}\XeLaTeX{}

b为粗体,可改为m为平常粗细。。。。

 

4,笔记本是texlive2011版本,家中台式机是2010.对2010使用 sudo tlmgr update --self --all升级后,编译无法通过,提示

xparse Error: Support package l3kernel too old..

经查找,是系统中有老版本包所致,需要删除 collection-latex3 、expl3、xpackages 这三个包(注意有倚赖关系)

删除后就可以了。。。。。

我所阅读的书籍及笔记(持续更新)

总是誊抄笔记发在BLOG上的效率太低,不如直接在实体书或电子书上做标记。
基本上,以后除了算法书、难题、陷阱 以外不会再做BLOG上的笔记了。。。
下面是我所看书的书目,

电子版的笔记是用xournal所做,请用xournal配合同名PDF文件打开。

(如果有xournal笔记的,会提供原版高清电子书PDF格式下载以配合笔记使用

    如果侵权了,请告知 -_____-)

 

一,C/C++类

  1. K&R《C程序设计语言》

笔记在本站BLOG

   2.  《C PRIMER PLUS》      

笔记在本站BLOG(分散)

   3.  《Linux编程一站式学习》

笔记在本站BLOG(分散)

   4.  《C++ PRIMER》4th Edition

xournal笔记下载

 

二,操作系统

   1. 《深入理解计算机系统》第二版

xournal笔记下载

   2. 《UNIX环境高级编程》(APUE)

笔记在本站BLOG

 

三,GUI

   1. 《Linux窗口程序设计——Qt4精彩实例分析》

xournal笔记下载(只做到了第二章,继续中)